Commit Graph

4339 Commits

Author SHA1 Message Date
H. Peter Anvin (Intel)
ce19a52a34 Define and use offsetin() instead of offsetof()
New macro which defines the offset on an object rather than a
type. This macro, as far as I know, ought to be fully portable, unlike
the fallback version of offsetof().

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-14 00:27:59 -08:00
H. Peter Anvin (Intel)
374312cde4 strlist, warnings: improve strlist, buffer warnings until error
Make strlist_free() take a pointer to a pointer, so we can set it to
NULL.

Buffer warnings on a strlist until we either get an error or we are in
pass 2. Hopefully this should let us get rid of a lot of the ERR_PASS*
bullshit, which far too often causes messages to get lost.

asm/labels.c contains one example of a warning that cannot be made
correct with a specific pass number.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-14 00:17:13 -08:00
H. Peter Anvin (Intel)
c5593142f7 hashtbl: fix errors in hash_iterate() and hash_free()
Both of these functions were apparently subtly broken after the revamp
to the new interfaces.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-14 00:10:15 -08:00
H. Peter Anvin (Intel)
628c93f0dc listing: use a non-uniqizing strlist to buffer error messages
Generic code is a wonderful thing...

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 23:06:05 -08:00
H. Peter Anvin (Intel)
6ddc62fbab strlist: make sure strlist_free() works for a non-uniqizing list too
We can't rely on hash_free_all() when using a non-uniqizing list.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 22:59:50 -08:00
H. Peter Anvin (Intel)
7dc5b23920 configure: make section garbage collect the default
Section garbage collect really is quite useful, and it makes managing
library source code management a little bit less stressful. It has
been used by the official builds for a while now, turn it on by
default.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 22:51:22 -08:00
H. Peter Anvin (Intel)
7bb13eac11 strlist: can be unique or not, add printf functions
Make it a selectable option at allocation time if a strlist should
contain only unique strings or not. If not, we omit the hash table and
strlist_find() will not do anything.

Add printf()-style functions to a strlist.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 22:48:14 -08:00
H. Peter Anvin (Intel)
be99ebd656 assemble.c: capitalize LOCK prefix
LOCK is a keyword and not a descriptive term here, capitalize it.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 22:12:37 -08:00
H. Peter Anvin (Intel)
4229317a5f Merge branch 'mkwarnings'
Resolved conflicts:
	asm/nasm.c

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 22:10:25 -08:00
H. Peter Anvin (Intel)
0fca7de45d Merge remote-tracking branch 'origin/nasm-2.14.xx' 2018-12-13 22:09:08 -08:00
H. Peter Anvin (Intel)
db72dc0684 asprintf: add "axprintf" functions that allocate extra storage
Add a set of variants on the asprintf functions, "axprintf", which
allocate extra storage for metadata at the head of the allocated
buffer.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 22:07:31 -08:00
H. Peter Anvin (Intel)
e3b4332643 asprintf: actually include asprintf.c
File missing from earcier checkin...

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 21:56:41 -08:00
H. Peter Anvin (Intel)
723ab481a6 warnings: define warning classes at point of use
It is extremely desirable to allow the user fine-grained control of
warnings, but this has been complicated by the fact that a warning
class has had to be defined in no less than three places (error.h,
error.c, nasmdoc.src) before it can be used in source code. Instead,
use a script to define these via magic comments at the point of use.

This hopefully will encourage creating new classes as needed.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 21:53:31 -08:00
H. Peter Anvin (Intel)
190e846563 errors: correct message saying -w+error= ... is in use when it is not
Correct the test for when -w+error= is the correct thing to print.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 21:45:59 -08:00
H. Peter Anvin (Intel)
6bde2ed880 errors: change the severity parameter from "int" to "errflags"
Change the severity parameter to the error function from "int" to an
unsigned typedef, currently uint32_t.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 19:42:38 -08:00
H. Peter Anvin (Intel)
9f89eb38fc Merge remote-tracking branch 'origin/master' into mkwarnings 2018-12-13 19:18:49 -08:00
H. Peter Anvin (Intel)
26572c6e37 warnings: change WARN_MNP -> WARN_MACRO_PARAMS
This one got missed during constant name conversion. Make the
constants match the options.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 16:51:45 -08:00
H. Peter Anvin (Intel)
152aadef66 NASM 2.14.01rc4 2018-12-13 16:45:08 -08:00
H. Peter Anvin (Intel)
78e39ace4b errfile.c: add file missing from previous checkin
File was missing from checkin

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 16:44:35 -08:00
H. Peter Anvin (Intel)
df2195b6a9 Merge remote-tracking branch 'origin/nasm-2.14.xx'
Resolved Conflicts:
	Makefile.in
	Mkfiles/msvc.mak
	Mkfiles/openwcom.mak
	asm/nasm.c
	nasmlib/alloc.c

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 16:43:43 -08:00
H. Peter Anvin (Intel)
3c896de5a3 warnings.pl: script to harvest warnings directly from the source
This will make it a lot easier to create new warning categories by
inserting a block comment directly in the source code near where the
warning is used.

