At least DWARF can encode C-style macros. In doing so, it wants the
file include hierarchy, so give the debug format backend the option of
receiving that information from the preprocessor.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed and unsigned are really two flags; might as well allow this
field to contain additional flags.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Collect macro call/nesting information for the benefit of the debug
back end. So far, the only backend for which this is provided is the
debug back end, to show what information is present.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
"compiler.h" already includes a bunch of common include files. There
is absolutely no reason to duplicate them in individual files, and in
fact it robs us of central control of how these files are used.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
For almost everything we should use "nctype.h". Right now we don't
have a nasm_toupper() to use <ctype.h> for things that need toupper().
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
There is absolutely no reason not to include <string.h> globally, and
with the inline function for mempcpy() we need it there anyway.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
The use of pass0, pass1, pass2, and "pass" passed as an argument is
really confusing and already caused a severe bug in the 2.14.01
release cycle. Clean them up and be far more explicit about what
various passes mean.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The prefix ERR_WARN_ is unnecessarily long and may be a disincentive
to create new warning categories. Change it to WARN_*, it is still
plenty distinctive.
This is equivalent to nasm-2.14.xx checkin 77f53ba6d4.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* nasm-2.14.xx: (83 commits)
NASM 2.14rc16
doc: Update changes
preproc: expand_smacro -- Fix nil dereference on error path
eval: Eliminate division by zero
doc: Update changes
opflags: Convert is_class and is_reg_class to helpers
preproc: Fix out of range access in expand mmacro
doc: Update changes
parser: Fix sigsegv on certain equ instruction parsing
labels: Make sure nil label is never passed
labels: Don't nil dereference if no label provided
macho: Add warning message in macho_output()
macho/reloc: Fix addr size sensitive conditions
macho/reloc: Fix macho_output() to get the offset adjustments by add_reloc()
macho/reloc: Fixed offset adjustment in add_reloc()
macho/reloc: Allow absolute relocation when forcing a symbol reference
macho/reloc: Adjust SUB relocation information
macho/reloc: Fixed in handling GOT/GOTLOAD/TLV relocations
macho/reloc: Simplified relocation for REL/BRANCH
macho/sym: Record initial symbol number always
...
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
We don't want to lose the offset into the parent section when we
create a subsection, at least not for the MachO backend which is
currently the only user of subsections. Allow ofmt->herelabel() to set
a flag to copy the section offset from the previous section.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Make all limit counters 64 bits, in case someone really has a usage
for an insanely large program. The globallines limit was omitted, add
it to the list of configurable limits.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Make all limit counters 64 bits, in case someone really has a usage
for an insanely large program. The globallines limit was omitted, add
it to the list of configurable limits.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Only two output formats (obj and ieee) actually need ofmt->segbase, so
move the common dummy definion into nullout.c.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Allow the subsection to store a subsection value directly in the
label, rather than having to do strange encoding hacks.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
In order to support Mach-O better, add support for subsections, as
used by Mach-O "subsections_via_symbols". We also want to add
infrastructure to support this by downcalling to the backend to
indicate if a new subsection is needed.
Currently this supports a maximum of 2^14 subsections per section for
Mach-O; this can be addressed by adding a level of indirection (or
cleaning up the handling of sections so we have an actual data
structure.)
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
MachO has this odd thing called "subsections via symbols", by which a
symbol can magically start what effectively is a new section. To
support this, add support for a calldown into the backend when a new
symbol is defined *at the current output location*, and allow it to
switch the current segment.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Get rid of remaining dependencies on FILENAME_MAX, which ought to have
been removed a long time ago.
Remove ofmt->filename(); all implementations pretty much do the same
thing and there is absolutely no reason to duplicate that
functionality all over the place.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
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>
1. One incorrect variable use(!)
2. One possibly uninitialized variable.
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Add a generic facility for generating perfect string hashes, where all
that is needed is an enum and a string table. The existing mechanism
using a custom Perl script wrapped around a module continues to be
available for any use case where this particular approach isn't
sophisticated enough.
Much of this patch comes from renaming "enum directives" to "enum
directive" as a result of the string hash generator expecting a set of
uniform naming conventions.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
A raw data dump can potentially be very large, especially when
incbin is used. Allow a %pragma for setting the maximum dump
size (defaults to 128 bytes.)
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Update the debug output format to dump (most of) the information that
is available via the new backend format, as well as the legacy backend
format -- probably the only backend ever which will ever want both!
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>
Make the source code easier to understand and keep track of by
organizing it into subdirectories depending on the function.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Split lib/ into nasmlib/ (for nasm-specific functions) and stdlib/
(for replacements for C library functions which may be missing.)
Rename the ersatz inttypes.h to nasmint.h so we can use a simple test
in compiler.h instead of dealing with include path magic.
Remove tests in configure.in for ancient missing functions (which will
break the build anyway.)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Get rid of the completely pointless "debuginfo" parameter to
ofmt->cleanup(). Most backends completely ignore it, and the two that
care (obj, ieee) can simply test dfmt instead.
Also, dfmt is never NULL, so any test for a NULL dfmt is bogus.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Move ofmt->current_dfmt into a separate global variable. This
should allow us to make ofmt readonly and removes some additional
gratuitious differences between backends.
From master branch checkin a7bc15dd0a
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Make struct dfmt and the struct dfmt arrays const across the board,
and make them static whereever possible.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Move ofmt->current_dfmt into a separate global variable. This
should allow us to make ofmt readonly and removes some additional
gratuitious differences between backends.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
@size might be negative for signed relocations but its length
is abs value. This is rather a fix for future use because at
moment we can't hit this problems but better be on a safe side.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Add OUT_REL1ADR (one-byte relative address) and support for
OUT_ADDRESs with size == 1. Add support for it in
outbin and outdbg. *It still needs to be added to other backends*,
both the OUT_REL*ADR and OUT_ADDRESS codepaths need to be handled.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Remove a bunch of function pointers in the output stage; they are
never changed and don't add any value. Also make "ofile" a global
variable and let the backend use it directly.
All we ever did with these variables were stashing it in locals and
using them as-is anyway for no benefit.
Also change the global error function, nasm_error() into a true
function which invokes a function pointer internally. That lets us
use direct calls to it.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Hash all directives, even the ones that are backend-specific,
and instead pass the backend an already-parsed directive number.
Furthermore, unify null functions across various backends.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>