Commit Graph

3483 Commits

Author SHA1 Message Date
Cyrill Gorcunov
37034f1cc8 elf: Add EI_ constants
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-12 11:37:15 +03:00
H. Peter Anvin
8753425472 asm/pragma.c: if the handler is NULL, treat it as DIRR_UNKNOWN
If the handler is NULL, then all pragmas are by definition unknown, so
treat them exactly as if we had received DIRR_UNKNOWN from the
handler.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-03-08 20:28:13 -08:00
H. Peter Anvin
d9493fa440 pragma: use the directives hash to look up directive names
Very few things have any desire to do its own string parsing, and the
directives hash is already a plain string-to-numbers O(1) hash.  The
namespace is small enough that even if it makes some switch statements
compile a bit larger there is no real reason to have separate hashes,
even if the actual code as opposed to the data structure was shared.

So, for right now, just throw them together in one big happy pot.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-03-08 20:10:46 -08:00
H. Peter Anvin
d49a3bf6db changes.src: some minor textual improvements
Document the new -Werror= options a little bit better.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-08 01:50:08 -08:00
H. Peter Anvin
024d0e0fd0 NASM 2.13rc8 2017-03-08 01:32:56 -08:00
H. Peter Anvin
ea33e83081 Run "make alldeps"
Missing dependencies strike again :(

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-08 01:31:10 -08:00
H. Peter Anvin
e345e3d640 Merge remote-tracking branch 'origin/master' 2017-03-08 01:30:20 -08:00
H. Peter Anvin
b2047cbb98 Make -Werror controllable on a per-warning-class basis
Make -Werror possible to control on a per-warning-class basis.  While
I was fixing up that code anyway, merge the handling of the -w, -W and
[warning] argument and directives.

Furthermore, make *all* warnings suppressible; any warning that isn't
categorized now belong to category "other".  However, for cleanliness
sake an "other" option does not get listed in the warning messages.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-08 01:26:40 -08:00
Cyrill Gorcunov
485413344b asm/pragma: Add missing "assemble.h" inclusion
| asm/pragma.c:131:6: error: no previous prototype for ‘process_pragma’ [-Werror=missing-prototypes]
| void process_pragma(char *str)
|      ^~~~~~~~~~~~~~

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-08 11:39:42 +03:00
H. Peter Anvin
38373e8f1c NASM 2.13rc7 2017-03-07 23:04:15 -08:00
H. Peter Anvin
7fcd9898f4 doc: document subsections_via_symbols
Document the subsections_via_symbols directive.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 23:03:11 -08:00
H. Peter Anvin
fc7c5c3967 outmacho.mac: fix typo in subsections_via_symbols
subsections_via_symbols is plural for both nouns.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 23:02:31 -08:00
H. Peter Anvin
b786f66c2e output: output format macros should be case insensitive
Use %imacro instead of %macro for ELF "osabi" and Mach-O
"subsections_by_symbols".

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 22:53:48 -08:00
H. Peter Anvin
8e1cb8e594 outmacho: support the "subsections_via_symbols" directive
The "subsection_via_symbols" directive simply sets a flag in the
Mach-O file header.

Requested in BR 3392367.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 22:43:00 -08:00
H. Peter Anvin
e562b70cea output: make the return value from the directives method more meaningful
The directives code is already trying to do a bit more unified error
handling, so give ourselves a bit richer interface.  At this point,
the conversion was pretty automatic so we probably return DIRR_OK
instead of DIRR_ERROR in a fair number of places, but that's okay.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 22:42:39 -08:00
H. Peter Anvin
a6e26d9cca Add a generic pragma-handling infrastructure
Add infrastructure for handling %pragmas with a variety of namespaces,
etc., etc...

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 21:32:37 -08:00
H. Peter Anvin
bb4524cf9a include/error.h: add file missing from previous commit
The include file include/error.h was missing from checkin
b20bc733c9, oops...

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 19:52:57 -08:00
H. Peter Anvin
b83b2b28ad asm/directiv.c: remove commented-out #include
Remove a commented-out #include mistakenly left in the file.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 19:52:12 -08:00
H. Peter Anvin
9c595b6bb4 Fix global variables without declarations
Global variables need to be declared in a header file; "extern" in C
files should be used extremely rarely (it is OK at least for now for
macro tables as they are generally only ever used in one specific
location, but otherwise, no.)

In a few cases the global variables were actually function-local!

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 19:44:21 -08:00
H. Peter Anvin
e28d5ea5d7 Merge remote-tracking branch 'origin/master'
The directiv.c renaming unfortunately got pushed in two separate
version; force the correct one.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 19:32:46 -08:00
H. Peter Anvin
b20bc733c9 asm/*: Move directive processing to its own file, refactor error handling
Move directive processing to its own file, and move nasmlib/error.c to
asm/error.c (it was not used by the disassembler); remove some extern
declarations from .c files, and do some general code cleanups.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 19:31:04 -08:00
H. Peter Anvin
ed40e2528d Rename directiv.c to directbl.c to free up the name directiv.c
We want to move the directive handling to a separate file, so change
the filename of the directive table handler to something a bit more
specific.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 18:08:03 -08:00
H. Peter Anvin
17cb4eb659 Rename directiv.[ch] to directbl.[ch] to free up the name directiv.c
We want to move the directive handling to a separate file, so change
the filename of the directive table handler to something a bit more
specific.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 17:56:42 -08:00
H. Peter Anvin
c713168bc7 asm/nasm.c: Move directive parsing into a separate function
Move the directive parsing out of the main loop into a separate
function.  It is much cleaner this way, and opens up for further
refactoring -- a bunch of the directives do the same thing or very
similar things.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 17:45:01 -08:00
H. Peter Anvin
f786ef7371 outelf.c: char * -> const char *
Make the arguments to add_sectname() constant.  There are definitely
more things about this that ought to be cleaned up, including not
relying on magic offsets for the section numbers, but this is a
trivial cleanup that really needed to be done anyway.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-01 21:17:45 -08:00
H. Peter Anvin
14d0085f0b NASM 2.13rc6 2017-03-01 13:46:46 -08:00
H. Peter Anvin
64e87d0dfc assemble.c: for the signed byte operand, check overflow then rawbyte
When we are generating a signed byte operand, we anyway have to do the
overflow check "manually".  After doing so, output the result using
out_rawbyte() instead of out_imm(), so we don't end up doing a
redundant, and incorrect, second overflow check.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-01 13:45:02 -08:00
H. Peter Anvin
02788e1675 Revert "asm/assemble.c: change the overflow handling for signed byte immediates"
This reverts commit fbb07d6843.

This change was quite wrong; it is explicitly there to verify the
validity of the value as a 16/32/64-bit number, not it's
8-bit-worthiness.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-01 13:39:10 -08:00
H. Peter Anvin
964d502248 changes.src: correct form is "%idefine ptr $%?"
Actually do the right thing this time, hopefully...

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-01 13:35:13 -08:00
H. Peter Anvin
f23bd426be changes.src: to hide a keyword, %idefine foo $%??
The $ in "%idefine ptr $%??" was missing.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-01 13:32:27 -08:00
H. Peter Anvin
285222ffd6 assemble.c: always do overflow warnings on pass 2
It is very rare that it makes sense to warn on pass 1.  Instead, do
all the overflow warnings in pass 2.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-01 13:27:33 -08:00
H. Peter Anvin
fbb07d6843 asm/assemble.c: change the overflow handling for signed byte immediates
For byte immediates that are sign-extended to a wider operand size,
simplify the code and make the warning code behave as what is
expected.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-01 13:25:08 -08:00
H. Peter Anvin
55e06dead1 test/imm.asm: test more combinations of immediates
A few more combinations of immediates that can or should be converted.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-01 13:23:52 -08:00
H. Peter Anvin
2d89477ef4 configure.ac: smarter way to handle -O2 -> -O3 default change
We don't want to tack on -O3 if the user has specified, say,
CFLAGS='-g -O1' for debugging.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-01 12:57:46 -08:00
H. Peter Anvin
6980985eb9 make clean: clean up more things that ought to be
Cleaning up hasn't really kept up to date with source code changes.
Try make it better for now; this also ought to make it easier to do
the corresponding cleaning in the *.mak files.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-03-01 01:23:00 -08:00
H. Peter Anvin
09dff8b257 Remove casts in switch statements only meant to keep OpenWatcom happy
Remove casts in switch statements that were intended to keep
OpenWatcom happy.  It didn't work, and now we have a more general
solution for the problem, which also ought to be less dangerous.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-03-01 01:01:37 -08:00
H. Peter Anvin
e90a89abe4 compiler.h: add redundant cast to quiet Watcom warning
Add a redundant cast in watcom_switch_hack() to quiet a Watcom
warning, and remove open-coded implementation of the Watcom switch
hack.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-03-01 00:52:48 -08:00
H. Peter Anvin
e29c7bb241 include/compiler.h: change __WATCOM__ to __WATCOMC__
The correct macro to test for (Open)Watcom is __WATCOMC__ not
__WATCOM__.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-02-28 23:05:17 -08:00
sezeroz
34b5dbe496 openwcom.mak: further fixes to build with OpenWatcom WMAKE
Further fixes for OpenWatcom/WMAKE (BR 3392383).

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-02-28 23:01:14 -08:00
H. Peter Anvin
844cbe88a2 NASM 2.13rc5 2017-02-28 19:37:27 -08:00
H. Peter Anvin
0c36965335 configure.ac: make possible to compile with -ffunction/data-sections
The -ffunction-sections and -fdata-sections, if supported, can enable
the linker to do some amount of dead code elimination.  Basically a
very basic form of LTO.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-02-28 19:34:36 -08:00
H. Peter Anvin
9b935a0ea8 configure.ac: default to -O3
Default to -O3 instead of -O2.  The code gets somewhat bigger, but
nasm is full of tiny functions called from all over the place.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-02-28 19:02:51 -08:00
H. Peter Anvin
5fe847e590 Makefile: make it possible to compile with gcc link-time optimization
Put in the necessary machinery to compile with gcc link-time
optimization.  This means compiling and linking with -flto, as well as
using gcc-ar and gcc-ranlib instead of the normal tools.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-02-28 18:48:01 -08:00
H. Peter Anvin
2d6a3101f9 Run make alldeps 2017-02-28 18:14:35 -08:00
H. Peter Anvin
a5a56bd117 exprlib: move dumping code to a separate C file
Most of the time we don't need the dumping code, so move it to a
separate C file to the linker can exclude it.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-02-28 18:13:43 -08:00
H. Peter Anvin
4d58a8fef5 Makefile: move all non-main objects into libnasm.a
There is no fundamental reason for all objects that don't contain a
main() function to not be part of libnasm.a; this allows the linker to
do its job optimally, especially in the presence of debugging code
which may not be needed under normal conditions.

If we do end up with function name conflicts the library might have to
be split, but it would be better to simply avoid that case.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-02-28 18:08:21 -08:00
H. Peter Anvin
87646096a9 asm/parser.c: don't call reloc_value() twice, minor cleanups
There is absolutely no reason to call reloc_value() twice while
processing an immediate.  Doing so is both expensive and unnecessary.
Make some more deliberate decorations to try to avoid miscompilation
on OpenWatcom, but I'm not sure this will help enough.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-02-28 17:44:24 -08:00
sezeroz
c585e8b654 openwcom.mak: BR 3392381: update to work for the current master
Update openwcom.mak to work on the current master branch, per
BR 3992381.

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

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-02-28 17:38:01 -08:00
H. Peter Anvin
895a66cbcb configure.ac: use AC_FUNC_MMAP instead of AC_CHECK_FUNCS(mmap)
There are a couple of extra checks in autoconf for mmap, supposedly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-02-23 20:34:38 -08:00
H. Peter Anvin
4b63094602 perllib/README: delete obsolete file
We have not included CPAN modules for a long time.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-02-23 20:24:56 -08:00