Commit graph

4569 commits

Author SHA1 Message Date
H. Peter Anvin (Intel)
295b64541c Makefile.in: always_everything needs to depend on dirs
If the directories don't exist, we could get serious weirdness.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-04 18:59:25 -07:00
H. Peter Anvin (Intel)
9e5e5ec5b6 Makefile.in: Makefile.dep is not optional for external dependencies
If we have external dependencies, we need Makefile.dep to exist;
this forces make to invoke the Makefile.dep target if this file is
missing.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-04 18:44:23 -07:00
H. Peter Anvin (Intel)
12308896bb NASM 2.15rc4 2020-06-04 18:35:44 -07:00
H. Peter Anvin (Intel)
aaa863fbe4 mkdep.pl: remove debugging print statement
Remove debugging print statement.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-04 18:33:26 -07:00
H. Peter Anvin (Intel)
d23200584c Makefile: run cleandeps, no need to config.status --recheck
There is no point to run config.status --recheck just because
we have changed Makefile.in. Just run config.status.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-04 18:30:35 -07:00
H. Peter Anvin (Intel)
dc1a6c5306 mkdep.pl: fix internalization/externalization
At some point internalization/externalization of dependencies
apparently broke.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-04 18:30:27 -07:00
H. Peter Anvin (Intel)
8d03b9ccc8 release: don't include nasmdoc.pdf.xz in the -xdoc file
There is no reason to include both nasmdoc.pdf.xz and nasmdoc.pdf. For
the -xdoc file, the one with minimal dependencies is the proper one.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-04 17:31:17 -07:00
H. Peter Anvin (Intel)
fb7753bc2b nasm.spec.in: need perl; .pdf.xz now build by standard Makefile
Building NASM from scratch needs perl.

.pdf.xz is now build by the standard NASM Makefile.in, so don't
do it again (it causes failures.)

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-04 17:17:28 -07:00
H. Peter Anvin (Intel)
855f50b70b NASM 2.15rc3 2020-06-04 16:33:50 -07:00
H. Peter Anvin (Intel)
f8639bdb52 BR 3392662: handle empty argument at end of mmacro call
A trailing comma at the end of an mmacro call is an empty
argument, and so we can't terminate the argument-processing loop. The
only case where skip_white() returning NULL where we are allowed to
terminate the loop is in the case of nparams == 0, i.e. the macro call
has no arguments at all.

Reported-by: gabriele balducci <balducci@units.it>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-04 16:29:53 -07:00
H. Peter Anvin (Intel)
283bc92a92 nasm.c: correctly print errors once committed; assert errhold_stack empty
Properly format the error messages when we print them (oops!)

The errhold_stack should be empty after each pass. It may even be
worthwhile to make sure it is empty after each *line*, but do this
for now.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-04 16:19:51 -07:00
H. Peter Anvin (Intel)
c44709c964 preproc: don't call nasm_error_hold_push() twice
We must not call nasm_error_hold_push() twice... the obvious
leak of the error stack caused all kinds of errors to be suppressed.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-04 16:19:01 -07:00
H. Peter Anvin (Intel)
4964d80fe4 BR 3392652: hold smacro expansion warnings until we are sure
Don't issue smacro expansion warnings until we are sure we are
actually *done* with the smacro expansion. The last pass of
expand_smacro_noreset() gets to commit warnings.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-04 15:59:47 -07:00
H. Peter Anvin (Intel)
12df4dd12f asm/error.c: handle warning "all" correctly
warning_alias[0] is "all". It is represented in the loop by
value == NULL; WARN_IDX_ALL does not have an entry in warning_state[]
and so trying to poke it is an error.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-04 15:59:47 -07:00
H. Peter Anvin
b1ef4345a9 NASM 2.15rc2 2020-06-01 16:16:04 -07:00
H. Peter Anvin
a3cbaafd52 outobj: fix harmless but still incorrect use of uninitialized variable
Fix use of uninitialized variable. This most likely is just an
issue while running at debug level >= 3, but it's still wrong.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-01 16:11:47 -07:00
H. Peter Anvin
7002bb76a3 BR 3392674: fix handling of {ud1,ud2b} <reg>,<reg>
We need the instruction table to contain the correct information for
both the reg and the rm field in the various modes.

Reported-by: <fasdfqwer@mail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-01 16:03:54 -07:00
H. Peter Anvin (Intel)
5b4de52083 BR 3392667: more reasonable limit for expression descent
Set an expression descent limit to 8192, which is more reasonable to
expect to work on most platforms. Furthermore, if getrlimit() exists,
then try to use it to see if we need to further limit the size.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-01 13:21:05 -07:00
H. Peter Anvin (Intel)
5d68f9823e preproc: error out if an include file exists but can't be opened
If an include file exists, but cannot be opened, that is still a
critical error.

