Age | Commit message (Collapse) | Author | Files | Lines |
|
ARRAY_SIZE is a well known name pointing out that
we're dealing with array in macro argument.
Also to be on a safe side prefix_name helper should
check the index been in bounds more precisely.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
|
|
nasm_opt_val should be able handle various text stream
passed, including tainted ones. Make it so.
Also it fixes the case when Elf section has multiple
attributes such as "progbits align=16" and friends
(introduced by commit bb0745f). The former just ignore
any other options/values except first one.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
|
|
For easier space separated words extraction
from a text stream.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
|
|
In case if we can't open "malloc.log" for writing
we should not hang out but rather switch to stderr
and continue processing.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
|
|
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
|
|
In a sake of portability we should better use
UINT64_C instead of open-coded ULL postfix.
[ BR2938449 ]
Reported-by: Alexander Ilyin <dragity@mail.ru>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
|
|
This allow us to eliminate code duplication
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
|
|
By analogy with nasm_zap_spaces_rev() have nasm_zap_spaces_fwd(). The
forward version isn't a super-common operation, and it might be
possible to think the reverse one is the "normal" version... therefore
we might as well be explicit.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
To make code more compact we introduce the
following string helpers:
1) nasm_scip_spaces - skip leading spaces
2) nasm_skip_word - skip leading non-spaces
3) nasm_zap_spaces - zap leading spaces with zero
4) nasm_zap_spaces_rev - zap spaces in reverse order
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.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>
|
|
*To the best of my knowledge*, we now have authorization from everyone
who has significantly contributed to NASM in the past. As such,
change the license to the 2-clause BSD license.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Change the "noreturn" macro to "no_return", to avoid problems with
system header files which use __attribute__((noreturn)) rather than
__attribute__((__noreturn__)) as is appropriate for system headers.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Add new nasm_assert() function, and add "const" to the declarations
which take filenames, as well as to the nasm_strdup/strndup functions.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Add copyright headers to the *.c/*.h files in the main directory. For
files where I'm sure enough that we have all the approvals, I have
given them the 2-BSD license, the others have been given the "LGPL for
now" license header. Most of them can probably be changed after
auditing.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Move backend-specific code into the output/ directory, and make the
null debugging backend a separate file (it certainly isn't needed for
ndisasm...)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
WAIT is technically an instruction, but from an assembler standpoint
it behaves as if it had been a prefix. In particular, it has to be
ordered *before* any real hardware prefixes.
|
|
None of the strings passed to nasm_strcat() are modified, to
make them const.
|
|
We have a number of all-zero buffers in the code. Put a single
all-zero buffer in nasmlib.c. Additionally, add fwritezero()
which can be used to write an arbitrary number of all-zero bytes;
this prevents the situation where the all-zero buffer is simply
too small.
|
|
Fix nasm_str[n]icmp() on platforms which don't have this function
natively.
XXX: Given the new nasm_tolower() implementation, we should consider
if this might actually be a faster function than the platform-native
one.
|
|
ctype functions take an *int*, which the user is expected to have
taken the input character from getc() and friends, or taken a
character and cast it to (unsigned char).
We don't care about EOF (-1), so use macros that cast to (unsigned
char) for us.
|
|
On some platforms, tolower() is implemented as a function call, in
order to handle locale support. We never change locales, so can the
result of tolower() into a table, so we don't have to sit through the
function call every time.
~1.3% overall performance improvement on a macro-heavy benchmark under
Linux x86-64.
|
|
fwriteint*() don't require unaligned references, so they can be
optimized for WORDS_LITTLEENDIAN rather than X86_MEMORY...
|
|
The RAA code doesn't have to be in nasmlib; it is only used by nasm
itself, and is better handled in a separate module.
|
|
Move all the SAA code out of nasmlib; it's not used by anything than
nasm itself. Cleaning out the kitchen sink known as nasmlib is a good
thing, too.
|
|
Hopefully backquoted strings should work correctly now.
|
|
First attempt at properly handle quoted strings in the preprocessor.
This also adds range support in %substr.
No support in the assembler yet.
|
|
Add a nasm_unquote() function supporting the intended `...` syntax.
|
|
Introduce new preprocessor directives %depend and %pathsearch, and
make incbin a standard macro using these filenames. This lets us
remove the code that makes incbin search the path.
|
|
First cut at AVX machinery support. The only instruction implemented
is VPERMIL2PS, and it's probably buggy. I'm checking this in with the
hope that other people can start helping out with (a) testing this,
and (b) adding instructions.
NDISASM support is not there yet.
|
|
1. Port dwarf3 support from ELF64 to ELF32
2. Move common SAA extentions to nasmlib
|
|
Make the RAA size always a power of two, so we can use shifts instead
of multiple, expensive divides.
|
|
If we're logging nasm_free(), then log it before we actually call
free(); that way we can find out what the last thing was if free()
crashes.
|
|
In particular, we'd miss issuing warnings for out-of-range dword
values, and the message for constants too large (we can't deal with >
64 bits) said 32 bits, not 64.
|
|
|
|
raa_free() didn't actually do the proper job; it would only free leaf
nodes, not internal nodes.
|
|
1. Don't warn on 32-bit overflow
2. Change EM64T to Intel 64 in Defining CPU Dependencies
section of documentation.
|
|
Slight cleanup of the fwrite*() functions. This actually helps gcc
generate better code on i386, for no apparent reason.
|
|
If we're on an x86 host, we can do unaligned littleendian memory
references directly. Just do'em.
|
|
Address data is always int64_t even if the size itself is smaller;
this was broken on bigendian hosts (still need testing!)
Create simple "write sized object" macros.
|
|
Use the elements() macro to count the elements in a static array.
|
|
The string argument to bsi() and bsii() should be const.
|
|
|
|
|
|
Suffixed versions of zero will look like both a prefix and a suffix.
Reject the prefixed version as being too short to decode.
|
|
(pradix && pradix > sradix) etc. is unnecessary since pradix and
sradix cannot be negative, so zero is always the smallest value.
Put in a comment explaining why making the default radix == 10 doesn't
need any additional error checking.
|
|
Unbreak hex constants which contain 'b' or 'd' in potentially tricky
places.
|
|
Allow any radix letter from the set [bydtoqhx] to be used either
"Intel-style" (0...x) or "C-style" (0x...). In Intel style, the
leading 0 remains optional as long as the first digit is in the range
0-9.
As a consequence, allow the prefix "0h" for hexadecimal floating
point.
|
|
"Stealth whitespace" makes it harder to read diffs, and just generally
cause unwanted weirdness. Do a source-wide pass to get rid of it.
|
|
- Allow underscores as group separators in numbers, for example:
0x1234_5678 is now a legal number. The underscore is just ignored,
it adds no meaning.
- Recognize dotless floating-point numbers, such as "1e30". This
entails distinguishing hexadecimal numbers in the scanner, since
e.g. 0x1e30 is a perfectly legitimate hex constant.
|
|
'd', 't' and 'y' now recognized as radix suffixes.
|