This should be more convenient. At least both headers
are well documented in specifications so we simply
follow them.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
We don't have any elf pragmas yet, but we want to be able to do
"%pragma elf" and have it work for any of the elf formats.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Implement the MachO do_dead_strip directive, which sets a flag on the
corresponding section. This as well as subsections_by_symbols are
reimplemented as pragmas; if someone uses the predefined macro they
still get the expected behavior.
However, this allows someone to write:
%pragma macho subsections_by_symbols
... and have it ignored if compiling for, say, ELF.
Also, implement the following section attributes:
zerofill, no_dead_strip, live_support, strip_static_syms
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
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>
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>
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>
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>