Create our own ctype table where we can do the tests we want to do
cheaply, instead of calling ctype functions and then adding additional
tests all over the code.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Replace all the is*() macros with inline functions. Disallow '?' in
identifiers unless we are in TASM mode.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
is allowed in
When we are running regression tests we compare binary
forms and the strings better to be the constants to not
trigger false positives.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Use a hash table to enforce uniqueness in a string list. It is still
an ordered list, however, and can be walked in insertion order.
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>
So we can test for out of bound access and make
helpers safe to use.
https://bugzilla.nasm.us/show_bug.cgi?id=3392447
Reported-by: Jun <jxx13@psu.edu>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
While configuring optimization in a level is conventional,
a certain optimization tends to conflict with some pragma.
For example, jump match conflicts with Mach-O's
"subsections-via-symbols" macro.
This configurability will workaround such conflicts.
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Add a default-off warning for phase error in pass 1. This is default
off because of the lateness in the release cycle, but cases where we
have such instability should be investigated further. For now, the
warning is here so we can debug these problems in the field.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.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>
Support the +n syntax for multiple contiguous registers, and emit it
in the output from ndisasm as well.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
There are cases where we may want to implement generic pragmas, while
still make them selective based on output and/or debug formats.
Initially, use this for the prefix/suffix options.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: Chang Seok Bae <chang.seok.bae@intel.com>
Add support for signed shifts. The operators are <<< and >>>,
although the former is (inherently) idntical to <<.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Nearly all instances of nasm_fatal() and nasm_panic() take a flags
argument of zero. Simplify the code by making nasm_fatal and
nasm_panic default to no flags, and add an alternate version if flags
really are desired. This also means that every call site doesn't have
to initialize a zero argument.
Furthermore, ERR_NOFILE is now often not necessary, as the error code
will no longer cause a null reference if there is no current
file. Therefore, we can remove many instances of ERR_NOFILE which only
deprives the user of information.
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>
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 the RAA infrastructure a bit cleaner, make it support 64-bit
indicies, and reduce the memory overhead of a sparse or small RAA --
the old code would allocate a *minimum* of 256K for each RAA. The new
code reduces that to 16K, and will not mandatorily allocate an entry
in the zero position.
The new shift, 11, was chosen so that a 32-bit RAA value will need 3
layers and a 64-bit value 6 layers, without excessive waste.
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>
We are not supposed to reset the segment numbers; this was an
attempted fix for a convergence bug that didn't actually exist. The
backend is required to return the same segment number for the same
segment; if it does not, the front end will not converge, but that is
in fact the correct behavior.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
RAAs can, and should be, usable for storing pointers as well as
integers. In reality it is exactly the same code, but make it explicit
by having different entry points. In the actual RAA the data is
stored as a union, which in practice will not occupy any more space
than the existing code.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Make any "deadman"-style execution limit configurable on the command
line (--limit-foo) or via a pragma (%pragma limit foo).
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Recent changes broke:
1. Backend-provided special segments, due to seg_alloc() getting
reset.
2. COMMON; the old code would pass size in the "offset" *without*
setting it in the label structure. Containing all this information
in the label structure requires another field.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Add --pragma to add pragmas on the command line; --before option to
add *any* statement on the command line, and add --include as an alias
for -P for familiarity with other toolchains.
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>
Simplify the nasm_malloc() code by moving the pointer check into a
common subroutine.
We can now issue a filename error even for failures like malloc().
Add support for the gcc sentinel attribute (verify that a list ends
with NULL).
Add a handful of safe_alloc attributes.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Without relocation, the linker may do erroneous dead strip.
For the relocation, the conversion of addresses to RAWDATA
should be avoided for Mach-O.
https://bugzilla.nasm.us/show_bug.cgi?id=3392469
Reported-by: Andrew Fish <afish@apple.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Some older versions of gcc (gcc 4.2.1 at least) produce a warning,
promoted to error, on C99 inlines. Do some work to figure out if we
need to fall back to GNU inline syntax.
Fix some issues with GNU inline syntax.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
It not only reads static variable but writes it back as well.
https://bugzilla.nasm.us/show_bug.cgi?id=3392461
Reported-by: Michael Šimáček <msimacek@redhat.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Automatically assign values to the instruction flags; we ended up with
a case where pushing flags into the next dword caused comparison
failures due to other places in the code explicitly comparing
field[3].
This creates necessary defines for this not to happen; it also cleans
up a fair bit of the iflag code.
This resolves BR 3392454.
Reported-by: Thomasz Kantecki <tomasz.kantecki@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>