Commit graph

3257 commits

Author SHA1 Message Date
Cyrill Gorcunov
5dfcab6bf9 labels: Warn if new label created on pass two
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>
2016-07-18 11:49:47 +03:00
bcallah@devio.us
065c34273c Add explicit void parameter to newmembuf() function declaration.
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>
2016-07-14 14:15:41 -07:00
H. Peter Anvin
2fc232bd23 compiler.h: always undefine __STRICT_ANSI__ for gcc
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>
2016-07-14 13:51:01 -07:00
H. Peter Anvin
7e70f4dbb3 Merge tag 'nasm-2.12.02'
NASM 2.12.02

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-07-14 13:47:51 -07:00
H. Peter Anvin
f7606613d0 Handle multiple standard macro sets sanely
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>
2016-07-13 14:23:48 -07:00
H. Peter Anvin
f640b61d55 NASM 2.12.02 2016-07-06 13:22:32 -07:00
H. Peter Anvin
0fcb488df3 Don't suppress ERR_DEBUG messages from the list file
In some cases, debug messages in the list file can be enormously
powerful for finding problems.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-07-06 11:55:25 -07:00
H. Peter Anvin
3d74b091e9 doc: update location of insns.dat
insns.dat is now in the x86 directory.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-07-06 11:02:14 -07:00
Cyrill Gorcunov
bbb7a1aad9 preproc: Fix accessing OOM address
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>
2016-06-19 12:15:24 +03:00
H. Peter Anvin
66d561f2d9 Merge tag 'nasm-2.12.02rc9'
NASM 2.12.02rc9

Resolved Conflicts:
	asm/preproc.c
	version

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-06-16 15:47:46 -07:00
H. Peter Anvin
41d8a17195 NASM 2.12.02rc9 2016-06-16 15:33:53 -07:00
H. Peter Anvin
f500d83ca4 preproc.c: fix assignment incorrectly coded as ==
Assignment is = not ==.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-06-16 15:28:09 -07:00
H. Peter Anvin
fd2b1a6be9 NASM 2.12.02rc8 2016-06-16 15:08:15 -07:00
Jim Kukunas
65a8afcaba preproc: for include files, include correct path in filename
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 ]
2016-06-16 15:07:32 -07:00
H. Peter Anvin
b41952986b outmacho: Fix relative relocations for 32-bit Mach-O (fix typo)
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>
2016-06-14 18:04:46 -07:00
H. Peter Anvin
5e0eb0c08b NASM 2.12.02rc7 2016-06-03 23:57:10 -07:00
knut st. osmundsen
8e6feefb3b outobj.c: Fix for RIP relative addressing relocation.
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>
2016-06-03 23:54:12 -07:00
H. Peter Anvin
e1f985c167 Reorganize the source code into subdirectories
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>
2016-05-25 12:06:29 -07:00
H. Peter Anvin
22538e2b67 nasmlib: break up nasmlib.c into logical components
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>
2016-05-25 05:43:49 -07:00
H. Peter Anvin
0c0fdaa357 ndisasm: don't use nasm_open_read()
Don't use nasm_open_read() in ndisasm.c, as we don't currently
use nasm_error() in the disassembler.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-05-25 04:47:02 -07:00
H. Peter Anvin
3e83cec90e Add wrappers around fopen(), use mmap on glibc
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>
2016-05-25 04:34:00 -07:00
H. Peter Anvin
4976cd2518 nasmlib: give gcc a bit more hints about how our allocation functions work
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>
2016-05-25 03:56:34 -07:00
H. Peter Anvin
9f9ba28043 NASM 2.12.02rc6 2016-05-25 03:11:02 -07:00
H. Peter Anvin
794688c21c Merge remote-tracking branch 'origin/nasm-2.12.xx'
Resolved Conflicts:
	version

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-24 23:48:38 -07:00
H. Peter Anvin
6c8b2be1dd preproc: make "StackPointer" a const char *
The less non-const the better...

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-24 23:46:50 -07:00
H. Peter Anvin
0183894895 codeview: use nasm_realpath() to find the canonical name of the outfile
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>
2016-05-24 23:35:57 -07:00
H. Peter Anvin
8794350751 NASM 2.12.02rc5 2016-05-24 23:06:11 -07:00
H. Peter Anvin
aa958b1ab6 ifunc.mac: the ilog2 warning may want to be both ceil and floor
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>
2016-05-24 23:03:17 -07:00
H. Peter Anvin
57a0581394 codeview: don't walk the file list for every line
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>
2016-05-24 23:00:23 -07:00
H. Peter Anvin
5e43bfef24 doc: include kerning tables in the metrics headers
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>
2016-05-18 01:58:58 -07:00
Jim Kukunas
4de0e93677 codeview.c: register all filenames
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>
2016-05-17 11:35:44 -07:00
Jim Kukunas
f8259c662a codeview.c: Add support for multiple source files
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>
2016-05-17 11:35:44 -07:00
H. Peter Anvin
7baac1e7f8 Merge remote-tracking branch 'origin/nasm-2.12.xx' 2016-05-16 21:36:53 -07:00
H. Peter Anvin
c9fd7b2aa5 configure: correctly discover -W options for clang
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>
2016-05-16 21:35:48 -07:00
H. Peter Anvin
a87c5e4c87 Merge remote-tracking branch 'origin/nasm-2.12.xx'
Resolved Conflicts:
	.gitignore
	Makefile.in
	Mkfiles/msvc.mak
	Mkfiles/netware.mak
	Mkfiles/openwcom.mak
	Mkfiles/owlinux.mak
	preproc-nop.c
	preproc.c
	version

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-05-16 21:27:33 -07:00
H. Peter Anvin
acbf8f0e19 doc: remove obsolete references
We don't use comp.lang.asm.x86 or freshmeat for announements anymore.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-16 20:39:04 -07:00
H. Peter Anvin
407166001c Fix building in a separate directory from the source code
The code to handle building in a separate directory had seriously
bitrotted.  This contains a number of fixes to make it possible,
including bits like the documentation which never worked in the past.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-16 20:30:09 -07:00
H. Peter Anvin
b06736ae7e Unbreak building in a separate object directory
Fix bitrot in building in a separate object directory.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-16 13:20:01 -07:00
H. Peter Anvin
cba1aca466 autogen.sh: remove configure-generated files
Remove files generated by configure when running autogen.sh.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-16 13:05:04 -07:00
H. Peter Anvin
2c9b6ad3d9 Support EVEX encodings of maps 0-15
Treat bits [3:0] of EVEX byte 0 as opcode map bits.  Check the range
of opcode maps in insns.pl: 0-31 for VEX, 8-31 for XOP, 0-15 for EVEX.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-13 14:42:55 -07:00
H. Peter Anvin
6a5b3ecb16 codeview: use nasm_free() instead of plain free()
We want to consistently use our allocator wrapper functions whereever
possible.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-10 15:40:24 -07:00
H. Peter Anvin
c0aaf9750f Revert "nasmlib/file.c: Windows _chsize_s() *returns* errno"
This reverts commit 55e51d9534.

