Correctly generate references between sections. The previous
version would work correctly as long as all relative references
came from the first section, which is usually __TEXT,__text and
so it usually worked.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Better handling of the replacement for fseeko() in its absence; also
look for the Windows _fseeki64() function.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
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>