aboutsummaryrefslogtreecommitdiffstats
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* preproc: %while ... %endwhile looploopsH. Peter Anvin2019-10-081-0/+5
| | | | | | | First user of the new loop infrastructure: a %while[n][cond] loop; supports anything that the %if/%elif directives support, too. Signed-off-by: H. Peter Anvin <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>
* | warnings: add [warning push] and [warning pop]H. Peter Anvin (Intel)2019-01-111-0/+10
|/ | | | | | Add [warning push] and [warning pop] directives. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* BR 3392538: test case for double free in listing moduleH. Peter Anvin2018-12-241-0/+27
| | | | | | | | | Test case from bug 3392538 for double free in the listing module. This is the test case only, not a fix. Reported-by: <russyz@comcast.net> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* insns.dat: accept explicit ax/eax/rax operand to CLZEROH. Peter Anvin2018-12-221-0/+26
| | | | | | | | | AMD documents this instruction with an rax operand. The error behavior implies this is an address-size-sensitive instruction. Add support for specifying the explicit operand, but consistent with normal ndisasm behavior, don't disassemble the implicit operand. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* test/Makefile: add .aout targetH. Peter Anvin (Intel)2018-12-181-2/+5
| | | | | | We had no target for generating an aout format file. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* BR 3392368: actually fix the documentation; add test caseH. Peter Anvin2018-11-261-5/+24
| | | | | | Add a mimimal test case for this bug; correct the documentation. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Correctly document the BR 3392368 fix, add test caseH. Peter Anvin2018-11-261-3/+9
| | | | Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* asm: support the +n syntax for register setsH. Peter Anvin2018-06-251-0/+12
| | | | | | | Support the +n syntax for multiple contiguous registers, and emit it in the output from ndisasm as well. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* test: make absolute.asm buildable even when not in binary modeH. Peter Anvin, Intel2018-06-251-3/+4
| | | | | | | absolute.asm is useful even for other backends, so explicitly test to see if ORG is possible for this format. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* test: add test for context-local labels and extern label promotionH. Peter Anvin, Intel2018-06-251-0/+25
| | | | | | | | Add a simple test case for context-local (%$) labels not disturbing the local variable namespace, and extern labels getting promoted to global. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* test: test for ELF symbol visibilityH. Peter Anvin2018-06-181-0/+10
| | | | | | Add test for declaring ELF visibility. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* pragma: define a hander for generic output (and debug) pragmasH. Peter Anvin2018-06-181-3/+3
| | | | | | | | | There are cases where we may want to implement generic pragmas, while still make them selective based on output and/or debug formats. Initially, use this for the prefix/suffix options. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> Cc: Chang Seok Bae <chang.seok.bae@intel.com>
* test/Makefile: qualify the names of list files with output formatH. Peter Anvin2018-06-181-15/+15
| | | | | | | It is quite likely we may want to build the same input with multiple output formats; make it so we don't lose the list file. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Cleanup of label renaming infrastructure, add subsection supportH. Peter Anvin2018-06-011-3/+4
| | | | | | | | | | | | | | In order to support Mach-O better, add support for subsections, as used by Mach-O "subsections_via_symbols". We also want to add infrastructure to support this by downcalling to the backend to indicate if a new subsection is needed. Currently this supports a maximum of 2^14 subsections per section for Mach-O; this can be addressed by adding a level of indirection (or cleaning up the handling of sections so we have an actual data structure.) Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* test: add test for subsections via symbolsH. Peter Anvin2018-05-301-4/+2
| | | | | | Add a test for subsections via symbols. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* pragma.c: make the generic "output" and "debug" pragma namespaces workH. Peter Anvin2018-05-301-0/+39
| | | | | | | "output" and "debug" are supposed to redirect to the current output and debug formats. Fix it so it actually does. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Merge remote-tracking branch 'origin/nasm-2.13.xx'H. Peter Anvin2018-02-201-0/+56
|\ | | | | | | | | | | | | Resolved Conflicts: version Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * insns.dat: add aliases of the RET instruction with explicit operand sizeH. Peter Anvin2018-02-141-0/+56
| | | | | | | | | | | | | | Make it possible to generate variants of RET(F) with explicit operand size specified without having to use o16/o32/o64. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* | Merge tag 'nasm-2.13.03'H. Peter Anvin2018-02-071-0/+22
|\| | | | | | | | | | | | | | | | | | | | | NASM 2.13.03 Resolved Conflicts: include/iflag.h version x86/insns-iflags.ph Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * vaesenc.asm: add a few more test casesH. Peter Anvin2018-02-071-1/+17
| | | | | | | | Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * iflag: automatically assign values, saner handling of CPU levelsH. Peter Anvin2018-02-061-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Automatically assign values to the instruction flags; we ended up with a case where pushing flags into the next dword caused comparison failures due to other places in the code explicitly comparing field[3]. This creates necessary defines for this not to happen; it also cleans up a fair bit of the iflag code. This resolves BR 3392454. Reported-by: Thomasz Kantecki <tomasz.kantecki@intel.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* | Merge remote-tracking branch 'origin/nasm-2.13.xx'H. Peter Anvin2017-11-017-1/+66
|\| | | | | | | | | | | | | Resolved conflicts: version Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * BR 3392442: correct vmin in overflow_general()H. Peter Anvin2017-10-111-0/+6
| | | | | | | | | | | | | | | | The calculation of vmin in overflow_general() was bogus, causing silliness like ~80h being warned about in a byte context. Reported-by: C. Masloch <pushbx@38.de> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * BR 3392362: generate RMI versions of PEXTRW when possibleH. Peter Anvin2017-09-271-0/+3
| | | | | | | | | | | | | | | | | | We could generate the MRI version (SSE 4.1) instead of the RMI (SSE 2) version of these instructions if a 64-bit register was given as the destination. Reported-by: Vasiliy Olekhov <olekhov@gmail.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * test: add Makefile target for RDOFF filesH. Peter Anvin2017-09-271-1/+4
| | | | | | | | Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * BR 3392411: smartalign: make sure we always define the end symbolH. Peter Anvin2017-09-271-0/+22
| | | | | | | | | | | | | | | | | | We need to always define the end symbol, otherwise we might find ourselves in a situation where the alignment code grows (common!) and then the symbol is defined late. Reported-by: ig <glucksmann@avast.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * BR 3392437: Fix diagnostic for negative value in TIMESH. Peter Anvin2017-09-271-0/+3
| | | | | | | | | | | | | | Issue a diagnostic and don't panic for invalid TIMES values. Reported-by: C. Masloch <pushbx@38.de> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * BR 3392418: MachO: support 16-character section names, debug flagH. Peter Anvin2017-09-271-0/+3
| | | | | | | | | | | | | | | | Support 16-character section names, and support the debug section flag. Reported-by: Andrey Timofeyev <timofeyev@bk.ru> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * test: add test code for BR 3392439H. Peter Anvin2017-09-271-0/+25
| | | | | | | | | | | | Bug report BR 3392439 test code. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>