Commit graph

213 commits

Author SHA1 Message Date
Anonymous Maarten
8c717107dd
Emit an error when seeing an invalid condition code in a macro (nasm mode) (#316)
Some checks failed
Build / Build - Ubuntu (push) Failing after 4s
Build / Build - MSVC (push) Has been cancelled
Build / Build - macOS (push) Has been cancelled
make-check: check .errwarn file first if yasm failed
2026-07-28 17:44:34 -07:00
Anonymous Maarten
7a7762c337
cmake: support CMake 4.0 and cross building (#307) 2026-07-20 22:36:19 -07:00
Anonymous Maarten
1f09fa089d
cmake: register all modules in yasm_init_plugin (#301)
Some modules were not registered when dynamically loading yasmstd.
2026-07-20 22:29:03 -07:00
PoroCYon
4dc8c3bf03
Add support for NASM %warning preprocessor directive (#232)
Regular NASM supports this, while Yasm doesn't seem to. This fixes the
discrepancy.
2023-06-17 23:44:01 -07:00
Ulya Trofimovich
811f24d0bf
GAS preprocessor: don't cut comments inside of string literals. (#81) 2023-05-12 21:23:13 -07:00
bird2tori
241bf4c42c
More makedep features (#80)
yasm.c: Added -MD, -MT and -MP options similar to gcc. Also added --makedep-dos2unix-slash for helping users of NUG make (and similar) on Windows. The -MD option does both assembling and Makefile dependency generation in one go, which convenient and a little quicker.

nasm-preproc.c: Have to always gather dependencies to support -MD. Minimal cost.

Co-authored-by: knut st. osmundsen <bird-skylake@anduin.net>
2023-05-12 21:22:36 -07:00
Duncan Ogilvie
8b6c7b237c
Fix allocator mismatch (#107) 2023-05-12 21:19:37 -07:00
Fighter19
529c14bfdc
Fix badly freed pointer on indented code block after rept (#189) 2023-05-12 21:13:44 -07:00
cryptobro
fa9e004383
gas preproc: Fix UB/crashes (#186) 2023-05-12 21:12:54 -07:00
bird2tori
4808260d62 Leak fixes (#79)
* preproc/nasm: Close the input file; addressed a few memory leaks.

* yasm.c: delete include paths before we exit

* cv-dbgfmt.c: Free cv_filename::filename too.
2017-09-23 15:08:58 -07:00
Henrik Gramner
32ad9c46ce Support numbers prefixed with + or - in %ifnum 2015-10-17 21:50:15 +02:00
Denis Denisov
0c2d90c6b3 Fix yasm segfaults GNU assembler files on OS X
Bug: http://tortall.lighthouseapp.com/projects/78676/tickets/269
2014-11-15 23:37:54 +02:00
Henrik Gramner
e32ff2c2ab Use a larger hash table size
Increases compilation speed of files with a large number of macros by
around 20x.
2014-01-21 00:24:40 +01:00
Peter Johnson
716c17112d nasm-pp.c: Plug a memory leak. 2011-09-30 12:52:32 -07:00
Peter Johnson
0ed2cc4451 Generate version number information from git history.
Due to the svn import structure, a special case is currently implemented
to look for the 1.1.0 branchpoint instead of the most recent tag on the
master branch.  This will be removed after the first release is tagged
on the master branch in git.

Specific details:

autogen.sh: More aggressively clean autoconf cache.
This is needed to ensure the version number is actually regenerated.

Don't generate PACKAGE_PATCHLEVEL or PACKAGE_BUILD variables.  The
genversion program now parses PACKAGE_VERSION directly.

For Mkfiles builds, YASM-VERSION.h is generated and included by the custom
config.h.  This avoids the need to edit config.h for versioning.
2011-08-27 09:25:30 -07:00
Peter Johnson
94ab1135a3 Remove $Id$ and RCSID() usage.
These are useless now that we're using git.
2011-08-19 10:43:16 -07:00
Peter Johnson
5355299056 Improve gas syntax .set directive to better match GNU as behavior.
- Add support for deferred symbols (those which depend on other symbols
  that have not yet been .set)
- Add support for re-defining symbols
- Add support for 0x hex notation in literals

Contributed by: Alexei Svitkine <alexei.svitkine@gmail.com>

svn path=/trunk/yasm/; revision=2366
2010-08-21 07:32:54 +00:00
Peter Johnson
0d3b3797e5 Fix #213: Fix gas-preproc misuse of strcpy() and uninitialized variables.
- strcpy() was being used with overlapping memory ranges; switched to memmove().
- bline->line_number was not set in one location.

Exact causes identified using valgrind.

svn path=/trunk/yasm/; revision=2348
2010-08-01 17:44:56 +00:00
Peter Johnson
bc3a8286ea NASM preproc: Add basic support for %{x:y} parameter list expansion.
Contributed by: Mathieu Monnier

nasm64developer has a more advanced 3-parameter version that will take
some time to integrate, so for now just provide the simpler version.

svn path=/trunk/yasm/; revision=2312
2010-04-08 03:46:43 +00:00
Peter Johnson
2de9ac8ede NASM preprocessor: Add %scope and %endscope.
Contributed by: Mathieu Monnier

svn path=/trunk/yasm/; revision=2311
2010-04-08 03:32:04 +00:00
Peter Johnson
74e776b0f6 Add support for gas preprocessor macro directives.
It doesn't yet support the full set of macro types gas supports, but
can handle a lot of common cases.

Contributed by: Alexei Svitkine

svn path=/trunk/yasm/; revision=2285
2010-02-13 07:22:23 +00:00
Peter Johnson
419e16fc71 nasm_pp_cleanup(): Do a better job of cleaning up.
svn path=/trunk/yasm/; revision=2283
2010-02-06 09:13:56 +00:00
Peter Johnson
26c7e74729 substitute_values(): Allocate sufficient space for null terminator.
Noticed by: Alexei Svitkine

svn path=/trunk/yasm/; revision=2274
2010-01-14 08:10:35 +00:00
Peter Johnson
e7185d2e24 gas-preproc.c: Use sprintf instead of snprintf.
It's impossible for a decimal long string to be longer than 64 chars.

Also remove workaround for MSVC added in r2267.

svn path=/trunk/yasm/; revision=2273
2010-01-13 04:44:28 +00:00
Peter Johnson
553e615b56 Unbreak make distcheck.
svn path=/trunk/yasm/; revision=2268
2010-01-07 06:55:03 +00:00
Peter Johnson
6ede18e881 GAS preproc: Fix line number for .rept without matching .endr error.
The line number reported for the error is that of the .rept directive.

Contributed by: Alexei Svitkine <alexei.svitkine@gmail.com>

svn path=/trunk/yasm/; revision=2265
2010-01-03 21:59:28 +00:00
Peter Johnson
5ce81be7fe gas-preproc.c: Avoid warning on unused variable.
svn path=/trunk/yasm/; revision=2261
2010-01-03 02:41:50 +00:00
Peter Johnson
bf8e6be2a9 Improve the gas preprocessor and re-add it as default for gas parser.
Contributed by: Alexei Svitkine <alexei.svitkine@gmail.com>

Summary of changes:
- Correct line numbers will now be reported for warnings and errors
  when using the GAS preprocessor
- GAS preprocessor will now replace defined (e.g. via .set) variables
  by their values in lines returned to the parser
- GAS preprocessor will now handle multi-line comments correctly
- GAS preprocessor will now handle nested .rept directives correctly

svn path=/trunk/yasm/; revision=2260
2010-01-03 02:04:13 +00:00
Peter Johnson
5501768adb Use queue.h HEAD macros more portably (also avoiding compiler warning).
svn path=/trunk/yasm/; revision=2258
2010-01-03 01:04:18 +00:00
Peter Johnson
a530673198 gas-preproc.c: Avoid casting away of const.
svn path=/trunk/yasm/; revision=2247
2009-12-26 04:38:27 +00:00
Peter Johnson
7a6e9cb430 Update gas preproc a bit:
- Handle removal of comments during preprocessing
- Fix a bug with evaluation of nested .if/.else statements.

Contributed by: Alexei Svitkine <alexei.svitkine@gmail.com>

svn path=/trunk/yasm/; revision=2246
2009-12-26 04:30:39 +00:00
Peter Johnson
9f471a9ba9 nasm-pp.c: Use vsnprintf if available.
Patch contributed by: Alexei Svitkine <alexei.svitkine@gmail.com>

svn path=/trunk/yasm/; revision=2245
2009-12-26 04:28:40 +00:00
Peter Johnson
493c5b8861 Add initial gas preprocessor, contributed by Alexei Svitkine.
Support for include directive amongst other major key pieces.
Does not currently support macros.
Fixes #79.

Contributed by: Alexei Svitkine <alexei.svitkine@gmail.com>

svn path=/trunk/yasm/; revision=2243
2009-12-23 06:45:17 +00:00
Peter Johnson
b5f0a4008c Fix #184: test -e is not portable (despite being in POSIX); use test -f instead.
svn path=/trunk/yasm/; revision=2226
2009-07-30 02:19:38 +00:00
Peter Johnson
0e0556cc9d Unbreak distcheck.
svn path=/trunk/yasm/; revision=2224
2009-07-25 05:29:47 +00:00
Peter Johnson
bccb81d575 tasm (tweaked nasm) preproc fixes:
- comments stripped before tokenization caused strings containing ';'
   to generate warnings (unterminated string) and incorrect output.
 - assume directive parsing did not properly handle ';' as end of line

Also add tests for the above.

Reported by: Rugxulo <rugxulo@gmail.com>

svn path=/trunk/yasm/; revision=2197
2009-04-17 03:25:08 +00:00
Peter Johnson
338a832c34 Fix #155: Don't crash on missing %endmacro.
We were crashing because we didn't generate this error until the preproc
module was getting cleaned up, which doesn't happen until after linemap
is cleaned up.  Instead detect and output this error when we reach the end
of preprocessed tokens during the parsing stage.

svn path=/trunk/yasm/; revision=2185
2009-03-24 06:33:32 +00:00
Peter Johnson
92f63a58c7 Unbreak snapshots (broken in [2172]).
Noticed by: Mark Charney <mark.charney@intel.com>

svn path=/trunk/yasm/; revision=2176
2009-03-04 07:39:02 +00:00
Peter Johnson
b6c9134ac7 Fix #166: Off-by-one error in raw preproc caused hang on lines longer than
512 characters.

svn path=/trunk/yasm/; revision=2172
2009-01-27 06:38:14 +00:00
Peter Johnson
36598c7334 Don't assume CPP_PROG is 3 characters long (e.g. "gcc -E" isn't).
Reported and fix submitted by: Mark Charney

svn path=/trunk/yasm/; revision=2159
2008-11-25 09:16:26 +00:00
Peter Johnson
a51609437b Use yasm functions yasm__strcasecmp and nasm_strdup instead of relying on
platform to have them.

Also, instead of using snprintf, preallocate and then use sprintf.  This
also avoids the while() reallocation loop.

Reported by: Brian Gladman

svn path=/trunk/yasm/; revision=2139
2008-10-08 05:19:47 +00:00
Peter Johnson
536542a69e Fix a number of warnings.
svn path=/trunk/yasm/; revision=2133
2008-10-07 05:59:29 +00:00
Peter Johnson
1e77ce6c40 Add core TASM syntax support.
Contributed by: Samuel Thibault <samuel.thibault@ens-lyon.org>

It is built on top of the NASM parser and preproc, with the following
notable extensions for TASM syntax:
 - case insensitive symbols and filenames,
 - support for segment and size of labels, which permits to avoid giving
   them on each memory dereference,
 - support for data reservation (i.e. e.g. "var dd ?"),
 - support for multiples (i.e. e.g. "var dd 1 dup 10"),
 - little endian string integer constants,
 - additional expression operators: shl, shr, and, or, low, high,
 - additional offset keyword,
 - additional fword and df,
 - support for doubled quotes within quotes,
 - support for array-like and structure-like notations: t[eax] and
   [var].field,
 - support for tasm directives: macro, rept, irp, locals, proc, struc,
   segment, assume.

Notes:

 - Almost all extensions are only effective when tasm_compatible_mode is
   set, so we should have very reduced possible breakage.

 - Because the "and" keyword can be an expression operator and an
   instruction name, the data pseudo-instructions explicitly switch the
   lexer state to INSTRUCTION state to fix the ambiguity.

 - In gen_x86_insn.py, several instructions (namely lds and lea) now take
   relaxed memory sizes.  The reason is that in the case of tasm, the size
   of the actual pointed data is passed up to there, and thus any type of
   data should be accepted.

With all of this, loadlin can be compiled by yasm with quite reduced
modifications.

A new TASM-like frontend is also included.

svn path=/trunk/yasm/; revision=2130
2008-10-07 05:38:11 +00:00
Peter Johnson
b7f2fbc64f Add cmake build infrastructure.
Not default nor even distributed in the .tar.gz, the cmake build allows for
loadable yasm plugins by building libyasm as a shared library.
Example plugins are in the plugins/ directory, and may be loaded into a
cmake-built yasm using the -N command line option (non-cmake builds will
not have this option).

Tested only on Linux so far, but should be relatively painless to port to
Windows thanks to the use of cmake rather than libtool to create shared
libraries.

The only modification to the main source tree is some conditional-compiled
additions to yasm.c.

svn path=/trunk/yasm/; revision=2098
2008-05-22 09:08:03 +00:00
Peter Johnson
cbf0c7befd Split NASM preprocessor standard macro set between various modules.
Standard macro sets are looked up based on parser and preprocessor keyword
from individual modules.

The "standard" NASM parser macros now reside in the NASM parser, so when
the GAS parser is used with the NASM preprocessor, the NASM-specific macros
are no longer defined.

Object-format specific macros are now individually defined by each object
formatm module.  This allows for the object formats to be independent of the
NASM preprocessor module and yields a small optimization benefit as unused
object format macros don't need to be skipped over.

Also add GAS macro equivalents for the Win64 SEH more complex directives [1].

[1] Requested by Brian Gladman <brg@gladman.plus.com>

svn path=/trunk/yasm/; revision=2082
2008-05-09 06:46:02 +00:00
Peter Johnson
ca23bda1cf Defensively look for NULL istk.
svn path=/trunk/yasm/; revision=2075
2008-04-25 05:07:57 +00:00
Peter Johnson
0fba7dca8d Fix #130: Add SAFESEH directive for indicating SEH handlers in win32 output.
Unlike in MASM, no command-line switch is required.
Usage:
  extern handler (or handler: to define locally)
  safeseh handler

svn path=/trunk/yasm/; revision=2032
2008-02-08 18:26:40 +00:00
Peter Johnson
02075ed7ca Fix #123: Be explicit that errors are such by printing "error:" at beginning
of error messages.

svn path=/trunk/yasm/; revision=2019
2007-12-04 06:19:07 +00:00
Peter Johnson
bd06f1aace Support use of EQU values within NASM preprocessor.
Note: label values are still not supported, and probably never will be,
as yasm is single-pass parsing, and only reads the source file once.
Someday we may add specific support for relatively common %if-%error
idioms.

svn path=/trunk/yasm/; revision=2008
2007-11-03 04:37:44 +00:00
Peter Johnson
f9824d2cfc Change preprocessor interface from block-oriented to line-oriented.
This will make certain types of parser-preprocessor synchronization
easier for upcoming feature enhancements.

Due to additional complexity in GAS (rept), internally GAS converts
lines back into blocks.

svn path=/trunk/yasm/; revision=2007
2007-11-03 04:27:35 +00:00