For 64 bits, a BRANCH reloc is sometimes needed to fix up PIC
problems. Make a best effort at generating BRANCH relocs just as
we make a best effort at distinguishing GOTLOAD from GOT.
This needs to be replaced with information from the assembler to
the backend.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
On systems that support it, allow the writing of sparse files.
This can be useful for some file formats (like binary, or ELF if the
alignments are very large) that can contain large amounts of zeroes.
This is not inherently portable code, so condition it on certain known
systems.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Add an option to compile with -Werror, useful for development.
Change --with-ccache to --enable-ccache to match guidelines.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Windows: indicate that we support multibyte character sets in file
names.
Unix: support gigantic input and output files. Might be useful
especially in the presence of the INCBIN directive.
Signed-off-by: H. Peter Anvin <hpa@linux.kernel.org>
The __TEXT segment in particular contains both code and data. The
most consistent thing is to look only at the section name, and have
the same behavior across sections.
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>
Right now, we don't check the return value from nasm_realpath();
furthermore doing so and failing is probably not the ideal behavior.
If we can't get the full canonical path, then punt and just return
nasm_strdup() of the known path name; better than nothing.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Remove additional cached function pointers which point to static
variables which are never actually changed. Just refer to the global
variable instead.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Complete the globalization of the output format definitions;
one more place where a local copy was cached for no good reason.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
For consistency with ofmt/dfmt, change the listing structure
to "struct lfmt" and "lfmt" and move it to listing.h.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
The variable symtabsection is defined but it is never actually set and
so was always zero. For both the 32-bit output format this is
sec_symtab defined in elf.h.
If this is not correct for the 64-bit format, then we should define
sec_symtab as a variable instead of having a gratuitious format
difference.
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>
Most preprocessor warnings are ERR_PASS1, but we want to see them in
the listing file too. If we make it to the code-generation pass,
ignore ERR_PASS* for the purpose of emitting warnings to the list
file.
While we are at it, allow ERR_DEBUG to specify ERR_PASS* too.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
We pass around a whole bunch of function pointers in arguments,
which then just get stashed in static variables. Clean this mess
up and in particular handle the error management in the preprocessor
using nasm_set_verror() which already exists.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
The debugging functions currently have unique prefix, which is good
for debuggability but hides real code differences. Convert them to
have the same name across files.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Instead of completely useless sequential line numbers, emit line
numbers corresponding to the line numbers in the source code.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Move the function stabs32_linenum() so that it is in the same location
as in the other ELF backends; this eliminates a gratuitous difference.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Make a point of the output format constants instead of making it
a pointer. The output format is set only once, but it is accessed
all the time.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Correct the handling of GOT relocations, as they need a symbol
reference. Add handling of TLVP relocations; it is unclear to me
if non-local relocations in TLVP space is permitted.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
For the mapping of .rodata to __TEXT,__const in the absence of
relocations, it would help if we changed the segment name *before* we
emit that part of the load command.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Sanitize the handling of sections in outmacho somewhat. This should
bring further performance improvements.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Slightly simplify the handling of segment number allocation.
If we are in absolute space, never push a segalign down to the backend.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>