summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* NASM 2.14rc16nasm-2.14rc16Cyrill Gorcunov2018-10-151-1/+1
|
* doc: Update changesCyrill Gorcunov2018-10-141-0/+4
| | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* preproc: expand_smacro -- Fix nil dereference on error pathCyrill Gorcunov2018-10-141-1/+3
| | | | | | | | | When error happened earlier we might have a.mac already handled and set to nil. https://bugzilla.nasm.us/show_bug.cgi?id=3392508 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* eval: Eliminate division by zeroCyrill Gorcunov2018-10-141-1/+1
| | | | | | | | | | | | | When doing division we should detect if the value we're divided by is not zero. Instead of is_unknown() helper we should use is_just_unknown(). https://bugzilla.nasm.us/show_bug.cgi?id=3392515 https://bugzilla.nasm.us/show_bug.cgi?id=3392473 Reported-by: Jun <jxx13@psu.edu> Reported-by: stuartly <situlingyun@gmail.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* doc: Update changesCyrill Gorcunov2018-10-131-0/+2
| | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* opflags: Convert is_class and is_reg_class to helpersCyrill Gorcunov2018-10-131-2/+12
| | | | | | | | | | So we can test for out of bound access and make helpers safe to use. https://bugzilla.nasm.us/show_bug.cgi?id=3392447 Reported-by: Jun <jxx13@psu.edu> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* preproc: Fix out of range access in expand mmacroCyrill Gorcunov2018-10-131-0/+2
| | | | | | | | | | | | | | On specially crafetd malformed input file the params might be zapped (say due to invalid syntax) so we might access out of bound having nil dereference in best case. Note the later code in this helper uses tok_isnt_ helper which already has similar check. https://bugzilla.nasm.us/show_bug.cgi?id=3392518 Reported-by: Jordan Zebor <j.zebor@f5.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* doc: Update changesCyrill Gorcunov2018-10-131-0/+2
| | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* parser: Fix sigsegv on certain equ instruction parsingCyrill Gorcunov2018-10-131-0/+17
| | | | | | | | | | We should check for bounds when accessing nasm_reg_flags. Seems this bug was for long time already. https://bugzilla.nasm.us/show_bug.cgi?id=3392516 Reported-by: Jordan Zebor <j.zebor@f5.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* labels: Make sure nil label is never passedCyrill Gorcunov2018-10-131-0/+2
| | | | | | | | We already catched a case where we've missed test for non nil label and in result got sigsegv, lets rather panic next time. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* labels: Don't nil dereference if no label providedCyrill Gorcunov2018-10-131-7/+5
| | | | | | | | | | An equ without label may cause nil dereference | equ 0x100 Fixes 98578071b9d71ecaa2344dd9c185237c1765041e Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* macho: Add warning message in macho_output()Chang S. Bae2018-10-091-0/+3
| | | | | Based-on-code-from: zenith432 <zenith432@users.sourceforge.net> Signed-off-by: Chang S. Bae <changseok.bae@gmail.com>
* macho/reloc: Fix addr size sensitive conditionsChang S. Bae2018-10-091-1/+1
| | | | | | | TLVP relocation helps GOT that is 64-bit only. Based-on-code-from: zenith432 <zenith432@users.sourceforge.net> Signed-off-by: Chang S. Bae <changseok.bae@gmail.com>
* macho/reloc: Fix macho_output() to get the offset adjustments by add_reloc()Chang S. Bae2018-10-091-1/+4
| | | | | | | | | Unlike the relative relocations, OUT_ADDRESS had ignored the adjustments made by add_reloc(), and writes the offset of the target symbol in the target section. Based-on-code-from: zenith432 <zenith432@users.sourceforge.net> Signed-off-by: Chang S. Bae <changseok.bae@gmail.com>
* macho/reloc: Fixed offset adjustment in add_reloc()Chang S. Bae2018-10-091-6/+6
| | | | | | | | | | | If the target symbol is in the same file, add_reloc() emits an internal reloc for the target section, and the offset written is the offset in the target section. If the target symbol is external, its offset is zero (or an explicit addend), and add_reloc() emits an external reloc for the symbol. Based-on-code-from: zenith432 <zenith432@users.sourceforge.net> Signed-off-by: Chang S. Bae <changseok.bae@gmail.com>
* macho/reloc: Allow absolute relocation when forcing a symbol referenceChang S. Bae2018-10-091-4/+7
| | | | | | | | | The (fake) section for absolute symbols is not in the linked list. So, when the section is not found from the index, now it simply points to the special section. Based-on-code-from: zenith432 <zenith432@users.sourceforge.net> Signed-off-by: Chang S. Bae <changseok.bae@gmail.com>
* macho/reloc: Adjust SUB relocation informationChang S. Bae2018-10-091-2/+4
| | | | | | | | As SUB relocation getting deprecated, reset external reference seems to be enough. Also, print a warning message for this. Based-on-code-from: zenith432 <zenith432@users.sourceforge.net> Signed-off-by: Chang S. Bae <changseok.bae@gmail.com>
* macho/reloc: Fixed in handling GOT/GOTLOAD/TLV relocationsChang S. Bae2018-10-091-5/+9
| | | | | | | | | | | | - Changed to search all symbols, instead of only global symbols. - Will do immediate exits when unsupported use of WRT - Fixed to mark (got)pcrel flag only for macho64 output. GOT is supported only for 64-bit. Based-on-code-from: zenith432 <zenith432@users.sourceforge.net> Signed-off-by: Chang S. Bae <changseok.bae@gmail.com>
* macho/reloc: Simplified relocation for REL/BRANCHChang S. Bae2018-10-091-16/+2
| | | | | | | | | It seems like the relocation for the relative reference to absolute addresses only cares external reference info. Instead of exiting, reset the external reference flag. Based-on-code-from: zenith432 <zenith432@users.sourceforge.net> Signed-off-by: Chang S. Bae <changseok.bae@gmail.com>
* macho/sym: Record initial symbol number alwaysChang S. Bae2018-10-091-3/+3
| | | | | | | The special segment may need this information for future fix-ups. Based-on-code-from: zenith432 <zenith432@users.sourceforge.net> Signed-off-by: Chang S. Bae <changseok.bae@gmail.com>
* opflags: Style unificationCyrill Gorcunov2018-10-011-9/+9
| | | | | | No func change. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* preproc: parse_size -- Check for string providedCyrill Gorcunov2018-09-291-2/+1
| | | | | | | | In case if the string is nil we will have sigsegv. https://bugzilla.nasm.us/show_bug.cgi?id=3392507 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* pspdf.pl: GhostScript font integration seems broken with -dSAFERH. Peter Anvin2018-09-241-5/+25
| | | | | | | | | -dSAFER seems to break font integration on some systems. Furthermore, once given -dSAFER seems to not be possible to override, so instead of calling via the ps2pdf script, call GhostScript explicitly with the equivalent options, sans -dSAFER. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* doc: changes -- Add a few more bulletsCyrill Gorcunov2018-09-231-0/+6
| | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* Fix small typo in commentCyrill Gorcunov2018-09-221-2/+2
| | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* asm: Restore showing output for preproc mode in stdoutCyrill Gorcunov2018-09-221-3/+9
| | | | | | | | | Before the commit 81b62b9f54ac8e4019a9b2ec2b95ec0faa86bd2a we've been always putting -E,-e results into stdout if no output file provded. So bring this backward compatibility back. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* obj: Fix to initialize segment listChang S. Bae2018-09-151-4/+5
| | | | | | | | | | Recent labeling mechanism changes seem to bring the case, where segment() procedure is called when the segment list is empty. Now, it will simply check and initalize the segment list. Reported-by: Ozkan Sezer <sezeroz@gmail.com> Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* macho: Fix relocation type for relative direct branchChang S. Bae2018-08-241-0/+2
| | | | | | | | | | Previously, X86_64_RELOC_BRANCH is only set for external relocations. Internal relocation also needs this type to be set, instead of the default (X86_64_RELOC_SIGNED) or anything. Reported-by: <zenith432@users.sourceforge.net> Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* doc: Fix macho section name for codeChang S. Bae2018-08-241-1/+1
| | | | | | | | While today's manual lists "text" as the code section name, "code" has been effectively named from d1da074. Reported-by: <zenith432@users.sourceforge.net> Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* disasm: Fix buffer overread in ndisasmCyrill Gorcunov2018-08-163-7/+33
| | | | | | | https://nvd.nist.gov/vuln/detail/CVE-2018-10254 https://sourceforge.net/p/nasm/bugs/561/ Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* macho: Turn off jump-match optimization for subsections_via_symbolsChang S. Bae2018-08-161-0/+3
| | | | | | | | | | | | | | The jump-match optimization tends to remove labels. When the "subsections_via_symbols" pragma is declared, all the labels should be emitted. Disabling the optimization (only) makes the pragma effective. It might be cleaner to extend the OFMT interface to support callback function. In this case, the reconfiguration can be done through the callback interface, rather than direct access to the global variable. Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* optimization: Introduce new flag to turn-off selectivelyChang S. Bae2018-08-165-18/+35
| | | | | | | | | | | | While configuring optimization in a level is conventional, a certain optimization tends to conflict with some pragma. For example, jump match conflicts with Mach-O's "subsections-via-symbols" macro. This configurability will workaround such conflicts. Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* NASM 2.14rc15nasm-2.14rc15H. Peter Anvin2018-07-061-1/+1
|