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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>