Commit Graph

3374 Commits

Author SHA1 Message Date
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
H. Peter Anvin
f15b125f17 changes.src: grammar fix
Fix a grammar mistake.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-02-23 20:20:50 -08:00
H. Peter Anvin
680f740b5a NASM 2.13rc4 2017-02-23 20:11:30 -08:00
H. Peter Anvin
2958bcc6c2 compiler.h: correctly handle HAVE_DECL_*, test HAVE_DECL_STRNLEN
HAVE_DECL_* are 0/1 not ifdef; use HAVE_DECL_STRNLEN to see if we need
to declare this, lest stdlib/strnlen.c fails to compile.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-02-23 19:23:10 -08:00
H. Peter Anvin
bc18af18f0 configure: make sure we flag invalid attributes
Use -Werror=attributes so we can actually test for non-supported
attributes without spewing warnings.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-02-23 19:22:27 -08:00
H. Peter Anvin
3fa2558a69 output/codeview.c: remove C99-ism
Remove a C99-ism, specifically the use of a variable declaration
inside a for loop statement.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-02-23 18:43:31 -08:00
H. Peter Anvin
9222364607 nasmlib/file: move memory-mapping functions out of file.c
Move memory-mapping functions from file.c into a separate mmap.c.
This will be cleaner especially once (if) we end up doing a Windows
implementation, which is likely to look entirely different.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-02-23 18:39:00 -08:00
H. Peter Anvin
f7aae402da NASM 2.13rc3 2017-02-23 18:21:03 -08:00
H. Peter Anvin
cbd72b68fc nasmlib/file.c: fix various portability problems
Fix portability problems which prevented this code from building on
Win32 with MinGW-W64.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-02-23 18:19:25 -08:00
H. Peter Anvin
11f18ec05b asm/exprlib.c: use PRId64 to print a 64-bit number
Use PRId64 instead of %ld to print a 64-bit number.  This is debugging
code, but as it is frequently useful I included it in mainline code
and, well, then it has to compile everywhere...

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