Commit message (Collapse)AuthorAgeFilesLines
* NASM 2.14.01nasm-2.14.01H. Peter Anvin2018-12-221-1/+1
* insns.dat: accept explicit ax/eax/rax operand to CLZEROH. Peter Anvin2018-12-222-0/+29
| | | | | | | | | 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>
* NASM 2.14.01rc5nasm-2.14.01rc5H. Peter Anvin (Intel)2018-12-141-1/+1
* Document the -Ov option, minor fix for gcc -OgH. Peter Anvin (Intel)2018-12-142-2/+9
| | | | | | | | | The -Ov option is useful but was undocumented. Add an initialization to keep gcc from complaining at optimization level -Og. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* labels.c: redefine test should be passn, not pass0H. Peter Anvin (Intel)2018-12-141-4/+5
| | | | | | Stupid thinko: lpass should be passn + 1, not pass0 + 1. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* --no-line: new option to ignore %line directivesH. Peter Anvin (Intel)2018-12-146-22/+40
| | | | | | | For debugging preprocessed code, it is useful to be able to ignore %line directives rather than having to filter them out externally. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* errors: correct message saying -w+error= ... is in use when it is notH. Peter Anvin (Intel)2018-12-131-1/+1
| | | | | | Correct the test for when -w+error= is the correct thing to print. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* NASM 2.14.01rc4nasm-2.14.01rc4H. Peter Anvin (Intel)2018-12-131-1/+1
* errfile.c: add file missing from previous checkinH. Peter Anvin (Intel)2018-12-131-0/+5
| | | | | | File was missing from checkin Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* malloc: handle potential infinite loop in nasm_alloc_failed()H. Peter Anvin (Intel)2018-12-137-10/+28
| | | | | | | | | It is possible on memory exhaustion that nasm_fatal() might cause another allocation error, thus calling nasm_alloc_failed() again. If we find us in nasm_alloc_failed() for a second time, try to get a message out and then call abort(). Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* NASM 2.14.01rc3nasm-2.14.01rc3H. Peter Anvin (Intel)2018-12-121-1/+1
* error: new flag ERR_HEREH. Peter Anvin2018-12-126-71/+87
| | | | | | | | | | | ERR_HERE is used to mark messages of the form "... here" so that we can emit sane output to the list file with filename and line number, instead of a nonsensical "here" which could point almost anywhere. This patch contains some changes from the one in the master branch to make the code cleaner. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* errors: unify nasm_verror_{gnu,vc} and remove some ERR_NOFILEH. Peter Anvin2018-12-121-101/+47
| | | | | | | | The differences between nasm_verror_{gnu,vc} are a short handful of strings, so unify them. Remove some additional ERR_NOFILE that are not necessary. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* error: remove unused ERR_TOPFILEH. Peter Anvin2018-12-122-3/+4
| | | | | | The flag ERR_TOPFILE was not used anywhere, remove it. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* BR 3392535: warning on redefine, promote define-on-pass2 to errorH. Peter Anvin (Intel)2018-12-123-26/+37
| | | | | | | | | | If we redefine consistently, make it a suppressed-by-default warning. If we end up doing the define on pass 2, promote that to a default-error warning; using a default-error warning allows the user to demote it should they so wish. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Requested-by: C. Masloch <pushbx@38.de>
* listing.c: handle multiple error messages on a single lineH. Peter Anvin (Intel)2018-12-121-26/+49
| | | | | | | We may produce an arbitrary number of error messages on a single line; include all of them in the list file. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* warnings: WARN_OTHER is now "above", not "below"H. Peter Anvin (Intel)2018-12-121-1/+1
| | | | Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* warnings: make it possible for a warning to default to an errorH. Peter Anvin (Intel)2018-12-123-37/+39
| | | | | | | | This allows us to do soft-migration of warnings to errors; they will now be nonfatal errors by default, but gives the user the option to demote them. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* warnings; move WARN_OTHER to the end; allow non-warnings to be suppressedH. Peter Anvin (Intel)2018-12-123-92/+102
| | | | | | | | | | | | | | | | | | | | Putting WARN_OTHER at the end of the list creates a number of advantages and simplifications: 1. It is more user friendly! It is far more of a logical location for the default case to be at the end of the printed list. 2. The value 0 can be used in a number of places to indicate a non-suppressible event. By having warning_state[0] always contain WARN_ST_ENABLED, we can always do the table lookup, even. 3. It means non-warnings (except fatal/panic) can now be conditioned on warning states. In those cases, WARN_*, including WARN_OTHER, can be added to the mask for any category. This is especially useful for notes. The only downside is that we have to explicitly detect the case where we have ERR_WARNING but no WARN_ flag. This is a trivial test. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* configure: add -Wno-shift-negative-valueH. Peter Anvin (Intel)2018-12-121-0/+5
| | | | | | | | | | Shifting negative values is undefined in standard C, but we have tons of dependencies that signed arithmetic is 2's-complement in the code anyway, and on gcc-like compilers we pass the -fwrapv option to indicate exactly that. Therefore, this is not a valid warning in our case and should be suppressed. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* warnings: rename ERR_WARN_* to WARN_*H. Peter Anvin (Intel)2018-12-1213-74/+74
| | | | | | | | The prefix ERR_WARN_ is unnecessarily long and may be a disincentive to create new warning categories. Change it to WARN_*, it is still plenty distinctive. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* errors: add ERR_NOTE and a default clause to error dispositionnasm-2.14.01rc2H. Peter Anvin2018-12-101-0/+3
| | | | | | | ERR_NOTE has no action. Have a default clause as well, for good measure. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* NASM 2.14.01rc2H. Peter Anvin2018-12-101-1/+1
* changes.src: update list of changes since 2.14H. Peter Anvin2018-12-101-0/+6
* BR 3392534: error out on an inconsistently redefined labelH. Peter Anvin2018-12-101-18/+59
| | | | | | | | | | | | If a label is redefined in the same pass, and the value is inconsistent, then error out. While we are at it, give the source location of the previous definition. This explicitly rejects BR 3392535; there seems to be no reason to reject duplicate definitions with the same value, as there is no inconsistency involved. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* error: add new severity level "note"H. Peter Anvin2018-12-102-4/+8
| | | | | | | Add a new severity level "note", intended to be used to give additional information about a previous error. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* nasm: clean up error messages somewhatH. Peter Anvin2018-12-101-7/+14
| | | | | | | | If warnings are errors, print [-w+error=xxxx] and prefix error:. Use the same spacing for filename and non-filename error messages. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* nasm: fix the combination -E -MD, handle -MD without a filenameH. Peter Anvin2018-11-283-10/+34
| | | | | | | | -E -MD should work and output a dependency file. -MD can be used without a filename; there is a default filename or -\c{-MF} can be used. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* changes.src: fp bug: there are probably other corner casesH. Peter Anvin2018-11-281-4/+3
| | | | | | | | There are probably other corner cases where we could at the very least produce an incorrectly rounded result, so be a bit more cagey about the description of the bug. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* NASM 2.14.01rc1nasm-2.14.01rc1H. Peter Anvin2018-11-261-1/+1
* BR 3392368: actually fix the documentation; add test caseH. Peter Anvin2018-11-262-10/+29
| | | | | | 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-262-6/+13
| | | | Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* changes.src: document more fixesH. Peter Anvin2018-11-261-0/+9
| | | | Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* BR 3392368: correct handling of exact limb switchH. Peter Anvin2018-11-261-4/+5
| | | | | | | | | | | | | | | | | | When we have an exact limb switch, we may end up with a case where the value no longer has any remaining valid bits. In that case, we end up relying on the expression *mp |= v << ms shifting the bits on the subsequent limb all the way to zero, but that is not how real hardware works when the shift count equals the width of the type. This is undefined behavior and does, in fact, produce the wrong result. Instead, change the test for limb shift to (ms < 0), meaning that we defer the advance to the next limb until we actually need it. At that point, change the shift into the *old* limb to have a cast to (fp_2limb) which means the shift right of LIMB_BITS is valid and produces a zero value as expected. Reported-by: Brooks Moses <bmoses@google.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* BR 3392529: remove excess printf() argumentH. Peter Anvin2018-11-261-1/+1
| | | | | | | The input file is provided by nasm_error(), we should not include it in the printf list (compiler warning + wrong message.) Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* BR 3392532: outobj: fix forward references to the SEG of external symbolsH. Peter Anvin2018-11-261-2/+2
| | | | | | | | | | | | | External symbols are defined via deflabel(), but deflabel() is not called until pass0 == 1. Until that happens, segbase has no way to know what the proper segment base of the segment actually is. Thus, testing for pass0 == 0 will always fail for a forward reference; correct the test to test for pass0 < 2, i.e. the assert should fail only for the final code-generation pass. Reported-by: <stsp@list.ru> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Fix undefined behavior when shifting left by 32 bitsMichael Bradshaw2018-11-231-1/+1
| | | | | | | See https://bugzilla.nasm.us/show_bug.cgi?id=3392368 Signed-off-by: Michael Bradshaw <mjbshaw@google.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* BR 3392529: if the default output name is the same as input -> nasm.outH. Peter Anvin (Intel)2018-11-201-3/+8
| | | | | | | | If no output filename is specified, then a default filename is used based on the input filename. If that ends up the *same* as the input filename, change the output filename to "nasm.out". Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* preproc: command-line preproc directive after system-generatedH. Peter Anvin2018-11-113-39/+84
| | | | | | | | | | | | | | | | | | BR 3392527: make sure that all command-line specified preprocessing directives are processed after the system-generated ones. In particular __OUTPUT_FORMAT__ was generated after command line pass 2, at which point -p, -d, -u, --pragma and --before had already been processed. There is no reason to split up defined_macros() anymore: the right place to execute it is simply between command line passes 1 and 2. We can also set dfmt here, which lets us define a __DEBUG_FORMAT__ macro as well. Finally move some options that have no business being processed in pass 2 to pass 1. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* NASM 2.14nasm-2.14H. Peter Anvin (Intel)2018-11-071-1/+1
* nasmdoc.src: fix compound wordH. Peter Anvin (Intel)2018-11-071-2/+2
* doc: Add a description for a useful case of mangling symbolsChang S. Bae2018-10-301-3/+15
| | | | Signed-off-by: Chang S. Bae <changseok.bae@gmail.com>
* preproc: Don't access out of bound data on malformed inputCyrill Gorcunov2018-10-291-2/+3
| | | | | | | | | | | | There are a number of places still where we test text data which is potentially may be an empty string. This is known to happen on fuzzer input but usually doesn't take place in regular valid programs. Surely we need to revisit preprocessor code for this kind of errors. https://bugzilla.nasm.us/show_bug.cgi?id=3392525 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* rdstrnum: Make sure we dont shift out of boundCyrill Gorcunov2018-10-291-1/+3
| | | | | | | | Otherwise we may hit underfined behavior. https://bugzilla.nasm.us/show_bug.cgi?id=3392526 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* preproc: Fix out of bound access on malformed inputCyrill Gorcunov2018-10-281-1/+1
| | | | | | | | | A fuzzer revealed a problem in preproc code. https://bugzilla.nasm.us/show_bug.cgi?id=3392521 Reported-by: ganshuitao <ganshuitao@gmail.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* doc: Clarify %include search directory semanticsCyrill Gorcunov2018-10-262-11/+7
| | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* doc: Update changesCyrill Gorcunov2018-10-211-0/+2
| | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* preproc: Make the preprocessor use nasm_catfile for includenight199uk2018-10-191-9/+7
| | | | | | | | | | | All include paths to nasm must already have a trailing separator prefix which is uncommon among tools. Change to using nasm_catfile which gives a more normal behaviour. https://bugzilla.nasm.us/show_bug.cgi?id=3392205 Signed-off-by: night199uk <night199uk@hermitcrabslab.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* path: nasm_catfile -- Fix incorrect return of filename onlynight199uk2018-10-191-6/+6
| | | | | | | | | nasm_catfile returns an incorrect (already incremented) pointer. https://bugzilla.nasm.us/show_bug.cgi?id=3392205 Signed-off-by: night199uk <night199uk@hermitcrabslab.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>