Commit Graph

3607 Commits

Author SHA1 Message Date
Cyrill Gorcunov
fdbf7012ba configure: Add --enable-gdb option
When one needs to run nasm under GDB

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-07-29 16:07:40 +03:00
Cyrill Gorcunov
b6a173fad5 preproc: Free token's text if only it has been modified
https://bugzilla.nasm.us/show_bug.cgi?id=3392414

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-07-26 01:21:16 +03:00
Adam Majer
736be08cf3 preproc: Workaround a usage after free bug
In some circumstantes this free is incorrect resulting
in usage after-free. Workaround it by not freeing memory
here.

https://bugzilla.nasm.us/show_bug.cgi?id=3392414

gorcunov@:
 - slightly tuneup the comment

Signed-off-by: Adam Majer <amajer@suse.de>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-07-25 13:29:30 +03:00
Adam Majer
f9ec5bbd2a preproc: Only concat tok->text if we accounted for its size
https://bugzilla.nasm.us/show_bug.cgi?id=3392415

Signed-off-by: Adam Majer <amajer@suse.de>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-07-25 13:15:12 +03:00
Cyrill Gorcunov
20d9c86eb1 build: Merge CPPFLAGS into ALL_CFLAGS
This is a fix for a4f6ca5a33

 - We should not use sole CPPFLAGS when compiling,
   but rather merge it into ALL_CFLAGS

 - nasm.spec.in should use DESTDIR since
   INSTALLROOT now renamed to it

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-07-06 01:36:06 +03:00
David Seifert
a4f6ca5a33 Make buildsystem respect GNU conventions
* CPPFLAGS is a user variable and should be respected
  when compiling .c files. Think of -D_FORTIFY_SOURCE=2.

* Pass ALL_CFLAGS when linking too. This is recommended
  for certain edge cases (-flto)

* Use DESTDIR instead of INSTALLROOT for staging dir
  Every other build system (Automake, CMake, Meson) uses
  DESTDIR. This integrates better into distro and other
  build systems that have standard hooks for DESTDIR.

* $(MAKE) -C <dir> is better than cd'ing into a <dir>

* Use Autoconf's ${docdir} and ${htmldir} for installing
  the documentation. This makes handling documentation
  easier and respects user choice.

Signed-off-by: David Seifert <soap@gentoo.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-07-06 01:28:57 +03:00
Cyrill Gorcunov
6e53180085 nasmlib/md5c: Fix typo in WORDS_LITTLEENDIAN
https://bugzilla.nasm.us/show_bug.cgi?id=3392416

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-06-24 14:32:05 +03:00
H. Peter Anvin
aac369d5b0 Merge remote-tracking branch 'origin/nasm-2.13.xx'
Resolved Conflicts:
	common/common.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-06-23 14:48:08 -07:00
H. Peter Anvin
df1eec0315 saa: fix typo: LITTEENDIAN -> LITTLEENDIAN
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-06-23 14:39:12 -07:00
H. Peter Anvin
58d2ab176f outmacho: always use symbol-relative relocations for MachO64
It seems that the MachO64 linker really doesn't like segment-relative
relocations under certain circumstances, so force relocations to be converted
to "external" (symbol-relative); error out if no symbol is available
(if this is a problem, we can consider inserting a synthetic symbol if
necessary.)

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-06-22 23:36:34 -07:00
H. Peter Anvin
1669cb04a5 outdbg: make the output for relative relocations more clear
Make the output for relative relocations more clear, so it can be
actually comprehended.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-06-22 23:00:38 -07:00
H. Peter Anvin
8a6903c43d test/reldef.asm: add some global symbols
Make some symbols global for more testing.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-06-22 18:39:52 -07:00
H. Peter Anvin
f61dd0fdbb reldef.asm: add more test cases for reference
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-06-22 18:32:49 -07:00
H. Peter Anvin
37b9be3402 reldef.asm: more comprehensive test
More testing of various relative operations.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-06-22 18:20:44 -07:00
sezeroz
2987e5d90e BR 3392409: idata_bytes() and resv_bytes() don't match their prototypes
https://bugzilla.nasm.us/show_bug.cgi?id=3392409