First of all, _chsize_s() *does* set errno, even though it returns the
same value.  Second of all, all we look for is a zero return value
anyway, so there is no need for this wrapper.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-10 15:18:00 -07:00
H. Peter Anvin
55e51d9534 nasmlib/file.c: Windows _chsize_s() *returns* errno
_chsize_s(), but not _chsize(), actually *returns* errno rather than
setting errno; create a wrapper routine to make it match the other
nasm_ftruncate() varieties.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-10 15:14:30 -07:00
Cyrill Gorcunov
771d04e263 preproc: Don't dereference nil @istk
If not input was specified istk = NULL, so don't dereference it.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-05-10 23:27:03 +03:00
H. Peter Anvin
acb48602fc srcfile.c: remove unnecessary #include's
Remove #include's inherited from nasmlib.c which aren't needed in this
file.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-10 09:01:10 -07:00
H. Peter Anvin
cfbdc3c6fa NASM 2.12.02rc4 2016-05-10 03:12:28 -07:00
H. Peter Anvin
02f49f2c1e stdscan: put some error message strings in quotes
Put some error message strings inside `...' quotes to match existing
usage.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-05-10 03:08:09 -07:00
H. Peter Anvin
274cda81f8 Use a hash to keep exactly one copy of each filename around
The old code for keeping track of source file name and line was
confused as hell about ownership of the strings, and it is pretty
clear we leaked that information all over the place.

Instead, use a hash table to keep a copy of each string as necessary,
and simply make references to a string pool that we keep until the end
of the assembly session.

This pool probably should be unified with the list of dependency
files, and so on, but that is for the development branch.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-05-10 03:01:58 -07:00
H. Peter Anvin
b157701b17 quote: make the input argument to nasm_quote() const
Whereas nasm_unquote() unquotes the argument in place, nasm_quote()
has to allocate a new string (since the new string will *always* be
longer than the old string!)  Make the old string const since we're
making a copy anyway.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-05-10 02:59:04 -07:00
Fabian Giesen
c74a709885 codeview: Call register_file only when producing line numbers
Previously, debug info would refer to the first file seen, even
when it did not actually generate line numbers (e.g. segto=-1).

Fix it so we only lock in the file name the first time we actually
produce a line number record. Not as good as proper support for
debug info referencing multiple source files but much more useful
than the current behavior.

Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-05-10 12:01:32 +03:00