Before the commit 81b62b9f54
we've been always putting -E,-e results into stdout if no
output file provded. So bring this backward compatibility
back.
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>
Formatting errors -- syntax errors -- are errors, no matter which pass
they end up in. ERR_PASS1 is just plain crazy: if we end up with a
formatting error on the code-generation pass, we are in a world of
hurt.
Defer warnings to the code-generation pass; that's the pass which
matters value-wise, and that way we get the warnings in the list file,
too.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
When we suffer an underflow that cross limb boundaries, it is possible
to end up with a stack underflow. Put in an explicit check for this
case (the mantissa will be zero in this case.)
https://bugzilla.nasm.us/show_bug.cgi?id=3392445
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
diff --git a/asm/float.c b/asm/float.c
index dcf69fea..2965d3db 100644
--- a/asm/float.c
+++ b/asm/float.c
@@ -608,6 +608,8 @@ static void ieee_shr(fp_limb *mant, int i)
if (offs)
for (j = MANT_LIMBS-1; j >= offs; j--)
mant[j] = mant[j-offs];
+ } else if (MANT_LIMBS-1-offs < 0) {
+ j = MANT_LIMBS-1;
} else {
n = mant[MANT_LIMBS-1-offs] >> sr;
for (j = MANT_LIMBS-1; j > offs; j--) {
In order for the machinery that deduces memory operand sizes when they
are not provided to work correctly, we need to make sure that
MERR_OPSIZEMISSING is only issued by matches() as the last resort;
that way all other error conditions will have been filtered out and we
know at the very end if we have exactly one option left.
This is a partial revert of cd26fccab4,
but does not affect the functionality introduced by that patch.
Reported-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.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>
We may not even have the most basic stabilization done unless we run
at least two optimization passes, e.g. in the case of subsections.
However, we cannot run more than one stabilization pass (pass0 == 1);
for one thing we'll call ofmt->symdef() multiple times on the same
symbol, which is not allowed. If we haven't achieved stability by the
time we decide to run a stabilization pass, plod on and hope for the
best.
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>
We can be in absolute space and still end up with segment-relative
references. This is in fact the meaning of absolute.segment. Make
sure we define the labels appropriately.
Reported-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
If we define a label which was previously declared EXTERN, then
automatically treat is as GLOBAL.
Previously, we would fail to converge and loop forever, which is
obviously not what we want. This is more user-friendly anyway.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
If we have overridden EXTERN, then we should not call define_label()
on it again. Return a fail status from declare_label(), indicating
that the type declaration failed, but of course we don't print an
error message.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The prefix and suffix options call perm_alloc() in labels.c, which is
not available until init_labels() have run. There is no reason not to
call init_labels() early.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
..@ labels (macro-local) are NASM specials, although not "magic": they
are explicitly defined to not preturb the local label base name.
However, they return false for both islocal() and ismagic(), so we
need to add a new function containing the correct test for when the
local label base should be advanced.
Reported-by: <balducci@units.it>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Bae, Chang Seok <chang.seok.bae@intel.com>
ofmt->symdef() always takes the mangled label name, make sure we
actually do the correct thing even for forward fixups.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.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>
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>
If we allocate a new segment number, that has to cause
global_offset_changed to be incremented. Thus, we should not update
lptr->defn.segment until that would ordinarily be done.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
If a symbol is EXTERN or COMMON, then we should not keep assigning it
new segment numbers over and over. Instead, change the label code so
that it assignes a new segment value if and only if one has not been
assigned before.
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>
Fix the parsing of long options (arguments with = broke things.)
Actually issue a warning if we specify a wrong limit on the command
line.
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>
During code suffle we occasionally made cpu directive to
take letter case into account despite the documentation.
https://bugzilla.nasm.us/show_bug.cgi?id=3392491
Reported-by: Rebecca Cran <rebecca@bluestop.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.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>
"output" and "debug" are supposed to redirect to the current output
and debug formats. Fix it so it actually does.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-Werror now trips on implicit fallthroughs. There is also at least one
that probably should not be, although it appears to be harmless.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Without the limit, the while loop opens to semi-infinite
that will exhaustively consume the heap space. Also, the
index value gets into the garbage.
https://bugzilla.nasm.us/show_bug.cgi?id=3392474
Reported-by : Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.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>
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>
Get rid of remaining dependencies on FILENAME_MAX, which ought to have
been removed a long time ago.
Remove ofmt->filename(); all implementations pretty much do the same
thing and there is absolutely no reason to duplicate that
functionality all over the place.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>