Commit graph

145 commits

Author SHA1 Message Date
H. Peter Anvin
79561027a0 Make limits 64 bits, add globallines limit to configurable limits
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>
2018-06-15 17:57:15 -07:00
H. Peter Anvin
14a10935f7 Merge commit '7daa26f9ba3ca45813d16ce540564448c13b16fa' into nasm-2.14.xx
Merge in some warning workarounds/possible bugs discovered by a recent
gcc.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-06-15 17:25:57 -07:00
H. Peter Anvin
46c839a03d labels: allocation of a segment number counts as a change
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>
2018-06-14 20:00:07 -07:00
H. Peter Anvin
af5f918a92 Don't keep assigning segment numbers to EXTERN or COMMON
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>
2018-06-14 19:53:45 -07:00
H. Peter Anvin
29695c85fb labels: add a subsection field available for backend use
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>
2018-06-14 17:04:32 -07:00
H. Peter Anvin
13587802fe segalloc: DO NOT reset segment numbers
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>
2018-06-14 16:42:03 -07:00
H. Peter Anvin
c805fd774d Fix parsing of long options; actually warn on bad limit
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>
2018-06-12 14:23:05 -07:00
H. Peter Anvin
987dc9c9db Make any execution limit configurable, add eval limit
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>
2018-06-12 13:54:42 -07:00
H. Peter Anvin
734824823e Unbreak special segment symbols, unbreak COMMON
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>
2018-06-11 14:54:14 -07:00
H. Peter Anvin
0599034321 Add --pragma and --before option; make --include = -P
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>
2018-06-11 13:32:42 -07:00
Cyrill Gorcunov
a7f318c307 directive: Make cpu directive case insensitive back again
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>
2018-06-07 00:06:58 +03:00
H. Peter Anvin
7daa26f9ba gcc: fix mistakes discovered by recent gcc
Recent versions of gcc issue a couple of warnings, which may be real
bugs.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-06-02 23:48:16 -07:00
H. Peter Anvin
3cb9068ee0 asm/directiv.c: fix bug in perm_alloc()
Fix dumb thinko in perm_alloc().

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-01 21:05:45 -07:00
H. Peter Anvin
98578071b9 Cleanup of label renaming infrastructure, add subsection support
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>
2018-06-01 18:06:25 -07:00
H. Peter Anvin
892c4818ce Add support for backend-defined subsections and label hacks
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>
2018-05-30 14:48:18 -07:00
H. Peter Anvin
b7136487bd pragma.c: make the generic "output" and "debug" pragma namespaces work
"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>
2018-05-30 14:42:06 -07:00
H. Peter Anvin
6d36d8684c Fix implicit fallthrough that trips -Werror
-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>
2018-05-08 12:45:00 -07:00
Chang S. Bae
f0ceb1e122 assemble: Check global line limit
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>
2018-05-05 23:44:33 +03:00
Chang S. Bae
427d8e3e57 output: macho -- Avoid conversion of addresses to RAWDATA
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>
2018-05-05 23:44:33 +03:00
Cyrill Gorcunov
72fd205bcf Revert "Use fallthrough() to placate compiler"
This reverts commit 8a7c6009fb.
2018-02-25 22:25:07 +03:00
Cyrill Gorcunov
8a7c6009fb Use fallthrough() to placate compiler
https://bugzilla.nasm.us/show_bug.cgi?id=3392465

Reported-by: Ozkan Sezer <sezeroz@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-25 17:21:54 +03:00
Cyrill Gorcunov
8a231080e0 get_cpu: Fix a7ecf2646d
The call to iflag_clear_all has been occasionally dropped,
bring it back.

https://bugzilla.nasm.us/show_bug.cgi?id=3392466

Reported-by: sezeroz@gmail.com
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-25 13:25:19 +03:00
H. Peter Anvin
281f5bd92c Merge branch 'master' of ssh://repo.or.cz/srv/git/nasm 2018-02-22 14:53:46 -08:00
H. Peter Anvin
6686fc627e Introduce cold function attribute
Attribute to deemphasize certain code paths.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-02-22 14:52:50 -08:00
H. Peter Anvin
3366e31b8a asm: allow abort on panic to be specified at runtime
New option --abort-on-panic to make debugging easier.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-07 14:14:36 -08:00
H. Peter Anvin
1b53750430 Merge tag 'nasm-2.13.03'
NASM 2.13.03

Resolved Conflicts:
	include/iflag.h
	version
	x86/insns-iflags.ph

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-07 13:51:54 -08:00
H. Peter Anvin
a7ecf2646d iflag: automatically assign values, saner handling of CPU levels
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>
2018-02-06 14:43:07 -08:00
H. Peter Anvin
81b62b9f54 Eliminate filename length restrictions, remote ofmt->filename()
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>
2017-12-20 13:38:20 -08:00
H. Peter Anvin
dcbaf677d4 error: add --enable-panic-abort config options
For debugging purposes, make it possible to force calling abort() on
ERR_PANIC.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-12-20 12:10:33 -08:00
H. Peter Anvin
7a6bf74d02 error: add ERR_TOPFILE
Add ERR_TOPFILE, for cases where displaying the current file and line
are completely inappropriate.  Instead, display the main input file,
or, if not available, the output file.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-12-20 12:10:13 -08:00
H. Peter Anvin
883985def5 nasm.c: better handling of errors without a file without ERR_NOFILE
We have hardcoded ERR_NOFILE in a number of places which really should
not need them, and it represents loss of information.  Instead, be
robust in the handling either of no filename or no line number.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-12-20 11:32:39 -08:00
H. Peter Anvin
ece809789e Merge remote-tracking branch 'origin/nasm-2.13.xx'
Resolved conflicts:
	version

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-01 10:37:18 -07:00
Cyrill Gorcunov
9b7ee09abf prepoc: Fix heap-buffer-overflow in detoken
Just make sure we've a data to process.

