Scan the command line twice, so we among other things can set up the
proper preprocessor before calling any of the preprocessor entry
points.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
We have been doing a pathname search every time we encounter a file,
which means every file in every pass. Instead, put the pathnames
found in a hash table.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
An INCBIN "instruction" can be enormous (up to an off_t size.) There
is no reason to burden the rest of the code by widening the inslen and
insoffs fields just for INCBIN, so set inslen == 0 to indicate fields
not valid.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
If we can't mmap a file and instead have to fread(), if the data is
small enough that we can reasonably accomodate it in a memory buffer,
then just read it once.
It seems rather unlikely that very large files would be used with
TIMES anyway.
Also note: the previous comment about nasm_file_size[_by_path]() being
invoked twice was spurious; it does not actually happen.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
A number of fairly common operations are invoked way too many times,
especially when using incbin. Drastically reduce the number of system
calls that need to be executed, and use memory mapping to reduce
unnecessary double buffering.
We could improve this further by leaving files open once used;
however, that might run into file count problems on some systems.
Still unclear is why we seem to invoke nasm_file_size() twice per pass
for incbin.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
For EVEX instructions, /is4 can contain a fifth register bit, encoded
in bit 3 of the imm8. Properly generate this case, and simplifiy the
/is4 generation code somewhat.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cherry picked and ported from nasm-2.12.xx commit
976ba73062.
Resolved Conflicts:
asm/assemble.c
This provides the first pass of assembler internals for a new, richer,
backend interface. It also reduces the amount of data carried in
function parameters inside the assembler.
The new interface is in the form of a structure, which will contain
substantially more information that the previous interface. This will
allow things like ELF GOT32X and Mach-O X86_64_RELOC_BRANCH
relocations to be reliably emitted.
This provides the initial set of structures. Future additions should
include:
1. Pass down the base symbol, if any.
2. Segments should be a structure rather than a number, and the
horrible hack of adding one for a segment reference should be
removed (OUT_SEGMENT replaces it.)
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
The ordering of the macro sets ended up changing due to the recent
file reorganization. Instead of forcing the order again, handle
multiple macro sets (rather than just two) in a coherent manner.
macros/macros.pl could use a cleanup of duplicated code, however.
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>