Commit graph

4590 commits

Author SHA1 Message Date
H. Peter Anvin
4a2c8c52c7 outobj: limit excessive length warning to 64 characters
The case where we warn for excessive length should presumably have
been %.nnns which means limit length to nnn characters, rather than
%nnns which means left-pad with spaces to nnn bytes if possible. Also
change the limit from 128 to 64, to make it more likely to not line
break.

Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-08-18 12:33:51 -07:00
Cyrill Gorcunov
51e23ac72a travis: add br3392643 test
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2020-08-18 21:05:56 +03:00
Cyrill Gorcunov
f14552e5fb BR3392646: output/outobj.c: fix memory corruption in long object names
When we encode a name we put its length before it, the
storage is one byte width so the name can't be more
than UINT8_MAX (ie 255) bytes length.

Moreover if one provide a name more than RECORD_MAX then
we simply overwrite random memory.

Thus lets do as in other obj_check calls -- shrink the
size we gonna use. But unlike oter code lets yield a
warning as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2020-08-18 20:27:14 +03:00
Cyrill Gorcunov
57e0b3e56a travis: add br3392711 test
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2020-08-18 13:59:12 +03:00
Cyrill Gorcunov
7c88289e22 BR3392711: preproc: fix memory corruption in expand_one_smacro
The mempcpy helper returns *last* byte pointer thus when
we call set_text_free we have to pass a pointer to the
start of the string.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2020-08-18 11:27:03 +03:00
H. Peter Anvin (Intel)
4268400c10 NASM 2.15.04rc5 2020-08-17 15:28:31 -07:00
H. Peter Anvin (Intel)
6dc8379d6a rdoff: disable broken backend, document deprecation
The RDOFF backend has been broken since at least NASM 2.14, throwing
an immediate assert. Since only one person appears to have even
noticed, and fixing it properly looks like it would take quite a bit
of work, disable this back end and document its deprecation.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-08-17 15:26:11 -07:00
H. Peter Anvin (Intel)
235a115130 doc: document long-standing restrictions in the use of $ in Dx
$ in data expressions is hazardous. A proper fix for this turns out to
be quite complex, as it requires the expression engine to propagate
additional data. For now, just put it into the documentation.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-08-17 15:10:26 -07:00
Cyrill Gorcunov
8806c3ca00 BR3392712: pp_tokline: fix double free
Make sure the data being freed get double
freed after -- the pointers must be zapped
(actually nasm_free and free_tlist support
being called with NULL pointer as an argument).

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2020-08-17 21:30:14 +03:00
H. Peter Anvin
0491fda82f NASM 2.15.04rc4 2020-08-13 17:21:28 -07:00
H. Peter Anvin
d988ce719c Fix inefficient encoding of MPX instructions
BNDMK, BNDLDX, and BNDSTX are split-SIB (MIB) instructions, but do
*not* require a SIB encoding. However, TILELOAD* and TILESTORE* *do*
require a SIB in all cases. Split the MIB flag into MIB (split
address) and SIB (SIB required) flags.

This fixes travis test mpx.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-08-13 17:21:00 -07:00
H. Peter Anvin
7839766663 eval, float: fix the __float80e__ and __float128h__ conversions
We need to add the byte offset into the floating-point value to get
the correct result for these floating point to integer conversions.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-08-13 13:41:46 -07:00
H. Peter Anvin (Intel)
50200cc0d3 configure.ac: add option to compile with suggestion warnings
Add a configure option to enable suggestion warnings, currently a set
of -Wsuggest-attribute=* warnings.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-30 17:37:42 -07:00
H. Peter Anvin (Intel)
c9467688b4 Add [v]printf_func() attributes where appropriate
Add a new macro vprintf_func() for vprintf-style functions, and add
printf_func() and vprintf_func() attribute arguments whereever
meaningful.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-30 17:30:20 -07:00
H. Peter Anvin (Intel)
ed47b8ce3e NASM 2.15.04rc3 2020-07-30 17:08:59 -07:00
H. Peter Anvin (Intel)
78df8828a0 output/codeview.c: use list_for_each_safe() to free a list
Using list_for_each() is by definition not safe when freeing the
members of the list, use list_for_each_free() instead.

Also, use nasm_new() and nasm_free() where appropriate.

