The logic in is_suppressed_warning() was severely wrong, which would
cause a lot of legitimate warnings to be suppressed while some
warnings would be duplicated.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
There is no need to hide this structure into a type.
The former preproc_ops is a way more descriptive.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This allow us to write the whole expressions
on section alignments, such as
align 0xa+6
or whatever math. Should be a way more convenient
than hardnumbers scheme we had.
Reported-by: Frank Kotler <fbkotler@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
__OUTPUT_FORMAT__ must consist of shortname of output format
or its alias, otherwise userspace ABI gets broken.
For example source code still can refer to __OUTPUT_FORMAT__=elf,
instead of __OUTPUT_FORMAT__=elf32.
BR3246990
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Two fixes:
1. Optimization of [bx+0xFFFF] etc
0xFFFF is an sbyte under 16-bit semantics,
so make sure to check it right.
2. Don't optimize displacements in -O0
Displacements that fit into an sbyte or
can be removed should *not* be optimized in -O0.
Implicit zero displacements are still optimized, e.g.:
[eax] -> 0 bit displacement, [ebp] -> 8 bit displacement.
However explicit displacements are not optimized:
[eax+0] -> 32 bit displacement, [ebp+0] -> 32 bit displacement.
Because #2 breaks compatibility with 0.98,
I introduced a new optimization level: -OL, legacy.
Make -Ox the default; it's the optimization level expected by most
users, and it is clearly still causing confusion that it has to be
specified manually.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Distinguish the case of no directive present (D_none) from the case of
an unknown specified directive (D_unknown). This is reflected in
different error messages.
Furthermore, change the special case symbols to lower case in case we
ever have a directive called [none] or [unknown].
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
A number of strings are broken by nindent passed over the nasm.c.
Though the compiler doesn't care about this fact it's really
unpleasant to have a string split at "dot" symbol.
Lets restore it in a sake of readability.
(No change on binary level)
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Instead of manipulating stdscan buffer pointer directly
we switch to a routine interface.
This allow us to unify stdscan access: ie caller should
"talk" to stdscan via stdscan_get/set routines.
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>
If [DEBUG id] has id longer then 80 symbols (well, 79 actually plus
EOS) then stack will be just overwritten.
Fix it with explicit check for identifier being too long.
Based on an initial version by Cyrill Gorcunov <gorcunov@gmail.com>.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
"Optimise" (and other -ise words) is en_GB, "optimize" (and other
"-ize" words) is en_US. Stick to en_US since that is what we seens to
be using more already.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
We only ever invoked the preprocessor with fixed values for efunc and
evalfunc, so call nasm_error() and evaluate() directly.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
We never invoked the parser with anything but the default definitions
for evaluate and efunc. Unlike the backend, though, we sometimes
invoke parse_line() with redefine_label() instead of define_label().
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
We never set ofmt and errfunc to anything but the global values.
Dropping them from the label definition function command line
simplifies the code.
Signed-off-by: H. Peter Anvin <hpa@zytor.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>
Before checkin aeb0e0e9f1 we would only
invoke ofmt->symdef() for a common variable during pass 2 if that
variable had "special" in the declaration. That checkin
unintentionally changed that behavior.
That doesn't mean that the pre-existing behavior is right, but this
should at least fix the resulting regressions. This really warrants
more investigation.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Hash all directives, even the ones that are backend-specific,
and instead pass the backend an already-parsed directive number.
Furthermore, unify null functions across various backends.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
We fopen() the output file in common code but fclose() it in the
backend. This is bad for a variety of reasons:
1. it is generally an awkward interface to change ownership.
2. we should use ferror() to test for write errors, and that is
better done in common code.
3. it requires more code.
4. we still need to fclose() in common code during error handing.
Thus, move the fclose() of the output out of the backends, and add
fflush() so we can test ferror() on output.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Instead of removing the list file on error, keep the list file and
include the errors in the list file. This makes it actually possible
to debug things that involve deep macro recursion, where the line
number is pretty much meaningless.
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>
Allow the backend to specify that an output format is either text or
binary. For future uses, define this as a flag word so we can define
other flags in the future if it would make sense.
Currently, the ieee and dbg formats are text; all the others are
binary.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>