https://bugzilla.nasm.us/show_bug.cgi?id=3392424

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-10-22 21:42:59 +03:00
Cyrill Gorcunov
6f8109ebf1 preproc: Fix SIGSEGV if not data provided for implicit pasting
https://bugzilla.nasm.us/show_bug.cgi?id=3392423

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-10-22 21:26:36 +03:00
Cyrill Gorcunov
7524cfd914 preproc: Fix sigsegv in find_cc
For specially formed code we can have skip_white_
to end up with nil pointer which should be taken
into account.

https://bugzilla.nasm.us/show_bug.cgi?id=3392435

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-10-22 19:01:16 +03:00
Cyrill Gorcunov
59ce1c67b1 peproc: Fix sigsevg in smacro expansion
In case if smacro is called with inapropriate
number of arguments exit early. Actually we have
to handle this situation more gracefully but
this requires a way more efforts than two
line patches (need to refactor macro expansion).

https://bugzilla.nasm.us/show_bug.cgi?id=3392431

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-10-22 18:54:20 +03:00
Cyrill Gorcunov
c9244eaadd prepoc: mmacro -- Don't left nparam_max less than nparam_min
Otherwise we hit nil dereference in best case.

https://bugzilla.nasm.us/show_bug.cgi?id=3392436

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-10-22 15:25:48 +03:00
Cyrill Gorcunov
3144e84add preproc: Don't access offsting byte on unterminated strings
https://bugzilla.nasm.us/show_bug.cgi?id=3392446

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-10-22 10:50:55 +03:00
H. Peter Anvin
89215e9e37 Remove duplicate warnings for immediate overflow
For immediates, we had one overflow test in the bytecode interpreter
(in most cases via warn_overflow_opd()) and one in out(); this meant
we got two warnings instead of one every time.  Replace with only the
one in out().

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-10-11 13:14:01 -07:00
H. Peter Anvin
94ead27971 BR 3392437: Fix diagnostic for negative value in TIMES
Issue a diagnostic and don't panic for invalid TIMES values.

Reported-by: C. Masloch <pushbx@38.de>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-09-27 15:22:23 -07:00
H. Peter Anvin
e800127a46 BR3392439: make sure to update globalbits if appropriate
For some output types, the bit size, globalbits, follow the section
(segment); make sure we actually update it!

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-09-27 14:22:16 -07:00
H. Peter Anvin
0a126062fb ilog2(): inline functions if practical
For many (most?) targets these will be very small functions, so inline
them.  However, just in case make these external library functions.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-09-27 13:34:42 -07:00
H. Peter Anvin
fbce0bfb4e Merge remote-tracking branch 'origin/nasm-2.13.xx'
Resolved Conflicts:
	asm/directiv.dat
	asm/preproc.c
	misc/omfdump.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-08-16 22:41:40 -07:00
H. Peter Anvin
3e30c32812 nasm: when using -MW, quote filenames containing &
When using the -MW option, double-quote filenames containing &.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-08-16 22:20:36 -07:00
H. Peter Anvin
427b9cae8b nasm: when using -MW, enclose whitespace in double quotes
When using the -MW option, enclose whitespace-containing filenames in
double quotes.  There are probably quite a few other things we ought
to know how to do...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-08-16 22:17:51 -07:00
H. Peter Anvin
f05034fd58 nasm: when generating null targets for WMAKE, add %null
WMAKE wants an explicit %null directive; empty is not ok.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-08-16 22:09:44 -07:00
H. Peter Anvin
ff04a9ffe8 BR 3392421: consider mode decorators in instruction matching
We have to consider mode decorators when considering instruction
matching, otherwise we end up falling back to VEX encoding if it is
available, losing the decorator.  See BR 3392421.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-08-16 21:48:52 -07:00
H. Peter Anvin
77c9bf6cd8 nasm: new option -MW to emit Watcom-style Makefile rules
Allow NASM to generate Watcom-style Makefile dependencies, in addition
to the default POSIX-style Makefile dependencies.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-08-16 21:14:33 -07:00
H. Peter Anvin
97fda4ce6e asm/preproc.c: use nasm_add_string_to_strlist()
Use nasm_add_string_to_strlist() to avoid a memory leak.
nasm_add_to_strlist() requires that the caller manages the string
being added or not.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-08-16 15:52:51 -07:00
H. Peter Anvin
a771be85f4 outobj: emit file dependency information
Some OMF toolchain can make use of file dependency information
embedded in the object files.  As implemented here, we don't try to
absolutize the filenames, as that prevents moving around trees and is
OS-dependent.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-08-16 15:00:38 -07:00