aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* preproc: add %i... variants, evaluated macro parameters, cleanupsevalmacroH. Peter Anvin2019-02-266-242/+405
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: the .note section should be 4-byte alignedH. Peter Anvin2019-02-262-2/+2
| | | | | | | The ELF .note section contains of 4-byte words and should be aligned accordingly. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Handle more ELF section typesH. Peter Anvin2019-02-264-125/+195
| | | | | | | note, preinit_array, init_array, and fini_array are ELF section types that can matter to the assembly programmer. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* ELF: handle more than 32,633 sectionsH. Peter Anvin2019-02-268-553/+570
| | | | | | | | | | | | | | | | | | | 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>
* SAA: allow seeking beyond the end of the arrayH. Peter Anvin2019-02-251-4/+10
| | | | | | | If putting the file pointer past the end of the array, expand the array with zeroes. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* configure.ac: add --enable-profiling optionH. Peter Anvin2019-02-251-0/+5
| | | | | | Add option to enable profiling without having to modify Makefile. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* outelf: hash sections for performanceH. Peter Anvin2019-01-123-28/+56
| | | | | | | | 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>
* NASM 2.14.03rc2nasm-2.14.03rc2H. Peter Anvin2018-12-301-1/+1
|
* ELF: add support for the ELF "merge" attributeH. Peter Anvin2018-12-304-34/+142
| | | | | | | | | | | | | Add support for the "merge" attribute in ELF, along with the associated "strings" and size specifier attributes. Fix a few places where we used "int", but a larger type really ought to have been used. Be a bit more lax about respecifying attributes. For example, align= can be respecified; the highest resulting value is used. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* NASM 2.14.03rc1nasm-2.14.03rc1H. Peter Anvin2018-12-271-1/+1
|
* changes.src: document suppressed messagesH. Peter Anvin2018-12-271-0/+5
| | | | | | Document the suppression of error messages from "label changed". Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* BR 3392539: some errors can "cascade". Allow suppressing if dead.H. Peter Anvin2018-12-273-2/+8
| | | | | | | | | | | | | | | | | | | | In BR 3392539, the error: helloW.s:18: error: label `rurt' changed during code generation [-w+error=label-redef-late] ... occurs a number of times after we have already issued an error. This is because the erroring instruction computes to a different size during code generation; this causes each subsequent label to cause a phase error. The phase error simply doesn't make much sense to report: if we are already committed to erroring out, it is more likely an error cascade rather than an error in its own right, so just suppress it in that case. Reported-by: <russvz@comcast.net> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* NASM 2.14.02nasm-2.14.02Cyrill Gorcunov2018-12-261-1/+1
|
* changes.src: document fix for listing module crashH. Peter Anvin2018-12-261-0/+5
| | | | Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* listing: list_emit -- Don't forget to zap listerr_headCyrill Gorcunov2018-12-251-0/+1
| | | | | | | | | | | | In list_emit we walk over listerr_head freeing the list, but the head pointer remain carrying old value. Need to clean it up once traverse is done to not access already freed memory later. https://bugzilla.nasm.us/show_bug.cgi?id=3392538 Reported-by: russvz@comcast.net Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.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>
* 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>