Legacy backends like obj/omf may depend on the offset being zero if
not in use.
Reported-by: Bernd Boeckmann <bernd-freedos@boeckmann.io>
Reported-by: Vladimir Chebotarev <vladimir.chebotarev@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
When converting an OUT_SEGMENT relocation to legacy, the addend is
still significant, as it would represent an explicit addend to the
segment number.
Fixes: https://bugzilla.nasm.us/show_bug.cgi?id=3392783
Reported-by: David Fifield <david@bamsoftware.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
RDOFF has been deprecated as it has unfixable problems, and has been
announced that it will be killed off in NASM 2.16.
This deletes it once and for all.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
There are no use cases for of RELA on i386, and the intent has always been
that efmt->rel_size would be the size of the desired relocation
section type. Rename it from rel_size to relsize to make it more
obvious that it matches efmt->reltype rather than SHT_REL, and delete
efmt->rela_size to keep it from being misused again.
This should avoid a repeat of:
https://bugzilla.nasm.us/show_bug.cgi?id=3392807
fixed in adf7507e29.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
i386 should use REL relocation in DWARF sections with addend stored at
the relocation offset. This fixes
https://bugzilla.nasm.us/show_bug.cgi?id=3392807
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
I'm dealing with a FreeBSD-derived embedded target that ends up
showing such symbols (which is mainly NASM struct definitions)
in backtraces after calling NULL function pointers, since these
symbols _are_ technically covering bytes around address zero.
Needless to say, this is extremely confusing and generates
nonsensical bug reports. (Essentially, random unrelated crashes
get cross-referenced to a random ASM struct, whatever the linker
picked for address 0).
These symbols are already a bit strange to begin with (they're
purely an artifact of how NASM happens to implement structs),
leaving their sizes at 0 seems reasonable.
Signed-off-by: Fabian Giesen <fabian.giesen@epicgames.com>
Before this patch, COFF output always contained the first 18 bytes of the
input filename. This breaks reproducibility and may also leak sensitive
data to objects (esp. with input filenames with absolute paths.)
This patch makes this output respect the --reproducible option, and omits
the input filename from the COFF output, when set.
Usage was removed in b6ba0a23f9
Fixes:
output/outcoff.c:302:28: warning: unused function 'coff_alignment' [-Wunused-function]
static inline unsigned int coff_alignment(uint32_t flags)
^
This commit adds the compilation directory debug information for ELF files.
This feature helps debuggers locate the source file when debugging.
The feature is already present for Mach-O files.
Signed-off-by: Marco Vanotti <mvanotti@dc.uba.ar>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
In case if section follows itself we should yield
an error, otherwise we hit nil dereference because
there won't be any group of sections.
After all "follow" attribute is rather to group
sections other than self.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
In 78f14ab1a6 the fix
is incomplete, we should move free procedure out of
the list_for_each traverse.
CID 1432930
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
If new list is not needed then we should free memory
allocated by nasm_basename and nasm_dirname calls.
CID 1432930
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
We need the ability to produce consistent output for our own tests,
anyway, so make this a user-accessible feature. This was requested in
BR 3392635.
This obsoletes the NASM_TEST_RUN environment variable; simply use the
normal NASMENV environment variable instead.
The .obj tests in travis needed to be updated in order to remove the
rather pointless suffix " CONST" from the NASM signatures.
Reported-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
NASM 2.15.04
Conflicts:
asm/listing.h
asm/pptok.pl
asm/preproc.c
version
This doesn't pass travis test 3392711, which is using an extremely odd
construct of %?? in the middle of an argument sequence for an smacro
while not being in a macro itself, and expecting it to expand to the
macro name. This seems to *really* confuse the master branch.
Resolve this later...
At least DWARF can encode C-style macros. In doing so, it wants the
file include hierarchy, so give the debug format backend the option of
receiving that information from the preprocessor.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Just stub out "org" as a macro to be able to read source files that
are designed for the .bin format.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
When we're running tests we must not fail due to
time stamp difference in a header. Lets zap it if
test run is detected.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
I believe "truncating" is the more common terminology in this case, so
change to it for aestetic reasons only.
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The case where we warn for excessive length should presumably have
been %.nnns which means limit length to nnn characters, rather than
%nnns which means left-pad with spaces to nnn bytes if possible. Also
change the limit from 128 to 64, to make it more likely to not line
break.
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
When we encode a name we put its length before it, the
storage is one byte width so the name can't be more
than UINT8_MAX (ie 255) bytes length.
Moreover if one provide a name more than RECORD_MAX then
we simply overwrite random memory.
Thus lets do as in other obj_check calls -- shrink the
size we gonna use. But unlike oter code lets yield a
warning as well.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
The RDOFF backend has been broken since at least NASM 2.14, throwing
an immediate assert. Since only one person appears to have even
noticed, and fixing it properly looks like it would take quite a bit
of work, disable this back end and document its deprecation.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Add a new macro vprintf_func() for vprintf-style functions, and add
printf_func() and vprintf_func() attribute arguments whereever
meaningful.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Using list_for_each() is by definition not safe when freeing the
members of the list, use list_for_each_free() instead.
Also, use nasm_new() and nasm_free() where appropriate.
This was discovered as a downstream bug from BR 3392707.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
It seems that the odd alignment-padding code was simply dead in older
versions of NASM. This means that the COFF backend behavior really was
the same as the other backends. Remove that stale code and revert to
previous/common behavior.
Reported-by: ig <glucksmann@avast.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
If the section/segment directive *only* contained an align= directive,
it would get lost. Fix that.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
ERR_PASS1 only remains in three places:
a. Unterminated %! string, an error
- Should be signalled no matter which pass it is encountered in
b. Two cases of map file problems in outbin
- The buffered warning system take care of that issue
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed and unsigned are really two flags; might as well allow this
field to contain additional flags.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Collect macro call/nesting information for the benefit of the debug
back end. So far, the only backend for which this is provided is the
debug back end, to show what information is present.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
NASM would incorrectly only allow for the alignment to be increased,
even when overridden by the user. Allow the user to specify any
alignment value and have it override the partition type default.
The user can increade their own alignment value specification later,
of course, and the sectalign directive will present a floor for either
kind of specification.
Reported-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
recursion: see recursion.
A wrapper function needs to call the function being wrapped, not
itself.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>