This block comment should look like:

     /*
      *!warning-name {on|off|err} this is a warning
      *!
      *! needs a help text.
      */
      nasm_warnf(WARN_WARNING_NAME, ...);

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 16:33:39 -08:00
H. Peter Anvin (Intel)
3b91f4c117 malloc: handle potential infinite loop in nasm_alloc_failed()
It is possible on memory exhaustion that nasm_fatal() might cause
another allocation error, thus calling nasm_alloc_failed() again. If
we find us in nasm_alloc_failed() for a second time, try to get a
message out and then call abort().

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 13:55:25 -08:00
H. Peter Anvin (Intel)
fef75c265a warnings: Make WARN_ constants consistent with -w options
Not only does this make it consistent, but allows for automation.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 18:13:47 -08:00
H. Peter Anvin (Intel)
8e08fb6da7 Merge remote-tracking branch 'origin/nasm-2.14.xx'
Resolved Conflicts:
	asm/assemble.c
	asm/directiv.c
	asm/error.c
	asm/float.c
	asm/labels.c
	asm/listing.c
	asm/nasm.c
	asm/parser.c
	asm/preproc.c
	asm/stdscan.c
	include/error.h
	output/outelf.c
	version

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 18:05:52 -08:00
H. Peter Anvin (Intel)
df4d342599 warnings: rename ERR_WARN_* to WARN_*
The prefix ERR_WARN_ is unnecessarily long and may be a disincentive
to create new warning categories. Change it to WARN_*, it is still
plenty distinctive.

This is equivalent to nasm-2.14.xx checkin 77f53ba6d4.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 17:48:38 -08:00
H. Peter Anvin (Intel)
51222ab69e NASM 2.14.01rc3 2018-12-12 17:44:19 -08:00
H. Peter Anvin
e2f5edbb3a error: new flag ERR_HERE
ERR_HERE is used to mark messages of the form "... here" so that we
can emit sane output to the list file with filename and line number,
instead of a nonsensical "here" which could point almost anywhere.

This patch contains some changes from the one in the master branch to
make the code cleaner.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-12 17:43:25 -08:00
H. Peter Anvin
c0b32a3650 errors: unify nasm_verror_{gnu,vc} and remove some ERR_NOFILE
The differences between nasm_verror_{gnu,vc} are a short handful of
strings, so unify them. Remove some additional ERR_NOFILE that are not
necessary.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-12 17:16:02 -08:00
H. Peter Anvin
dea7f4733f error: remove unused ERR_TOPFILE
The flag ERR_TOPFILE was not used anywhere, remove it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-12 17:00:19 -08:00
H. Peter Anvin (Intel)
950dee9edc BR 3392535: warning on redefine, promote define-on-pass2 to error
If we redefine consistently, make it a suppressed-by-default warning.
If we end up doing the define on pass 2, promote that to a
default-error warning; using a default-error warning allows the user
to demote it should they so wish.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Requested-by: C. Masloch <pushbx@38.de>
2018-12-12 16:49:07 -08:00
H. Peter Anvin (Intel)
46016cb368 listing.c: handle multiple error messages on a single line
We may produce an arbitrary number of error messages on a single line;
include all of them in the list file.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 16:47:04 -08:00
H. Peter Anvin (Intel)
bdf017c89c warnings: WARN_OTHER is now "above", not "below"
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 16:12:36 -08:00
H. Peter Anvin (Intel)
eb48c1191d warnings: make it possible for a warning to default to an error
This allows us to do soft-migration of warnings to errors; they will
now be nonfatal errors by default, but gives the user the option to
demote them.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 16:11:08 -08:00
H. Peter Anvin (Intel)
93367ea97b warnings; move WARN_OTHER to the end; allow non-warnings to be suppressed
Putting WARN_OTHER at the end of the list creates a number of
advantages and simplifications:

1. It is more user friendly! It is far more of a logical location for
   the default case to be at the end of the printed list.
2. The value 0 can be used in a number of places to indicate a
   non-suppressible event. By having warning_state[0] always contain
   WARN_ST_ENABLED, we can always do the table lookup, even.
