If we get an output type we don't know how to handle, do a panic()
rather than a compile-time error; this will be necessary in the short
time pending a change to the backend interface.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
The constant arrays in get_disp8N() should be static; otherwise the
compiler has to manifest them on the stack for every execution which
makes no sense at all.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
stabs is the default debug format and GNU gold dies with an assertion
failure when it encounters a SHT_REL section in an x64 ELF file.
Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
df_dwarf and df_stabs were orphans of the elf32/64 merge; clean up.
Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Improve consistency by allowing contracted forms for EVEX-encoded
instructions when it's allowed for similar VEX-encoded instructions.
Previously the behavior would change depending on the vector size or
the register number which could be somewhat confusing:
vaddps xmm0, xmm1 ; ok
vaddps ymm0, ymm1 ; ok
vaddps zmm0, zmm1 ; error
vaddps xmm0, xmm16 ; error
Also allow contracted forms for a few additional older AVX instructions
where it makes sense.
Signed-off-by: Henrik Gramner <henrik@gramner.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Consistently identify dependencies by their path, not by their
basename. This avoids missing indirect dependencies. Furthermore, we
cannot start scanning files until we know the paths of all potential
targets.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Disable common data to:
a) discover problems with common data as quickly as possible (we
should not use common data as some compilers may not handle it);
b) work around a problem with the OSX linker causing it to not find
zero_buffer even though it is defined in nasmlib/zerobuf.c.
Reported-by: anonymous coward <nasm64developer@users.sf.net>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
write_symbolinfo_properties didn't match the S_COMPILE2 record it's
supposed to be writing (the "compiler version" string was emitted
starting in the final "version" field); fix that.
Write version 8.0.50727; the Windows App Certification Kit (WACK)
checks compiler versions as given in app debug info and complains
when the toolchain is too old. 8.0.50727 is the lowest permitted
"MASM" version for WACK to be happy, so that's what we write.
Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
On host platforms where $(LN_S) is cp, need to make sure to
link rdf2bin first.
Backport of 6d67dbfa95
Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
write_symbolinfo_properties didn't match the S_COMPILE2 record it's
supposed to be writing (the "compiler version" string was emitted
starting in the final "version" field); fix that.
Write version 8.0.50727; the Windows App Certification Kit (WACK)
checks compiler versions as given in app debug info and complains
when the toolchain is too old. 8.0.50727 is the lowest permitted
"MASM" version for WACK to be happy, so that's what we write.
Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
On host platforms where $(LN_S) is cp, need to make sure to
link rdf2bin first.
Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
When symbols are created turing non-first pass we
should at least warn a user since it's a sign of
potential problem.
http://bugzilla.nasm.us/show_bug.cgi?id=3392358
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
In rdoff/rdoff.c, the function declaration for newmembuf is written:
static memorybuf *newmembuf()
The attached diff adds an explicit void parameter.
It seems like it would be nicer with an explicit void parameter
especially since the -Werror build options seem to want to find such
things.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
It is not just DJGPP which has broken header files if __STRICT_ANSI__
is defined. Cygwin has also been confirmed to have problems. It
would be somewhat different if configure didn't still detect those
functions.
Undefine __STRICT_ANSI__ for all gcc platforms. If this breaks then,
well, we'll have to really narrow down the problems.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
The ordering of the macro sets ended up changing due to the recent
file reorganization. Instead of forcing the order again, handle
multiple macro sets (rather than just two) in a coherent manner.
macros/macros.pl could use a cleanup of duplicated code, however.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
In case if there is no environment variable present
we allocated empty string but when working with tokens
we test for second byte for special symbols, accessing
out of memory address (->text[1] for the reference).
http://bugzilla.nasm.us/show_bug.cgi?id=3392333
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
The codeview backend needs to be able to open each source file passed in
so that it can calculate its checksum. In order to take into account
include paths, this patch updates the filename to include the path where
the file was found.
Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
[ hpa: resolved one conflict in preproc.c ]
This unbreaks checkin 84f6860ed5, which
was broken due to a transcription error of mine. Zenith432 was
faultless in this case.
This fixes bug report 3392355.
Reported-by: Zenith432 <zenith432@users.sourceforge.net>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
For 16-bit and 32-bit x86 code, the size and realsize() always
matches as only jumps, calls and loops uses PC relative
addressing and the address isn't followed by any other opcode
bytes. In 64-bit mode there is RIP relative addressing which
means the fixup location can be followed by an immediate value,
meaning that size > realsize().
When the CPU is calculating the effective address, it takes the
RIP at the end of the instruction and adds the fixed up relative
address value to it.
The linker's point of reference is the end of the fixup location
(which is the end of the instruction for Jcc, CALL, LOOP[cc]).
It is calculating distance between the target symbol and the end
of the fixup location, and add this to the displacement value we
are calculating here and storing at the fixup location.
To get the right effect, we need to _reduce_ the displacement
value by the number of bytes following the fixup.
Example:
data at address 0x100; REL4ADR at 0x050, 4 byte immediate,
end of fixup at 0x054, end of instruction at 0x058.
=> size = 8.
=> realsize() -> 4
=> CPU needs a value of: 0x100 - 0x058 = 0x0a8
=> linker/loader will add: 0x100 - 0x054 = 0x0ac
=> We must add an addend of -4.
=> realsize() - size = -4.
The code used to do size - realsize() at least since v0.90,
probably because it wasn't needed...
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Make the source code easier to understand and keep track of by
organizing it into subdirectories depending on the function.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
nasmlib.c had basically turned into a garbage bin of various functions
with very little in common. Break it up into logical components for
isolation and manageability.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Add wrappers to fopen(). The intent is to replace references to
FILE * with an internal structure which can also cache things like the
filename and, when needed, the full pathname and checksums.
Also, add the "m" flag if we are compiling for glibc, for speed.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Tell gcc that our allocation functions are, indeed, allocation
functions, and that they don't ever return NULL.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Concatenating the cwd with the name of the output file is incorrect
for filenames which are specified as absolute. We already have
nasm_realpath() for this purpose, use it.
Cc: Jim Kukunas <james.t.kukunas@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
There is no reason why the warning-generating ilog2 has to be only the
floor variant. However, I am pretty sure we can simply implement the
ilog2cw() as a macro only; we can always fix that if that turns out to
be incorrect.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Instead of walking a linear list of files for every line, make a
simple comparison for the common case of the same file, and otherwise
use a hash table.
Cc: Jim Kukunas <james.t.kukunas@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Output the kerning tables in the metrics headers. This will hopefully
make it possible to support kerning later (e.g. using the PostScript kshow
operator with some kind of kerning function.)
Note: the previous ordering of the metrics output was sensitive to the
particular hashing algorithm used in that version of Perl. This
version sorts them in order to keep them stable, but which obviously
completely changes the (otherwise unmodified) widths part of the output.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This essentially reverts 6503051dcc since
that workaround is no longer needed thanks to support for multiple source
files
Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Handle the existence of multiple source files, as is normal when using
include files.
Signed-of-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
clang doesn't error out on unknown -W options unless
-Werror=unknown-warning-option is specified first, so do that so the
configure script can do its job.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>