Commit graph

4569 commits

Author SHA1 Message Date
Cyrill Gorcunov
4c3798b7e6 BR 3392696: nasm_quote -- fixup callers
In 41e9682efe we've
changed the nasm_quote arguments still not all callers
were converted which could lead to nil dereference.

[hpa: no need to call strlen() for the asm/preproc.c chunk]

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2020-07-12 06:06:02 -07:00
H. Peter Anvin
6a9d1e56c6 Revert "BR 3392696: nasm_quote -- fixup callers"
This reverts commit 6c300aa488.

Will apply a modified version from the nasm-2.15.xx branch instead.
2020-07-12 06:04:48 -07:00
H. Peter Anvin
b9a44fcdf0 autogen.sh: don't rely on sed -r
Not all versions of sed has "sed -r", so change it to use basic
regular expressions. Furthermore, not all systems support \| in basic
regular expressions, to work around it by converting the script names
explicitly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2020-07-12 06:03:58 -07:00
H. Peter Anvin
d831915543 preproc: add %is...() function-like macros
Add the first "preprocessor functions". These are simply "magic"
single-line macros with a suitable expansion function. The first
application is functions equal to the %if directives, e.g.
%ifdef blah == %if %isdef(blah) except can be used anywhere (not just
in %if statements like defined() in C.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2020-07-12 06:03:58 -07:00
Cyrill Gorcunov
80e1774b90 travis: weirdpaste -- add nil dereference test
To address BR 3392696

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2020-07-12 14:06:54 +03:00
Cyrill Gorcunov
6c300aa488 BR 3392696: nasm_quote -- fixup callers
In 41e9682efe we've
changed the nasm_quote arguments still not all callers
were converted which could lead to nil dereference.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2020-07-11 19:18:30 +03:00
H. Peter Anvin (Intel)
b14dbb95a1 phash: simplify the code generators
Simplify the code generators by merging the two hash constant arrays
into one. The hash is effectively the same, although the order of the
constants differ (possibly in a way which makes the indexing easier.)
The main difference is the amount of code is necessary to generate
each of the output C files.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-10 19:26:52 -07:00
H. Peter Anvin (Intel)
10c9aa37a4 preproc: drop preproc_ops
There is only one preprocessor now, so drop the indirection through
preproc_ops.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-10 19:26:44 -07:00
H. Peter Anvin (Intel)
84cf342e38 asm/phash.pl: remove unused script
This script is redundant with the far more capable
nasmlib/perfhash.pl, which is the one invariably used.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-10 19:22:29 -07:00
H. Peter Anvin (Intel)
1cc58533f2 pphash: change UNUSED_HASH_ENTRY to INVALID_HASH_ENTRY
INVALID_HASH_ENTRY is far more expressive...

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-10 01:25:22 -07:00
H. Peter Anvin (Intel)
1593c1dc60 preproc: don't call do_directive recursively
The hacky %arg and %local directives build directives as strings which
they then tokenize and call do_directive() recursively with. Factor
these out and remove the recursion.

It is too bad that %arg and %local didn't include the [] brackets in
the created macros; if so it would have been possible to do something
sane with 64-bit register operands. Sigh.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-10 01:21:44 -07:00
H. Peter Anvin (Intel)
72a555972f error: get rid of ERR_PASS1
ERR_PASS1 only remains in three places:

a. Unterminated %! string, an error
   - Should be signalled no matter which pass it is encountered in
b. Two cases of map file problems in outbin
   - The buffered warning system take care of that issue

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-10 01:10:30 -07:00
H. Peter Anvin (Intel)
fcb3d135ec preproc: a negative number is actually two tokens
A negative number is two tokens: a minus sign and a positive
number. For most uses we still want to generate signed numbers; for
specific uses there might be motivation for an unsigned output, but in
most cases it would be confusing.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-10 01:08:47 -07:00
H. Peter Anvin (Intel)
93dd437ac9 preproc: move reverse_tokens() into define_smacro()
The fact that smac->expansion is stored in reverse order is a detail
of the implementation, and should not be forced on the caller of
define_smacro().

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-10 00:56:03 -07:00
H. Peter Anvin (Intel)
0d17f8a7e6 phash: bloat the hashes somewhat, reducing the likelihood of false positives
Set the hash size scaling constant to 1.6, signifying 3.2 times the
hash load. This both reduces the convergence time and makes it less
likely (< 25%) that a non-entry will require a secondary comparison,
and after all, in most of our use cases non-entries are by far the
more common.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 23:39:58 -07:00
H. Peter Anvin (Intel)
32322a9a93 preproc: get rid of the prepreprocessor and the nop preprocessor
Fold the prepreprocessor and the nop preprocessor into the main
preprocessor. This means handling # cpp-like lines and TASM
compatibility tokens in the preprocessor proper, but that is really
not very hard to do.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 23:34:52 -07:00
H. Peter Anvin (Intel)
c36cdf8a55 Merge remote-tracking branch 'github/debug-macros'
Resolved Conflicts:
	version

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 21:16:49 -07:00
H. Peter Anvin (Intel)
e24b7c3504 Merge remote-tracking branch 'github/nasm-2.15.xx' into debug-macros
Resolved Conflicts:
	asm/assemble.c

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 21:13:50 -07:00
H. Peter Anvin (Intel)
0d4ce8d739 debug: don't call dfmt->linenum without a filename
With -Lb, it is possible that we don't have a filename for the current
code expansion. In that case, suppress calling dfmt->linenum as some
debug backends *really* aren't equipped to handle that case.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 21:10:42 -07:00
H. Peter Anvin (Intel)
79fd2b9645 data: replace data->sign with a flags field
Signed and unsigned are really two flags; might as well allow this
field to contain additional flags.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 20:58:10 -07:00
H. Peter Anvin (Intel)
2f171ddeec debug: invoke dfmt->linenum when the segment number changes
If the segment number changes, we also need to invoke dfmt->linenum(),
as a .nolist macro may end up emitting to more than one section.

This also adds the source location explicitly to the output data
structure; the cost for that is minimal, and will enable a more
sophisticated debug backend to receive the entire data structure in
the future.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 20:06:18 -07:00
H. Peter Anvin (Intel)
771e714c71 changes.src: update 2.15.03 release notes
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 19:41:12 -07:00
H. Peter Anvin (Intel)
3eba084173 NASM 2.15.03rc2 2020-07-09 19:35:22 -07:00
H. Peter Anvin (Intel)
e1f0b35af0 configure.ac: also try -std=c99
If -std=c17 and -std=c11 don't work, try -std=c99 as well.
-std=c90 is unlikely to work because of the requirement for "long
long" on L32 platforms, which isn't likely to be supported on a pure
C90 compiler.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 19:33:26 -07:00
H. Peter Anvin (Intel)
1b9c8ec434 pa_c_typedef.m4: also test for __typeof and __decltype
Some vendors prefer to put underscores just at the beginning.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 19:28:12 -07:00
H. Peter Anvin (Intel)
5c90a7c237 autoconf: use -std=c17 or -std=c11 if available
If the compiler supports it, use -std=c17 or -std=c11. Hopefully, this
will give us more predictable behavior in some cases.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 19:26:27 -07:00
H. Peter Anvin (Intel)
89563d78b2 autoconf: add success/failure code options to PA_ADD_*FLAGS
Allow code to be executed in the success or failure scenatios of
PA_ADD_*FLAGS.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 19:25:41 -07:00
H. Peter Anvin (Intel)
e8d6bbacd4 configure.ac: if we have a C17/C11-compatible compiler, use it
Enable -std=c17 or -std=c11 for compilers that handle them.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 19:12:25 -07:00
H. Peter Anvin (Intel)
abcdf8356a configure.ac: better tests for typeof, snprintf, vsnprintf
With some combinations of options tests for typeof, snprintf, and
vsnprintf end up with warnings promoted to errors, which then trigger
incorrect results for these tests. Move the typeof test to the end,
and write specific tests for snprintf and vsnprintf.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 19:04:28 -07:00
H. Peter Anvin (Intel)
2850da733d vsnprintf.c: fix printing of a size_t variable
printf("%d", <size_t>) is invalid. As this is for legacy compilers,
don't rely on %zu but rather cast to unsigned long long.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 17:44:21 -07:00
H. Peter Anvin (Intel)
f399172a83 assemble: don't pass a NULL filename to dfmt->linenum
Don't pass a NULL filename to dfmt->linenum even if -Lb is in use; it
confuses the heck out of some debug backends.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 10:26:32 -07:00
H. Peter Anvin (Intel)
7501601dbd preproc: pass macro debug information in invocation order
Reverse the invocation lists once each list is complete, so that the
lists passed to the macro backend are in true invocation order.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 10:13:46 -07:00
H. Peter Anvin (Intel)
35ed91f6f8 nasmlib.h: clear up namespace confusion in list_reverse()
list_reverse() used "next" as an argument, while also needing to
refer to the structure field "next". Furthermore, the two temp
variables can be made generic by making them void *, and as this is
not a loop construct this is doable by declaring them inside the macro
loop.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 10:11:38 -07:00
H. Peter Anvin (Intel)
942092e32a macro debug: use rb_search_exact()
We need the exact match in the rbtree for the current section. An
approximate match is not acceptable.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 09:53:49 -07:00
H. Peter Anvin (Intel)
e450e06084 rbtree: add rb_search_exact()
Sometimes we want to search for an exact key only, and reject the case
when tree->key < key. Add rb_search_exact() for this purpose, rather
than forcing the caller to perform the comparison in open code.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 09:51:30 -07:00
H. Peter Anvin (Intel)
68e3802b23 rbtree: add rb_search_exact()
Sometimes we want to search for an exact key only, and reject the case
when tree->key < key. Add rb_search_exact() for this purpose, rather
than forcing the caller to perform the comparison in open code.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 09:49:38 -07:00
H. Peter Anvin (Intel)
50184c26c7 debug: collect macro information for the debug backend
Collect macro call/nesting information for the benefit of the debug
back end. So far, the only backend for which this is provided is the
debug back end, to show what information is present.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 09:28:44 -07:00
H. Peter Anvin (Intel)
2caafadbd0 rbtree: implement rb_first(), rb_last() operations
Add operations to get the first and last entry in the tree,
respectively. Searching for 0 or ~UINT64_C(0) is not sufficient in the
presence of duplicated keys, and is more inefficient anyway.

rb_first() followed by rb_next() until NULL, or equivalently rb_last()
followed by rb_prev() until NULL, can be used to walk the tree in key
order (ascending or descending), including all duplicate key
entries.

Since this is a *threaded* tree now, this walk can safely free entires
as it goes along, as long as the whole tree is destroyed; once any one
entry has been freed, the tree is no longer valid for anything other
than proceeding with the same tree walk.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 09:18:22 -07:00
H. Peter Anvin (Intel)
110e5046c9 rbtree: implement a "threaded LLRB tree"
Change the left-leaning red-black (LLRB) trees into left-leaning
threaded red-black trees. Instead of NULL pointers at leaf nodes, use
the otherwise unused field as a pointer to the lexical predecessor
(left) or successor (right). This allows fast previous/next
interator operation without needing to keep track of the root of the
tree at all times.

The additional metadata that needs to be kept can be done for "free"
simply by changing "bool red" into a flag field.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 09:18:22 -07:00
H. Peter Anvin (Intel)
91bc518895 asm: fix pass_type()
Update the table used by pass_type() to give the name of the pass
type. It was not updated properly after PASS_PREPROC was added.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 09:14:58 -07:00
H. Peter Anvin (Intel)
422c8c4f1e k_test.asm: comment out %pragma list options
Disable the %pragma list options in k_test.asm to avoid nasty
surprises. LISTOPT is -L+ by default and can be overridden on the
command line, so the %pragma is not just unnecessary but problematic.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 09:03:08 -07:00
H. Peter Anvin (Intel)
c341ad7300 rbtree: implement rb_first(), rb_last() operations
Add operations to get the first and last entry in the tree,
respectively. Searching for 0 or ~UINT64_C(0) is not sufficient in the
presence of duplicated keys, and is more inefficient anyway.

rb_first() followed by rb_next() until NULL, or equivalently rb_last()
followed by rb_prev() until NULL, can be used to walk the tree in key
order (ascending or descending), including all duplicate key
entries.

Since this is a *threaded* tree now, this walk can safely free entires
as it goes along, as long as the whole tree is destroyed; once any one
entry has been freed, the tree is no longer valid for anything other
than proceeding with the same tree walk.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 09:01:34 -07:00
H. Peter Anvin (Intel)
dacee5a5f5 config/unconfig.h: still needs to be in the repository
config/unconfig.h is build from config/config.h.in, but the latter
doesn't exist in the repository either. config/unconfig.h is cleaner,
so check it back into the repository, to let non-Unix-sh people be
able to build from the repo.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 08:53:28 -07:00
H. Peter Anvin (Intel)
8f385ec6a0 test/Makefile: allow overriding -L+
Add a LISTOPT to make it possible to override -L+ without a bunch
of painful additional options.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-08 08:52:49 -07:00
H. Peter Anvin (Intel)
6f52ecfa49 changes.src: update with current state of 2.15.03
Add release notes for 2.15.03 as it currently exists.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-07 09:33:42 -07:00
H. Peter Anvin (Intel)
47f8399667 NASM 2.15.03rc1 2020-07-06 21:51:40 -07:00
H. Peter Anvin (Intel)
cd87431424 BR 3392692: outcoff: allow user to reduce the default alignment
NASM would incorrectly only allow for the alignment to be increased,
even when overridden by the user. Allow the user to specify any
alignment value and have it override the partition type default.

The user can increade their own alignment value specification later,
of course, and the sectalign directive will present a floor for either
kind of specification.

Reported-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-06 21:46:43 -07:00
H. Peter Anvin (Intel)
178148c876 compiler.h: safer/more portable version of offsetin()
Still technically not defined behavior, but this *should* work on all
reasonable or semi-reasonable systems.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-06 17:13:02 -07:00
sezero
c0ab5a8be9 rdflib.c (main): change incorrect break statement to /* fall through */
Commit 6d36d8684 added a wrong break statement to case 'x'
in rdflib.c::main() at line235.  That case 'x' must "fall
through" into case 't' which re-checks the argument.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-06 13:20:09 -07:00
sezero
741967033e rdflib.c: add back timestamp size to header in library creation.
Commit 8dc965347 removed writing of the timestamp size to library
header. (Accidentally, I guess??) The attached patch adds it back.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-06 13:17:42 -07:00