This was discovered as a downstream bug from BR 3392707.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-30 17:06:24 -07:00
H. Peter Anvin (Intel)
bae6b070ff BR 3392705: AVX512: reinstate the SSE-like opcodes for VPCMPEQ/GT
The VPCMP instructions are controlled by an immediate byte, but there
is also a set of SSE-derived legacy opcodes for VPCMPEQ and
VPCMPGT. For the specific cases of VPCMPEQ and VPCMPGT, prefer those
opcodes since they are one byte shorter.

Reported-by: ig <glucksmann@avast.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-30 16:56:52 -07:00
H. Peter Anvin (Intel)
6299a3114c BR 3392708: fix NULL pointer reference for invalid %stacksize
After issuing an error message for a missing %stacksize argument, need
to quit rather than continuing to try to access the pointer.

Fold uses of tok_text() while we are at it.

Reported-by: Suhwan <prada960808@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-30 15:57:57 -07:00
H. Peter Anvin (Intel)
6ac6ac57e3 parser: when flattening an eop, must preserve any data buffer
An eop may have a data buffer associated with it as part of the same
memory allocation. Therefore, we need to move "subexpr" up instead of
merging it into "eop".

This *partially* resolves BR 3392707, but that test case still
triggers a violation when using -gcv8.

Reported-by: Suhwan <prada960808@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-30 15:48:45 -07:00
H. Peter Anvin (Intel)
0e6e013813 nasm: don't make -L+ imply -Lw
-Lw really is only useful to debug NASM crashes, and can hugely slow
down the assembler. Make -L+ simply imply full verbosity; if NASM
crashes use -Lw+ instead.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-30 15:25:00 -07:00
H. Peter Anvin (Intel)
e56c2dc5b7 insns.pl: audit for impossible Sx patterns; fix a few
Break the instruction processing if there are impossible combinations
of Sx flags and operand sizes. If the intent is to always require
explicit sizes, use the SX flag.

The INSERTPS instruction pattern was explicitly wrong, the rest of
these are nuisance fixes.

TODO: fix the disassembler to be able to exclude patterns where these
bits don't matter.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-30 15:16:11 -07:00
H. Peter Anvin (Intel)
5b89628e44 NASM 2.15.04rc2 2020-07-28 13:50:04 -07:00
H. Peter Anvin (Intel)
9d96e7a6a4 BR 3392704: unbreak MOVHPD instruction
MOVHPD takes a mem64, but was incorrectly tagged SO - an impossible
combination.

The Sx tags really are a problem and should be removed in the future
whereever possible, presumably in the master branch.

Reported-by: Lukas Hönig <lukashoenig@icloud.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-28 13:39:44 -07:00
H. Peter Anvin (Intel)
1803518017 NASM 2.15.04rc1 2020-07-27 13:28:05 -07:00
H. Peter Anvin (Intel)
671f204ed1 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-27 13:24:59 -07:00
H. Peter Anvin (Intel)
e743b89f25 BR 2292703: Add memory sizes to SSE and some other instructions
Most SSE instructions were missing memory operand sizes, resulting in
error if a memory operand was specified with explicit size.

Reported-by: <nemeth.marton@hotmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-27 13:20:38 -07:00
H. Peter Anvin (Intel)
421e4d03ea changes.src: document COFF alignment fix
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-27 12:36:36 -07:00
H. Peter Anvin (Intel)
b6ba0a23f9 BR 3392701: outcoff: remove weird padding code
It seems that the odd alignment-padding code was simply dead in older
versions of NASM. This means that the COFF backend behavior really was
the same as the other backends. Remove that stale code and revert to
previous/common behavior.

Reported-by: ig <glucksmann@avast.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-27 12:28:09 -07:00
H. Peter Anvin (Intel)
9abbaa133d BR 2292702: fix ENQCMDS and TILELOADT1 instructions
Wrong prefixes for ENQCMDS and TILELOADT1.