However, downgrade this from a fatal to a nonfatal error. There really
isn't any reason to stop cold here.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-01 12:32:35 -07:00
H. Peter Anvin (Intel)
6e71496e3c BR 3392669: in expand_one_smacro(), we may reach EOL before tafter
If the rest of the line is consumed, we may never see tafter, so we
have to test for end of line at line 5412.  We already do at 5397, so
it clearly should have been there all along.

Reported-by: <puppet@zju.edu.cn>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-01 12:21:10 -07:00
H. Peter Anvin (Intel)
7cfd01868c BR 3392668: in %define, don't set "definining" until confirmed
Don't set "defining" until the macro definition is successfully parsed
and we know for sure that we are going to define the macro.

Together with:

a762cd4e54 BR 3392668: preproc: test for macro in TOK_LOCAL_SYMBOL

... this addresses BR 3392668.

Reported-by: <puppet@zju.edu.cn>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-01 12:04:35 -07:00
H. Peter Anvin (Intel)
a762cd4e54 BR 3392668: preproc: test for macro in TOK_LOCAL_SYMBOL
TOK_LOCAL_SYMBOL is only applicable inside a macro; otherwise error
out just like we do for TOK_MMACRO_PARAM.

This *partially* addresses BR 3392668.

Reported-by: <puppet@zju.edu.cn>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-01 11:49:08 -07:00
H. Peter Anvin (Intel)
941c75a2b2 Makefile portability improvement, build nasmdoc.pdf.xz
Significantly improve the portability/reliability of a general
make command. Build a .pdf.xz version of the documentation,
using an uncompressed pdf as basis.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-05-26 14:13:31 -07:00
H. Peter Anvin (Intel)
ac30bd6a5f NASM 2.15rc1 2020-05-26 10:16:47 -07:00
H. Peter Anvin (Intel)
70a4af43eb Merge remote-tracking branch 'chang/master' 2020-05-26 10:15:49 -07:00
Andrey Matyukov
4df1386eb0 doc: Update for upcoming 2.15 release
Update release notes and documentation for 2.15

Signed-off-by: Andrey Matyukov <andrey.matyukov@intel.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-05-06 20:37:09 +00:00
Chang S. Bae
c32fb08319 test: Add BR3392607
Reported-by: Henrik Gramner <herik@gramner.com>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392607
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-22 00:10:21 +00:00
Henrik Gramner
284ad955a4 insns.dat: Fix the opcodes for the AVX512-VBMI2 instructions
The two VPSH{R|L}DV* instructions had the wrong opcode.

Reported-by: Henrik Gramner <herik@gramner.com>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392607
Signed-off-by: Henrik Gramner <henrik@gramner.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-22 00:10:08 +00:00
Chang S. Bae
bd1055b8be disam: explicitly change stdin to binary mode
The binary mode has no difference from text mode in
POSIX-compliant operating systems. The two modes are
distinguishable from each other on Windows, and perhaps
on other systems as well.

The binary stream has scalability and other advantages.
Windows treats the standard input stream as text mode by
default. So the code changes it to binary mode.

Also, add a helper function, nasm_set_binary_mode(),
that is OS-agnostic, in the library.

Reported-by: Didier Stevens <didier.stevens@gmail.com>
Suggested-by: Didier Stevens <didier.stevens@gmail.com>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392649
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-22 00:09:58 +00:00
Chang S. Bae
ee8edad40b test: Add BR3392661
Suggested-by: <mae.bdf@outlook.com>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392661
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-22 00:08:28 +00:00
Chang S. Bae
74b2731f2c outelf: Fix the section index for the debug output
The section information delivered to the debug output has an index of the
section table. The index should be different from the total number of
sections at the moment, the returned value from add_sectname(). So, fix the
value.

Fixes: b2004511dd ("ELF: handle more than 32,633 sections")

Reported-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392654
Reported-by: <mae.bdf@outlook.com>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392661
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-22 00:05:56 +00:00
Chang S. Bae
c52aff4cc8 preproc: Fix in accessing the definition structure of a single-line macro
Determining whether we should warn on defining a single-line macro, with a
name and a certain number of parameters, call a helper function,
smacro_defined(). It does not always return the address of the definition
structure.

Fix the code to be cautiously accessing the definition structure.