idata_bytes() and resv_bytes() don't match their prototypes in common.c
which leads to a build error with watcom.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-06-01 15:23:05 -07:00
Martin Storsjö
869087d53d Use cpu_to_le64 instead of htole64
This fixes compilation on macOS, Windows, and quite likely a number of
other platforms.

Signed-off-by: Martin Storsjö <martin@martin.st>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-24 10:19:56 -07:00
H. Peter Anvin
95f5373ee9 .gitignore: add *.od and /misc/omfdump
A few generated files missing from .gitignore.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-05-03 17:34:04 -07:00
H. Peter Anvin
a7b6bfca68 Sanitize the handling of segments a bit
Make the internal handling of segment numbers just a little more
sane.  The whole use of when we have done ofmt->segbase or not is
crazy, though...

In the meantime, add a few more hacks to the dbg output format to make
it more useful.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-05-03 17:33:04 -07:00
H. Peter Anvin
09a3f8d18a omfdump: decode a few more record types
Eventually it would be good to have far more of these...

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-05-03 17:30:22 -07:00
H. Peter Anvin
4be9b5790d nasmdoc.css: add more space between columns and a column separator
The columns were rather crammed together; add more space around them
and add a column separator bar.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-02 13:09:49 -07:00
H. Peter Anvin
735883692d Document/update dependencies for the documentation
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-02 13:01:59 -07:00
H. Peter Anvin
afa56016d4 insns.h: mark resb_bytes() const_func
Usually const_func doesn't matter for inlines, as the compiler can
"see" the innards of the function already, but it doesn't cost to mark
it as such.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-02 11:48:40 -07:00
H. Peter Anvin
7f419dff4e Merge tag 'nasm-2.13.01'
NASM 2.13.01

Resolved Conflicts:
2017-05-02 11:46:34 -07:00
H. Peter Anvin
13ff7f92ec NASM 2.13.01 2017-05-01 22:17:48 -07:00
H. Peter Anvin
7c99db15f0 insns.h: change ITEMPLATE_END to not warn on some compilers
The use of negative numbers for some fields in ITEMPLATE_END triggers
a nuisance warning at least with Sun CC.  There is no reason for it:
the only thing that matters in this template is I_none, so declare it
that way.

See BR 3392372.

Reported-by: <noloader@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 22:06:58 -07:00
H. Peter Anvin
2fbc727078 insns.h: db_bytes() should take an enum opcode
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 21:49:24 -07:00
H. Peter Anvin
3cee8b4a4a insns.dat: change the title of the pseudo-ops section
Use the term pseudo-ops, as this is a well-known assembly term.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 21:46:34 -07:00
H. Peter Anvin
af9fe8f597 Don't sort opcodes; move all pseudo-ops to the beginning
We don't need to sort opcodes anymore, since we are using an O(1) hash
and not binary search.  Instead, sort them in the order they first
appear in insns.dat; this lets us move all the pseudo-ops to a
contiguous range at the start of the file, for more efficient
handling.

Change the functions that process pseudo-ops accordingly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 21:44:24 -07:00
H. Peter Anvin
d23066906c incbin: remove pointless call to lfmt->set_offset()
We already have the correct offset; otherwise the times == 1 case
would not work.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 21:29:05 -07:00
H. Peter Anvin
20f6c253cd Merge remote-tracking branch 'origin/nasm-2.13.xx' 2017-05-01 21:25:14 -07:00
H. Peter Anvin
4892f95bb5 doc/changes.src: update with the latest changes
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 21:16:21 -07:00
H. Peter Anvin
3e458a89d8 a) Fix handling of DZ/ZWORD; b) don't crash on TIMES JMP
a) Fix a number of missing instances of DZ and ZWORD.

b) NASM would crash if TIMES was used on an instruction which varies
   in size, e.g. JMP.  Fix this by moving the handling of TIMES at a
   higher level, so we generate the instruction "de novo" for each
   iteration.  The exception is INCBIN, so we can avoid reading the
   included file over and over.