Reported-by:  Iouri Kharon <bc-info@styx.cabel.net>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-27 11:44:04 -07:00
H. Peter Anvin
92d40ad8e4 nasmdoc.src: document when $*? and $*?? were introduced
It is important for programmers to be able to know when new constructs
were introduced, as they may have backwards compatibility needs and
thus need to know to avoid a construct that is too new.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-18 13:49:58 -07:00
H. Peter Anvin
6263a2a4c2 preproc: add %*? and %*??
The %? and %?? tokens are ambiguous when used inside a multi-line
macro. Add tokens %*? and %*?? that only expand during single-macro
expansion.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-18 13:47:59 -07:00
H. Peter Anvin
d76663a637 doc: one more copyright year issue. Add metadata macros to fix.
Yet another place in the documentation where the copyright year comes
in. Instead of having to deal with it manually over and over, add
support for inserting the metadata strings as macros in the output.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-17 19:48:36 -07:00
H. Peter Anvin
2d53846aab doc/nasmdoc.src: update copyright year
Updating the copyright year in the header isn't sufficient. To make it
harder to mess up, move the year metadata tag to the header just below
the copyright statement itself.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2020-07-17 19:33:52 -07:00
H. Peter Anvin
66a0dd460c insns.dat: fix accidentally duplicated patterns
Some patterns were accidentally duplicated during the conversion of
the X64 marker.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2020-07-17 19:29:37 -07:00
H. Peter Anvin
6c1ad43d5e insns.dat: get rid of the X64 marker (= X86_64,LONG)
The X64 marker for "X86_64,LONG" has turned out to be a problem in
that it is easy to mistake for "long mode" when adding new
instructions, which results in duplicate CPU flags. Kill it off; it
isn't like we will legitimately have new instructions with this
pattern ever again.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-17 19:25:19 -07:00
H. Peter Anvin
8ce4a58b1a rdsrc.pl: allow code paragraphs up to 80 characters long
All the backends support code paragraphs 80+ characters wide (85 for
HTML, 90 for PDF) without overrunning the margins. Avoid the noise.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2020-07-17 18:12:34 -07:00
H. Peter Anvin
20be7aaa28 doc/pspdf.pl: remove .setpdfwrite from gs command line
Ghostscript no longer recommends adding the .setpdfwrite operator when
producing PDF; in fact:

.setpdfwrite
    This operator is now deprecated, and its use is discouraged

Presumably it was never actually necessary, so just drop it.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-17 18:02:49 -07:00
H. Peter Anvin
d27427846f NASM 2.15.03 2020-07-17 17:53:37 -07:00
H. Peter Anvin
ec20417002 changes.src: slighly better description of new instructions
Describe what the new instructions actually are.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-17 17:46:45 -07:00
H. Peter Anvin
1d8c09b24e x86/insns.dat: add tuple type for the latest AVX512 instructions
Add missing tuple type (all are Full - fv:) for the latest AVX512
instructions.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-17 17:44:27 -07:00
H. Peter Anvin
848b1657fd NASM 2.15.03rc8 2020-07-16 23:13:24 -07:00
H. Peter Anvin
d081f0db5d fp: support bfloat16 constants
Support generating bfloat16 constants. This is a bit awkward, as "DW"
already generates IEEE half precision constants; therefore there is no
longer a single floating-point format for each size. This requires
some replumbing.

Fortunately bfloat16 fits in 64 bits, so support generating them with
a macro that uses __?bfloat16?__() to convert to integers first before
passing them to DW.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2020-07-16 23:11:03 -07:00
H. Peter Anvin
e830e92b77 preproc: when printing errors, don't descent into unlisted macros
If macros are nolisted, *or* they don't have any filename associated
with them, it is absolutely pointless to try to descend into them for
error messages, so just don't, even if -Lb is provided.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2020-07-16 22:50:33 -07:00
H. Peter Anvin
b31a4c9906 Add support for new instructions from ISE June 2020
Add support for new instructions as defined in the Instruction Set
Extensions manual as of June 2020.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2020-07-16 21:52:15 -07:00
H. Peter Anvin
36814f1fc8 autoconf: look for _Decltype as yet another alias for typeof().
If the past is any indication, the final standardization of typeof()
probably will be _Decltype().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2020-07-16 20:28:35 -07:00
H. Peter Anvin (Intel)
271dc7a7f7 NASM 2.15.03rc7 2020-07-15 16:21:08 -07:00
H. Peter Anvin (Intel)
4c0bd9e736 preproc: BR 2292698: fix handling of whitespace around %+
The previous code to fix whitespace around and multiple %+ symbols in
a row (checkin 122c5fb759) had some
seriously broken pointer handling when zapping tokens. This could
cause paste_tokens() to go into an infinite loop because it would
attach %+ to another token and then immediately break them apart
again, over and over.

Reported-by: <alexfru@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-15 16:16:57 -07:00
Cyrill Gorcunov
f1cf95480d travis: weirdpaste -- add nil dereference test
To address BR 3392696

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2020-07-12 06:01:51 -07:00
Cyrill Gorcunov
65c6ba8716 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:00:51 -07:00
H. Peter Anvin (Intel)
bc5fc72d5b NASM 2.15.03rc6 2020-07-10 18:46:12 -07:00