Fixes: e91f5cc132 ("preproc: fix %undef of macro aliases, and add
%ifdefalias")

Reported-by: Dale Curtis <dalecurtis@chromium.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392659
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-21 21:41:33 +00:00
Chang S. Bae
5f8d0ec1f6 test: Add BR3392660
Suggested-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392660
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-21 21:35:54 +00:00
Chang S. Bae
057b832f45 preproc: Fix the macro-parameter check for conditional code
Mistreating the macro-parameter, just equivalent to the given
argument number, leads to casting an unnecessary error. Fix to
assemble the conditional code correctly.

Fixes: de7acc3a46 ("preproc: defer %00, %? and %??
expansion for nested macros, cleanups")

Reported-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392660
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-21 21:28:50 +00:00
Chang S. Bae
9e019f249c test: Add BR3392640
Suggested-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392640
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-21 21:12:39 +00:00
Chang S. Bae
7ee58d44e4 preproc: Fix the token in expanding the macro-parameters
The code looked to be unintentionally always nullifying the
token pointer at first place in handling those macro-parameters.
Remove it to avoid segfault.

Fixes: de7acc3a46 ("preproc: defer %00, %? and %??
expansion for nested macros, cleanups")

Reported-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392640
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-21 21:12:01 +00:00
Chang S. Bae
0197c966da test: Add BR3392630
Add the test code into the existing xdefine testing.

Suggested-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392630
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-21 21:11:33 +00:00
Chang S. Bae
95e54a9f1f preproc: Fix the token iterator in expanding single-line macro
The code used to stuck in going through whitespace tokens.
Fix to increment towards on the next in the loop.

Reported-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392630
Suggested-by: C. Masloch <pushbx@ulukai.org>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-21 21:11:10 +00:00
Chang S. Bae
bb96fdc74c test: Add BR3392626
There are many similar preprocessor loop cases but located
on each bug-report basis. While it looks to be better to
consolidate them together, add one more test case like what
was done before.

Suggested-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392626
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-21 21:00:56 +00:00
Chang S. Bae
bec812fc4b preproc: Fix to reset %rep list line number after every iteration
The code has been fixed to print the corresponding line
numbers of %rep blocks correctly, but only for the first
iteration. For the subsequent iterations, the current line
number on the expansion needs to be explicitly reset again.

Fixes: ab6f831955 ("listing: when listing lines in macros
and rep blocks, show the actual line")

Reported-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392626
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-17 21:33:33 +00:00
Chang S. Bae
333f1d02bb test: Add BR 3392607
Reported-by: Henrik Gramner <herik@gramner.com>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392607
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-01 15:48:37 -07:00
Henrik Gramner
b291b21685 insns.dat: Fix the opcodes for the AVX512-VBMI2 instructions
The two VPSH{R|L}DV* instructions had the wrong opcode.

Reported-by: Henrik Gramner <herik@gramner.com>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392607
Signed-off-by: Henrik Gramner <henrik@gramner.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-01 15:48:04 -07:00
Chang S. Bae
2f3e898780 disam: explicitly change stdin to binary mode
The binary mode has no difference from text mode in
POSIX-compliant operating systems. The two modes are
distinguishable from each other on Windows, and perhaps
on other systems as well.

The binary stream has scalability and other advantages.
Windows treats the standard input stream as text mode by
default. So the code changes it to binary mode.

Also, add a helper function, nasm_set_binary_mode(),
that is OS-agnostic, in the library.

Reported-by: Didier Stevens <didier.stevens@gmail.com>
Suggested-by: Didier Stevens <didier.stevens@gmail.com>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392649
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-01 15:47:26 -07:00
Chang S. Bae
655761ba18 test: Add BR 3392640
Suggested-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392640
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-01 15:43:54 -07:00
Chang S. Bae
6e3f3411a1 preproc: Fix the token in expanding the %+/%- macro-parameters
The code looked to be unintentionally always nullifying the
token pointer at first place in handling those macro-parameters.
Remove it to avoid segfault.

Fixes: de7acc3a46 ("preproc: defer %00, %? and %??
expansion for nested macros, cleanups")

Reported-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392640
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-01 15:42:16 -07:00
Chang S. Bae
53ca4bb19c test: Add BR 3392630
Add the test code into the existing xdefine testing.

Suggested-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392630
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-01 15:41:44 -07:00
Chang S. Bae
51fd5a5067 preproc: Fix the token iterator in expanding single-line macro
The code used to stuck in going through whitespace tokens.
Fix to increment towards on the next in the loop.

Reported-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392630
Suggested-by: C. Masloch <pushbx@ulukai.org>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-01 15:41:38 -07:00
Chang S. Bae
ddb22a821c test: Add BR 3392626
There are many similar preprocessor loop cases but located
on each bug-report basis. While it looks to be better to
consolidate them together, add one more test case like what
was done before.

Suggested-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392626
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-01 15:40:59 -07:00
Chang S. Bae
073cd40c63 preproc: Fix to reset %rep list line number after every iteration
The code has been fixed to print the corresponding line
numbers of %rep blocks correctly, but only for the first
iteration. For the subsequent iterations, the current line
number on the expansion needs to be explicitly reset again.

Fixes: ab6f831955 ("listing: when listing lines in macros
and rep blocks, show the actual line")

Reported-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392626
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2020-04-01 15:40:40 -07:00
H. Peter Anvin
2cd1a6fb70 test: test case for BR 3392655, overflow during bin format link
The bin format linker should warn if a relocation overflows its
virtual address.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2020-03-31 10:23:43 -07:00