summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'github/nasm-2.15.xx'H. Peter Anvin2020-07-051-3/+27
|\
| * Make debug info and error messages correctly reflect macros and repsH. Peter Anvin (Intel)2020-07-051-3/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Error messages would issue with the line number of %endrep. 2. Debug line information would ignore both macros and reps. This is doubly wrong; macros are semantically equivalent to inline functions, and it is expected that debuggers trace into these functions. These changes finishes the last parts of moving all responsibility for the listing enable/disable into the preprocessor, so remove the way over-complicated macro inhibit facility from the listing module entirely. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | Merge remote-tracking branch 'github/nasm-2.15.xx'H. Peter Anvin (Intel)2020-06-302-1/+162
|\ \ | |/ | | | | | | | | | | Resolved Conflicts: version Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
| * emptyarg.asm: add expansion test for a range with a single parameterH. Peter Anvin (Intel)2020-06-301-0/+8
| | | | | | | | | | | | Add a test for %{1:1}, as reported in BR 3392611. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
| * preproc: fix %{:} macro operand rangesH. Peter Anvin (Intel)2020-06-301-1/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix the handling of %{:} macro operands. Use the same code for expanding the subarguments as for normal arguments. This (hopefully) resolves the following bug reports: BR 3392611, BR 3392686, BR 3392688 Reported-by: <coconutfaistoslimeregistry@gmail.com> Reported-by: Jasper Lievisse Adriaanse <r+nasm@jasper.la> Reported-by: Jason Hood <jadoxa@yahoo.com.au> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
| * listing: list short reserved blocks as ?? instead of <res ...>H. Peter Anvin (Intel)2020-06-271-0/+15
| | | | | | | | | | | | | | | | | | | | | | <res ...> can get rather annoying when mixed in with data, as can happen with the MASM-like db syntax. List shorter blocks (8 bytes or less) as ?? instead; 8 bytes avoids line breaks for a single statement. This is probably more readable anyway... Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | Merge tag 'nasm-2.15'H. Peter Anvin (Intel)2020-06-273-10/+35
|\ \ | |/ | | | | | | | | | | NASM 2.15 Resolved Conflicts: version
| * test: add Makefile target for elfx32H. Peter Anvin (Intel)2020-06-261-0/+3
| | | | | | | | | | | | Add an .ox Makefile target for an ELFx32 object. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
| * test: enable debugging outputH. Peter Anvin (Intel)2020-06-261-8/+8
| | | | | | | | | | | | | | There is no reason why we should not emit debugging output when compiling test files for manual analysis, quite the contrary. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
| * doc: document operator and Dx changesH. Peter Anvin (Intel)2020-06-251-2/+2
| | | | | | | | | | | | | | Document new operators, removal of special casing for %if, and the MASM-like enhancements to the Dx directives. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
| * BR 3392681: handle a64 instruction patters correctlyH. Peter Anvin (Intel)2020-06-221-0/+22
| | | | | | | | | | | | | | | | | | | | The a64 instruction patterns would incorrectly force REX to zero at a point where REX prefixes have already been assigned. This is not only incorrect in case of instructions which can use high registers, but it causes an assertion failure. It happened to work for J*CXZ and LOOP*. Reported-by: Philip Lantz <philip.lantz@intel.com> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | Merge tag 'nasm-2.15rc8'H. Peter Anvin (Intel)2020-06-142-0/+8
|\ \ | |/ | | | | NASM 2.15rc8
| * preproc: even more handling of backwards compatibility for mmacrosH. Peter Anvin (Intel)2020-06-141-0/+1
| | | | | | | | | | | | | | | | | | Legacy multi-line macro argument expansion really is very complicated. With these changes, all legacy tests seem to pass, and the only differences with NASM 2.14.xx are that some macros which should have been expanded and were not now are. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
| * test/ifdef.asm: test for simple %ifdefH. Peter Anvin (Intel)2020-06-051-0/+7
| | | | | | | | | | | | For some reason, %ifdef is failing now?! Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | preproc: add %require directiveH. Peter Anvin (Intel)2020-06-051-0/+2
|/ | | | | | | | | Most programming languages these days have a "require" directive, which is analogous to %include except that it automatically guards against multiple inclusion. This is useful enough to add, since with nasm_realpath() we can now to this (mostly) reliably. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* BR 3392667: more reasonable limit for expression descentH. Peter Anvin (Intel)2020-06-011-0/+0
| | | | | | | | Set an expression descent limit to 8192, which is more reasonable to expect to work on most platforms. Furthermore, if getrlimit() exists, then try to use it to see if we need to further limit the size. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* preproc: error out if an include file exists but can't be openedH. Peter Anvin (Intel)2020-06-011-0/+2
| | | | | | | | | | If an include file exists, but cannot be opened, that is still a critical error. However, downgrade this from a fatal to a nonfatal error. There really isn't any reason to stop cold here. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* BR 3392669: in expand_one_smacro(), we may reach EOL before tafterH. Peter Anvin (Intel)2020-06-011-0/+0
| | | | | | | | | If the rest of the line is consumed, we may never see tafter, so we have to test for end of line at line 5412. We already do at 5397, so it clearly should have been there all along. Reported-by: <puppet@zju.edu.cn> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* BR 3392668: preproc: test for macro in TOK_LOCAL_SYMBOLH. Peter Anvin (Intel)2020-06-011-0/+0
| | | | | | | | | | TOK_LOCAL_SYMBOL is only applicable inside a macro; otherwise error out just like we do for TOK_MMACRO_PARAM. This *partially* addresses BR 3392668. Reported-by: <puppet@zju.edu.cn> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* test: Add BR3392607Chang S. Bae2020-04-221-0/+2
| | | | | | Reported-by: Henrik Gramner <herik@gramner.com> Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392607 Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* test: Add BR3392661Chang S. Bae2020-04-221-0/+8
| | | | | | Suggested-by: <mae.bdf@outlook.com> Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392661 Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* test: Add BR3392660Chang S. Bae2020-04-211-0/+9
| | | | | | Suggested-by: C. Masloch <pushbx@ulukai.org> Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392660 Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* test: Add BR3392640Chang S. Bae2020-04-211-0/+4
| | | | | | Suggested-by: C. Masloch <pushbx@ulukai.org> Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392640 Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* test: Add BR3392630Chang S. Bae2020-04-211-1/+5
| | | | | | | | Add the test code into the existing xdefine testing. Suggested-by: C. Masloch <pushbx@ulukai.org> Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392630 Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* test: Add BR3392626Chang S. Bae2020-04-211-0/+6
| | | | | | | | | | | There are many similar preprocessor loop cases but located on each bug-report basis. While it looks to be better to consolidate them together, add one more test case like what was done before. Suggested-by: C. Masloch <pushbx@ulukai.org> Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392626 Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* test: test case for BR 3392655, overflow during bin format linkH. Peter Anvin2020-03-311-0/+37
| | | | | | | The bin format linker should warn if a relocation overflows its virtual address. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* preproc: fix %undef of macro aliases, and add %ifdefaliasH. Peter Anvin (Intel)2019-10-231-0/+52
| | | | | | | | | | | Macro aliases can legitimately point to nonexistent macros. Furthermore, %undef should remove the pointed-at macro, not the alias. This led to an infinite loop in the existing code; fix that. Add an %ifdefalias directive to test for the existence of an alias. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* preproc: properly protect %xdefine params (see below), cleanupsH. Peter Anvin (Intel)2019-10-232-0/+17
| | | | | | | | | | | | | | | | | | 1. %xdefine was broken because the code used i as a loop, which is a standard use for the name i. To avoid that confusion in the future, use "op" rather than "i" to hold the directive constant. 2. Once (1) was fixed, the smacro expansion code would fail because of parameter token numbers being indistinguishable between the ongoing expansion and the %xdefine parameters. In a first pass, mark the parameters with a new TOK_XDEF_PARAM token number, and change them to proper parameter token numbers in a second pass, which is now moved into define_smacro() which is where it arguably belongs. 3. Add a few tests for token pasting and xdefine with and without parameters. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Implement an enhanced version of MASM's dup() and "db ?" syntax.H. Peter Anvin (Intel)2019-10-161-0/+21
| | | | | | | | | Add support for complex data (Dx) statement expressions involving both initialized and uninitialized data. In addition, we have support for overriding the size of each element on an individual item and/or list basis. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* preproc: fix the detection of the >= operatorH. Peter Anvin2019-10-071-1/+1
| | | | | | There are *four* operators starting with ">": > >> >>> and >=. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* preproc: make %exitrep do what it is supposed toH. Peter Anvin2019-10-071-0/+16
| | | | | | | | | | | | | | %exitrep should should stop emitting code immediately, not just terminate the loop when we hit %endrep. There is a bunch of hacky code that special-cases that using istk->in_progress == 0. The handling of the tail of %exitrep, %include and non-emitting conditionals using entirely different mechanisms is just dumb. They need to be unified. Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392612 Reported-by: Jason Hood <jadoxa@yahoo.com.au> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* test: add a test for symbol prefixes via %pragmaH. Peter Anvin2019-09-301-0/+22
| | | | | | | Add a test for symbol prefixes via %pragma, including overlapping directives. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* elf: fix "object" symbol keywordH. Peter Anvin2019-09-121-0/+2
| | | | | | | | | The "object" symbol keyword would incorrectly generate STT_NOTYPE instead of STT_OBJECT. Add test for weak object references; they are different from plain weak references in that they are guaranteed to resolve to zero if the symbol is not found. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Drop unnecessary EXTERN symbolsH. Peter Anvin2019-09-121-1/+2
| | | | | | | | | | | | Currently, NASM always issues as an unknown symbol any symbol declared EXTERN. This is highly undesirable when using common header files, as it might cause the linker to pull in a bunch of unnecessary modules, depending on how smart the linker is. Add a new REQUIRED directive which behaves like the old EXTERN, for the use cases which might still need this behavior. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* elf: support weak global and extern referencesH. Peter Anvin2019-09-121-3/+20
| | | | | | | | A global or extern definition can now contain the keyword "weak" (or "strong", although that is the default) to create a weak symbol or a weak external reference, respectively. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* preproc: fix varadic macros, add conditional comma operatorH. Peter Anvin (Intel)2019-08-201-0/+6
| | | | | | | | | | | Fix the (severely broken handling of) varadic macros. Add a conditional comma operator "%,". This expands to a comma unless followed by a null expansion of some sort, which allows suppressing the comma before an empty argument (usually varadic, but not necessarily.) Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* listing: add the -L+ option to enable all listing optionsH. Peter Anvin (Intel)2019-08-191-1/+1
| | | | | | | -L+ or %pragma list options ++ will enable all possible listing options. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* BR 3392472: don't complain on wraparound for lower bit modesH. Peter Anvin (Intel)2019-08-161-0/+12
| | | | | | | | | | | If the address we are using is >= the size of the instruction, then don't complain on overflow as we can wrap around the top and bottom of the address space just fine. Alternatively we could downgrade it to OUT_WRAP in that case. Reported-by: C. Masloch <pushbx@38.de> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* test: very simple test for MASM displacement syntaxH. Peter Anvin (Intel)2019-08-141-0/+36
| | | | | | Very trivial test of MASM package. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Add %pragma list optionsH. Peter Anvin2019-08-101-0/+2
| | | | | | | Add a %pragma to set (or clear) listing options. It only takes effect on the next assembly pass, however! Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* obsolete handing: handle a few more subcases in a useful wayH. Peter Anvin (Intel)2019-08-091-0/+3
| | | | | | | | | Distinguish instructions which have once been valid (OBSOLETE) from those that never saw the light of day (NEVER). Futhermore, flag instructions which devolve to an architectural noop from those with undefined behavior and possibly recycled opcodes. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* BR 3392590: add warning for valid but obsolete instructionsH. Peter Anvin (Intel)2019-08-091-0/+9
| | | | | | | | | | | Just becase one is compiling for an old CPU doesn't mean one wants to use obsolete instructions that would not be forward compatible. Rename the "obsolete" warning to "obsolete-removed" and create a new "obsolete-valid" warning to go with it (-w[+-]obsolete controls both options, as usual.) Suggested-by: C. Masloch <pushbx@38.de> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* listing: add -L option for additional listing infoH. Peter Anvin (Intel)2019-08-091-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | Add an -L option for additional listing information. Currently supported is -Le, which emits each line after processing through the preprocessor, and -Lm, which displays each single-line macro defined or undefined. NASM doesn't preserve the names of unused arguments, nor does it have any technical reason to do so. Instead of adding complexity to save them, make unnamed parameters official by specifying an empty string in the argument list. This has the additional advantage that () is now simply considered a single empty argument, which means that NASM should now properly handle things like: %define myreg() eax mov edx,myreg() ... similar to how the C preprocessor allows an empty macro argument list which is distinct from a macro with no arguments whatsoever. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Add implicitly sized versions of the K instructionsH. Peter Anvin (Intel)2019-08-091-0/+137
| | | | | | | | | This allows the K instructions to be specified without a size suffix as long as the operands are sized; this matches the way most other x86 instructions work. As this is not the syntax specified in the SDM, don't use it for disassembly. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* br3392586: add test case for smacro descentH. Peter Anvin (Intel)2019-08-071-0/+8
| | | | | | Add test case for smacro descent from bug 3392586. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Add group aliases for all prefixed warnings.H. Peter Anvin2019-06-061-1/+1
| | | | | | | For example, -w+float will now enable all warnings with names staring with float-*. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Merge branch 'evalmacro'H. Peter Anvin (Intel)2019-04-245-0/+27
|\ | | | | | | | | | | | | | | | | | | | | Resolved Conflicts: asm/preproc.c output/elf.h output/outelf.c output/outelf.h version Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
| * preproc: add %i... variants, evaluated macro parameters, cleanupsevalmacroH. Peter Anvin2019-02-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All directives which create single-line macros now have %i... variants to define case-insensitive versions. Case insensitive rather sucks, but at least this way it is consistent. Single-line macro parameters can now be evaluated as a number, as done by %assign. To do so, declare a parameter starting with =, for example: %define foo(x,=y) mov [x],macro_array_y ... would evaluate y as a number but leave x as a string. NOTE: it would arguably be better to have this as a per-instance basis, but it is easily handled by having a secondary macro called with the same argument twice. Finally, add a more consistent method for defining "magic" macros, which need to be evaluated at runtime. For now, it is only used by the special macros __FILE__, __LINE__, __BITS__, __PTR__, and __PASS__. __PTR__ is a new macro which evaluates to word, dword or qword matching the value of __BITS__. The magic macro framework, however, provides a natural hook for a future plug-in infrastructure to hook into a scripting language. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * ELF: handle more than 32,633 sectionsH. Peter Anvin2019-02-264-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Dead code elimination in ELF uses separate ELF sections for every functions or data items that may be garbage collected. This can end up being more than 32,633 sections which, when the ELF internal and relocation sections are added in, can exceed the legacy ELF maximum of 65,279 sections. Newer versions of the ELF specification has added support for much larger number of sections by putting a place holder value (usually SHN_XINDEX == 0xffff, but 0 in some cases) into fields where the section index is a 16-bit value, and storing the full value in a diffent place: the program header uses entries in section header 0, the symbol table uses an auxiliary segment with the additional indicies; the section header did not need it as the sh_link field is already 32 (or 64) bits long. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * outelf: hash sections for performanceH. Peter Anvin2019-01-121-0/+6
| | | | | | | | | | | | | | | | Use a hash table to look up sections by name, and an RAA to look up sections by index; thus remove O(n) searches. This becomes important since ELF uses sections for dead code elimination. Signed-off-by: H. Peter Anvin <hpa@zytor.com>