3. It means non-warnings (except fatal/panic) can now be conditioned
   on warning states. In those cases, WARN_*, including WARN_OTHER,
   can be added to the mask for any category. This is especially
   useful for notes.

The only downside is that we have to explicitly detect the case where
we have ERR_WARNING but no WARN_ flag. This is a trivial test.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 15:58:32 -08:00
H. Peter Anvin (Intel)
64b56eaa39 configure: add -Wno-shift-negative-value
Shifting negative values is undefined in standard C, but we have tons
of dependencies that signed arithmetic is 2's-complement in the code
anyway, and on gcc-like compilers we pass the -fwrapv option to
indicate exactly that. Therefore, this is not a valid warning in our
case and should be suppressed.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 15:56:28 -08:00
H. Peter Anvin (Intel)
77f53ba6d4 warnings: rename ERR_WARN_* to WARN_*
The prefix ERR_WARN_ is unnecessarily long and may be a disincentive
to create new warning categories. Change it to WARN_*, it is still
plenty distinctive.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 14:38:50 -08:00
H. Peter Anvin (Intel)
eb5b3ae0d3 nasmlib: Add nasm_(v)asprintf()
Add a version of (v)asprintf(), which allocates a string on the
heap. Unlike the standard version of (v)asprintf(), we return the
pointer; if one wants the length of the string then one can simply use
the %n pattern.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 14:34:34 -08:00
H. Peter Anvin (Intel)
64471097ca strlist: merge the strtbl and strlist interfaces
The currently-unused strtbl was basically a slightly different version
of strlist, with the find and linearize capabilities. Merge these two
together by augmenting strlist to have the same capabilities.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-11 13:37:32 -08:00
H. Peter Anvin (Intel)
ebb05a0e5f hashtbl: revamp the hash table interface, support binary keys
Add binary key support to the hash table interface. Clean up the
interface to contain less extraneous crud.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-11 13:18:49 -08:00
H. Peter Anvin
ddb290681e error: new flag ERR_HERE
ERR_HERE is used to mark messages of the form "... here" so that we
can emit sane output to the list file with filename and line number,
instead of a nonsensical "here" which could point almost anywhere.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-11 00:06:29 -08:00
H. Peter Anvin
026b62f264 srcfile: simplify and make most functions inline
Simplify the srcfile subsystem by making it official that any pointer
passed to src_get() needs to have been obtained from the srcfile
subsystem itself.

Move a lot of the srcfile operations into inline code; often they
amount to a single machine instruction...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-10 23:28:01 -08:00
H. Peter Anvin
1aa794527f Move srcfile.c to asm/
srcfile.c is not used by anything outside asm/, so move it there.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-10 23:03:04 -08:00
H. Peter Anvin
77016c8ff4 errors: unify nasm_verror_{gnu,vc} and remove some ERR_NOFILE
The differences between nasm_verror_{gnu,vc} are a short handful of
strings, so unify them. Remove some additional ERR_NOFILE that are not
necessary.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-10 22:46:30 -08:00
H. Peter Anvin
5bdc235e02 error: remove unused ERR_TOPFILE
The flag ERR_TOPFILE was not used anywhere, remove it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-10 22:46:28 -08:00
H. Peter Anvin
c55702ecb8 nasm.c: use error helpers, remove ERR_NOFILE
The current error handlers are much smarter about missing filenames,
and thus using ERR_NOFILE just makes it harder for the programmer.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-10 22:46:26 -08:00
H. Peter Anvin
a7bc437eab asm/labels.c: use error helpers
Replace explicit calls to nasm_error() with error helpers.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-10 22:46:24 -08:00
H. Peter Anvin
d351efc97d error: add nasm_note() helper, clean up helper generation
It is fairly easy to more compactly create error helpers since we are
using preprocessor hacks anyway, so do exactly that.

Create nasm_note() helpers for the new NOTE severity class.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-10 22:46:20 -08:00
H. Peter Anvin
36e3c70790 Merge remote-tracking branch 'origin/nasm-2.14.xx'
Resolved Conflicts:
	asm/labels.c
	include/error.h
	version
2018-12-10 21:28:59 -08:00
H. Peter Anvin
54aac9d3c1 errors: add ERR_NOTE and a default clause to error disposition
ERR_NOTE has no action. Have a default clause as well, for good
measure.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-10 21:14:57 -08:00
H. Peter Anvin
48a810fc19 NASM 2.14.01rc2 2018-12-10 13:38:11 -08:00