c) When using the RESx instructions, just fold TIMES into the reserved
   space size; there is absolutely no point to iterate over it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 21:13:15 -07:00
H. Peter Anvin
5810c594c9 listing: fix base address for TIMES
A simpler, and actually correct fix for the listing address for
TIMES.  The listing interface is quite frankly insane, but it probably
is better to fix it in 2.14+ and not in the maintenance branch.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 19:51:09 -07:00
H. Peter Anvin
5f93c9597d Revert "asm/assemble.c: correct the listing address for TIMES"
This reverts commit 440ba7e13e.

The fix is wrong; it causes the listing file to *only* show <rept>,
without showing the first iteration.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 19:44:34 -07:00
H. Peter Anvin
3301ee8a9e doc/changes.src: document the changes to the 2.13 maint branch so far
Current changes scheduled for 2.13.01.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 15:41:30 -07:00
H. Peter Anvin
440ba7e13e asm/assemble.c: correct the listing address for TIMES
We need to set the listing offset before calling LIST_TIMES, but we
had already advanced data.offset by calling out().  Move the call to
lfmt->set_offset() and lfmt->uplevel() to the top and out of the loop;
there is no reason for it to be in the loop in the first place.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 15:39:15 -07:00
H. Peter Anvin
571592ea63 listing.c: show [ssss] for a segment instead of a bogus address
There is no point in showing a number of a relative segment, so just
show [ssss]; even if there is a possible segment offset it is
linker-dependent and output format dependent.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 15:32:37 -07:00
H. Peter Anvin
217e714e6b output/legacy.c: OUT_SEGMENT -> OUT_ADDRESS with a zero addend
The legacy output doesn't distinguish between segments and other
addresses, so we need to force the offset to zero before passing it
down to the output layer.

This addresses BR 3392406.

Reported-by: <rugxulo@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 15:10:47 -07:00
H. Peter Anvin
08e71e7dc4 test/Makefile: add a rule to run omfdump on an .obj file
omfdump is really useful while debugging obj output, so add an
explicit rule to generate omfdump output.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 15:09:44 -07:00
H. Peter Anvin
b3dd17b0b6 Merge branch 'nasm-2.13.xx' 2017-04-29 13:35:16 -07:00
H. Peter Anvin
91ac58dc65 changes.src: we managed to implement a few %pragmas before 2.13...
Minor change to the release notes for 2.13: we did end up with a few
actually implemented %pragmas.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-29 13:34:19 -07:00
H. Peter Anvin
9516cf3fda NASM 2.14rc0
Tag the development branch as NASM 2.14rc0 so there is no confusion
about ordering versus the 2.13.xx branch.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-29 13:29:53 -07:00
H. Peter Anvin
97408d67dd Merge remote-tracking branch 'origin/elf' 2017-04-29 13:28:12 -07:00
H. Peter Anvin
b84ac82249 NASM 2.13 2017-04-29 13:25:21 -07:00
H. Peter Anvin
65ce38a819 nasmlib/ilog2.c: force the shift in ROUND() to be an uint32_t
Some compilers apparently warn on 1 << w for w == 31; fix it by
explicitly making it UINT32_C(1).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-29 13:13:59 -07:00
H. Peter Anvin
0624296834 changes.src: definitely making 2.13 next
About to release 2.13 for real.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-29 13:13:59 -07:00
H. Peter Anvin
d6b9227565 NASM 2.13rc23 2017-04-27 20:04:34 -07:00
Chang S. Bae
375f452813 outmacho: fix dwarf line number information (debug_line section)
Create directory table in prologue and file name indicates index
of the table for its directory

Now bring back included file names

Signedoff-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-27 20:04:15 -07:00
Chang S. Bae
961d8670bf outmacho: add dir list
Separate dir info from the file list to align with dwarf format
in debug_line section

Signedoff-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-27 20:03:53 -07:00
H. Peter Anvin
0e37f02bad Mkfiles/README: add a blank line
Trivial formatting fix: add a blank line for readability.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-26 00:22:42 -07:00