Travis CI testing with AddressSanitizer (ASan) triggered a severe memory
leak in the assembler label tracking. Local label structures were not
properly freed during cleanup stages. This fix adds proper verification
and destruction of tracking labels, resolving the ASan memory leak.
Signed-off-by: alexvoste <alexvostedev@proton.me>
[ hpa: fixed indentation style and removed unnecessary { } ]
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The parser incorrectly treated colons as memory segment overrides inside
EQU directives because of an inverted far_jmp_ok check. This regression
was introduced in commit 8981724. Removing the incorrect negation
restores proper parsing of FAR pointer constants.
Fixes#242
Signed-off-by: alexvoste <alexvostedev@proton.me>
When complaining about a valid token where an identifier was expected,
do include the leading $ if at all applicable to avoid confusing the
user.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
For identifier-escapes beginning with $a-f to work, the $ hexadecimal
prefix cannot be used, nor could it ever be used, with A-F immediately
after the $. This is the main reason the $-hex has been deprecated.
When adding the non-dollarhex mode, this got accidentally promoted to
nasm_isnumchar() instead of nasm_isnumstart(), which broke using
$-escaped identifiers in directives.
To fix this properly, it would be a good thing to add a central
identifier-skipping function.
Fixes: https://github.com/netwide-assembler/nasm/issues/223
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This script can output more than just Emacs format these days; it is
already used to produce both Emacs and JSON output, and it seems
unlikely that we would want to create another script to output any
additional file formats.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Instead of sorting the list of flags by number, it sorted it by hash.
Reported-by: <bbhtt@bbhtt.in>
Fixes: https://github.com/netwide-assembler/nasm/issues/220
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The sequence EXTERN, GLOBAL, definition would fail, because the EXTERN
would create a pseudo-segment and consider it a definition, whereas
GLOBAL would set change it to a global definition, but leaving the
definition existing, which is not the normal case for a GLOBAL symbol
(define_label would not be called.)
Therefore, explicitly "undefine" the symbol by setting defn.defined to
0, as it would be after a GLOBAL statement, as as it is when an EXTERN
statement is followed by a definition (causing it to be implicitly
promoted to GLOBAL.)
Reported-by: E. C. Masloch <ecm-pushbx@github.com>
Reported-by: <roel-z@github.com>
Fixes: https://github.com/netwide-assembler/nasm/issues/224
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The %clear loop was missing advancing to the next token. Also allow
the list to be comma-separated, like most other cases in NASM.
Reported-by: <magicelk235@gmail.com>
Fixes: https://github.com/netwide-assembler/nasm/issues/227
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Unfortunately, the %rmacro and %irmacro directives were not disabled
when recursive macros were removed due to the implementation did not
work. Make them issue a warning and document that they might change in
the future.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
For the longest time, NASM has allowed non-ASCII characters is macros
and identifiers, but they have always been treated as opaque
bytes.
NASM has never done case insensitive matching of identifiers, only
keywords and macros. Keywords are compile-time-defined and are always
ASCII, but macros can be user-defined, so document the limitations.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
It has not been considered valid to omit the long patch description
for a long time. Try to explain in more detail what the long patch
description is actually expected to contain.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Bernd Böcknann has been maintaining a fork of this tool on github:
https://github.com/boeckmann/omfdump
Sync with his latest version. In the future it might be possible to
drop this tool from the NASM distribution entirely.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This reverts commit 35ffac3ea0.
This commit caused a regression, causing segment overrides to get
lost. Multiple travis tests failed as a result.
Revert this until a proper solution exists.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
For `VCVTUSI2SD`, `VCVTUSI2SS`, and `VCVTUSI2SH`, the `|er` flag in
`insns.dat` was attached to the XMM pass-through source (operand 2, the
vvvv field) rather than the integer source (operand 3, the rm field).
This caused NASM to require the embedded-rounding decorator before the
integer register rather than after it, which is wrong; the correct
syntax is `vcvtusi2ss xmm0,xmm1,eax,{rn-sae}`, not `vcvtusi2ss
xmm0,xmm1,{rn-sae},eax`.
Move `|er` to the integer source operand for all six affected entries,
and change the XMM source from `xmmreg|er` to `xmmreg*` (optional
duplicate of the destination, consistent with every other scalar
integer-to-float convert in the file).
Also fix a copy-paste error in `insns.dat` where the second `VCVTUSI2SH`
entry (W=1, rm64) was mis-labeled as `VCVTUSI2SS`.
Update `travis/test/avx512f.asm` to use the correct decorator syntax
(`reg,{rN-sae}` instead of `{rN-sae},reg`) for the ER forms of
`VCVTSI2SD`, `VCVTSI2SS`, `VCVTUSI2SD`, and `VCVTUSI2SS`; regenerate the
golden `avx512f.bin.t`. The encoded bytes are unchanged.
`travis/test/avx512f.json` had a trailing comma after the last field of
the JSON object, making it invalid JSON. Remove the trailing comma.
Signed-off-by: Joe Konno <joe.konno@intel.com>
Fixes: https://github.com/netwide-assembler/nasm/pull/229
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Current Codeview implementation assumes there is only one actual code
section and all line number information is pulled there. With support
of comdat that assumption becomes incorrect, so proper generation of
line number information table per code section is required.
Also solved an issue with incorrect relocation for symbol with the
same name as some section.
New code assumes that coff_nsects doesn't change during generation of
debug information.
Fixes: https://github.com/netwide-assembler/nasm/pull/183
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Documented the 'function' win32/64 extension to the global, extern
and static directives.
Resolved Conflicts:
doc/outfmt.src
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Added a special symbol ..symtab for emitting the COFF symbol table
index of a symbol rather than some kind of address. For use with ehcont
metadata and possible other stuff.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Rename this script to reflect its function within the NASM tree. The
output file is still called nasmtok.el, however, as it reflects its
function within an Emacs environment.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The definition of nasm-token-lists was double quoted: both the list
itself and the tokens inside were quoted, which is not the right
thing.
Remove the unnecessary inner quoting.
Reported-by: 8dcc <8dcc@github.com>
Fixes: https://github.com/netwide-assembler/nasm/issues/231
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
These use a 16-bit tuple type, not one derived from EVEX.W. All of
this is really messy... it would be better to have a much more
explicit handling of the displacement type than relying on "tuples".
Reported by: MSander-OptiCode <msander-opticode@gmail.com>
Fixes: https://github.com/netwide-assembler/nasm/issues/245
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Converting nroff man pages to other formats was obsoleted with the use
of asciidoc. No need to check for them.
Reported-by: Ross Burton <rossburton@github.com>
Fixes: https://github.com/netwide-assembler/nasm/issues/236
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The parser incorrectly treated colons as memory segment overrides inside
EQU directives because of an inverted far_jmp_ok check. This regression
was introduced in commit 8981724. Removing the incorrect negation restores
proper parsing of FAR pointer constants.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This change has no effect on NASM, but syncs with the upstream
collection. RANLIB should be defaulting to : if not present.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The -g3 and -ggdb options are really separate, treat them as
such. Trying -ggdb3 -g3 is not only inefficient, it is wrong when the
compiler supports only -ggdb.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
In elf_init, cur_path is a malloced one, and should be freed.
This patch adds a free operation by the end of the elf_init.
Signed-off-by: Yongjie Sheng (Intel) <sheng.yongjie@outlook.com>
When there is an ill formed assembly (e.g. a macro without a correct
ending), the assembly processing will end with a defining->refcnt
in non-zero value that further causes a nasm_assert in free_mmacro,
the nasm_assert causes a panic.
Force the defining->refcnt to zero in pp_clean_pass as a bailout.
Signed-off-by: Yongjie Sheng (Intel) <sheng.yongjie@outlook.com>
When there is an invalid radix specifier, the parse_smacro_template
set the current char pointer (cp) to NULL, but the tailing processing
of the for loop increases the cp so its value is 0x1 that deceives
the for loop condition check.
Add a NULL pointer checking on the cp after the switch statement
to quit the for loop because of the invalid radix specifier.
Signed-off-by: Yongjie Sheng (Intel) <sheng.yongjie@outlook.com>
A comment accidentally was left with a merge resolution
annotation. This was of course harmless, being in a comment, but it
shouldn't be there.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
ppscan() had a break; statement followed immediately by a return
statement. The latter was left over from code restructuring and is
dead code.
Remove it.
Fix a nearby comment indicating that we should not need to strip a
const from a string pointer. Probably Token::t_charptr should be
const, but it might need additional work.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>