0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-10-10 00:25:06 -04:00
Commit Graph

5512 Commits

Author SHA1 Message Date
H. Peter Anvin (Intel)
013db3d446 nasmlib: rename crc32.c to crc32b.c to avoid conflict with zlib/crc32.c
For the benefit of those platforms which have to rely on VPATH, avoid
having the same filename in multiple subdirectories.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-09 14:49:22 -07:00
InstLatx64
378ee0e9c5 AMX-TRANSPOSE: removed, retag instructions NEVER.
All the 16 AMX-TRANSPOSE instructions were removed from the 59th
edition of "Intel Architecture Instruction Set Extensions and Future
Features Programming Reference" September 2025, 319433-059.

Similar to PCOMMIT, they are tagged as 'NEVER'

[ hpa: don't remove from tests, but suppress the warnings.  Don't
  remove the CPUID tag; a future version of NASM will actually implement
  CPU filtering based on the various CPUID tags; that development is
  genuinely in progress. ]

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-09 14:44:24 -07:00
InstLatx64
62b610ad86 Feature flag change, remove duplicate: AVX512FC16->F16C
VEX version of VCVTPH2PS, VCVTPS2PH is F16C

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-09 14:29:09 -07:00
H. Peter Anvin (Intel)
43f9a71fc0 NASM 3.01rc7 nasm-3.01rc7 2025-10-08 13:12:29 -07:00
Yongjie2017
a684942de0 the list file existing or not should not fail the copy instead fail the nasm compiling itself so nasm -v is excused 2025-10-08 13:07:07 -07:00
Yongjie Sheng
420313da8c add project test support to dav1d 2025-10-08 13:07:07 -07:00
H. Peter Anvin (Intel)
be03f169b9 travis: let "make travis" show the errors if any
Grep for FAIL in the log and print any errors, otherwise a success
message.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-08 13:03:40 -07:00
H. Peter Anvin (Intel)
51dce26137 travis improvements: look for python3, log output, option to filter
Use autoconf to find either python3 or python.

Add option to travis to filter the contents of stdout or stderr.

Generate the _version.stdout travis matching file from the version
file.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-08 12:56:00 -07:00
H. Peter Anvin (Intel)
a398a41f0a travis: update AMX test
Update AMX test per previous commit from IntLatx64.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-08 11:59:23 -07:00
InstLatx64
019615f85f AMX fix
-- AMX instruction fixes
-- AMX test file extension with new levels
according to Intel ISA Extension Guide 58th edition

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-08 11:59:23 -07:00
InstLatx64
292d852f55 AVX-NE-CONVERT fix
AVX-NE-CONVERT fix:
- only VCVTNEPS2BF16 has EVEX version
AVX-NE-CONVERT32b/64b test files
Checked with XED version: [v2025.06.08]
2025-10-08 11:51:04 -07:00
Iouri Kharon
5a5057ad95 bug in new macro (typo?): alias is SAL (to SHL), not SAR 2025-10-08 11:49:54 -07:00
H. Peter Anvin (Intel)
e027b5919f NASM 3.01rc6 nasm-3.01rc6 2025-10-07 20:27:43 -07:00
H. Peter Anvin (Intel)
ae9335a0b9 labels: make the prefix/suffix options and pragmas consistent
Make the spellings for the label-mangling options and pragmas
consistent, and implement the directive forms which were documented
but never implemented.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 18:46:39 -07:00
H. Peter Anvin (Intel)
c08b4edca1 Sync builtin.mac 2025-10-07 18:06:34 -07:00
H. Peter Anvin (Intel)
495fd738ec NASM 3.01rc5 nasm-3.01rc5 2025-10-07 16:32:54 -07:00
H. Peter Anvin (Intel)
99df4c97be changes.src: handwavy note about various instruction changes
A lot of minor changes, but not worth enumerating them.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 16:31:43 -07:00
H. Peter Anvin (Intel)
e3f26e25a2 Reshuffle shift and rotate patterns for APX
The shift and rotate patterns are "interesting" in the following way:

1. Even though only 4/5/6 bits of the input are ever used, for the
   regular instructions the input is specified as the CL register, but
   for the -X instructions as a size-matching register. This makes the
   optimization patterns "interesting."

2. The sequencing of legacy, VEX -X versions, APX EVEX, and APX -X

For #1, allow any size register to contain the shift count.

For #2, split up the macro generation of the patterns, and add a new
"$xmacro" macro to deal with the combinatorics of generating all the
-X patterns.  Written directly in Perl since it seemed easier than
trying to make anything more general for what is very much a special
case...

Reported-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 16:26:09 -07:00
hongjinghao
e39b856bde preproc: fix heap memory overflow CVE-2023-31722
paramlen has heap memory of length nparam+1. The value of variable i
may be greater than nparam+1, causing heap memory overflow. Therefore,
i and nparam+1 needs to be determined in the loop.

Fixes: https://bugzilla.nasm.us/show_bug.cgi?id=3392857#c1
Fixes: https://github.com/netwide-assembler/nasm/pull/83
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 14:58:03 -07:00
H. Peter Anvin (Intel)
c651c28217 NASM 3.01rc4 nasm-3.01rc4 2025-10-07 11:18:18 -07:00
H. Peter Anvin (Intel)
6e221c8193 assemble: reduce the priority of "mask not permitted" error
Per BR 75, the "mask not permitted" error is a little too persistent.

Fixes: https://github.com/netwide-assembler/nasm/pull/75 (hopefully)
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 11:12:43 -07:00
Henrik Gramner
86919accd9 x86/insns.dat: Enable contracted forms for a few EVEX vcvt* instructions
Most instructions support contracted forms, but those had been overlooked.

Signed-off-by: Henrik Gramner <henrik@gramner.com>
[ hpa: manual merge ]
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 11:08:58 -07:00
Henrik Gramner
162d245c30 x86/insns.dat: Fix {er} usage on EVEX vcvtsi2* instructions
The rounding specifier should be applied to src2, not src1.

Furthermore, VCVTSI2SD with a 32-bit source operand does not
support specifying a rounding mode (as no rounding can occur).

Signed-off-by: Henrik Gramner <henrik@gramner.com>
[ hpa: manual merge ]
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 11:06:52 -07:00
H. Peter Anvin (Intel)
0a1a9789ec Fix confusion between "postfix" and "suffix"
"suffix" is the more common English term, but NASM used "postfix" for
a long time.  Allow them as aliases, and tidy up the documentation
accordingly.  While making these changes, tidy up the handling of
options in the index.

Fixes: https://github.com/netwide-assembler/nasm/pull/61
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 10:49:55 -07:00
Iouri Kharon
89439aa58d Remove unneeded (illegal) evex-encoding of VCVTPS2PH
According to the June edition of SDM evex-form of the VCVTPS2PH command only exists with mmmmm equal to 0f38, and map5 only exists for the VCVTPS2PHX command
2025-10-07 10:16:36 -07:00
H. Peter Anvin (Intel)
41d35bb483 Merge multiple fixes from "InstLatx64" 2025-10-07 10:13:12 -07:00
H. Peter Anvin
e72a54174c insns.dat: correct the [LD][GI]DT patterns
It is somewhat counterintuitive, but the correct flag for the memory
operand is "OSIZE". The "nw" flag takes care of promoting the default
operand size on 64 bits to 64.

Fixes: https://github.com/netwide-assembler/nasm/issues/130
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 09:58:54 -07:00
H. Peter Anvin
f047ceeae3 test/Makefile: add .bin{16,32,64} targets
Quick and easy way to run the same test for 16-, 32- and 64-bit output
without mixing them together in one binary output file.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 09:57:19 -07:00
H. Peter Anvin
fa43d8e01d asm: new --bits option to set the processor mode on the command line
This is really just a shorthand for the --before option, but it is
really convenient for quickly writing multimode tests.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 09:56:20 -07:00
H. Peter Anvin
2c63ab038c asm/preproc.c: generalize pp_pre_command()
Generalize pp_pre_command() so that the first argument doesn't have to
be a preprocessor token. Instead, the two arguments are now both
turned into token streams, separated by a whitespace token.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 09:53:15 -07:00
H. Peter Anvin
f1b6d3188c preproc: add a %selbits() function
Although one can implement this "manually" in terms of %sel(), this
function is *really* useful for making multi-mode tests and allows for
better error checking.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 09:17:59 -07:00
H. Peter Anvin
e4044cfc48 assemble.c: avoid a panic after invalid instruction error
If an instruction triggers an error (nasm_nonfatal) it is legitimate
for calcsize() to return 0; in that case no further processing is
needed.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 09:16:06 -07:00
H. Peter Anvin
6df250aee3 parser: add the actual name of a label to the label-orphan warning
The label-orphan warning is *way* more useful if it includes the
actual label name; this way the programmer can usually spot
immediately if it is a label or misspelled instruction.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 08:30:02 -07:00
Yongjie Sheng
d66187c1de reconstruct ffmpegtest to be generic to support more different projects 2025-10-07 08:11:33 -07:00
InstLatx64
2a2acca7c0 AVX512_VP2INTERSECT test files
AVX512_VP2INTERSECT 32b/64b test files
Checked with XED version: [v2025.06.08]
2025-10-07 12:07:55 +02:00
InstLatx64
f4b1a206e0 Remove duplicates
Remove duplicates:
- V{MAX,MIN}{P,S}H
- VEXTRACT{F,I}{32x4,64x2}
- VF{,C}MULCPH
- VF{,N}M{ADD,SUB}{132,213,231}SH
Removed AVX10_1 label from VADDPH/VCMPPH due to consistency
2025-10-07 11:35:15 +02:00
InstLatx64
fb43244978 KUNPCK* fix
KUNPCK* fix, it compiles k_test.asm without errors
2025-10-07 11:07:33 +02:00
InstLatx64
172c4b2342 Missing AVX-VNNI_INT{,8,16} instructions
-- AVX-VNNI_INT{,8,16} instructions: VPDP{B,W}{SS,SU,US,UU}{D,DS}
- AVX-VNNI_INT{,8,16}  test files
Checked with XED version: [v2025.06.08]
2025-10-07 09:52:13 +02:00
Yongjie Sheng
9cb23294a4 fix a displacement offset calculation error for movddup 2025-10-07 14:35:45 +08:00
Alexey Vishnyakov
891c63e64f output: fix null pointer dereferences in output/outaout.c
The bugs were found by Svace static analysis tool:

1. sym can be null in when exact is false, and sym is later dereferenced
   by sym->symnum
2. asym can be null, no return from function is performed, and asym is
   dereferenced by asym->symnum
2025-10-06 14:58:40 -07:00
Ivan Sorokin
bd7185bad1 fix undefined behavior in count_mmac_params
When compiled -fsanitize=undefined nasm produced this error message:

asm/preproc.c:2523:25: runtime error: member access within null pointer of type 'struct Token'

The problem is reproducible on tests avx512f, avx512cd, avx512pf
and avx512er in the test suite.

The problematic line was:

    /* Advance to the next comma */
    maybe_comma = &t->next;                            <<< HERE
    while (tok_isnt(t, ',')) {
        if (!tok_white(t))
            comma = NULL; /* Non-empty parameter */
        maybe_comma = &t->next;
        t = t->next;
    }

When t is NULL this line doesn't cause memory access, but it is still an
undefined behavior according to C standard.

I believe that the underlying problem is that this loop doesn't have a sound
invariant about maybe_comma:

* On first iteration: *maybe_comma == t->next
* On the following iterations: *maybe_comma == t

I don't know what the intended loop invariant is and I decided to just
mechanically fix the deferencing of NULL pointer, completely preserving
the existing behavior.

Signed-off-by: Ivan Sorokin <vanyacpp@gmail.com>
2025-10-06 14:56:45 -07:00
Ivan Sorokin
ad297258c1 fix memory leak in eval_strfunc
When running with -fsanitize=leak enabled nasm prints this error:

==19965==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 360 byte(s) in 90 object(s) allocated from:
    #0 0x7faee9396867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x5645d39a401c in nasm_malloc nasmlib/alloc.c:55
    #2 0x5645d3a41f9d in string_transform asm/strfunc.c:356
    #3 0x5645d3a37d40 in eval_strfunc asm/eval.c:761
    #4 0x5645d3a37d40 in expr6 asm/eval.c:906
    #5 0x5645d3a3968d in expr5 asm/eval.c:627
    #6 0x5645d3a39aca in expr4 asm/eval.c:602
    #7 0x5645d3a39b72 in expr3 asm/eval.c:563
    #8 0x5645d3a39db8 in expr2 asm/eval.c:537
    #9 0x5645d3a39f38 in expr1 asm/eval.c:511
    #10 0x5645d3a3a0b8 in expr0 asm/eval.c:485
    #11 0x5645d3a3a242 in rexp3 asm/eval.c:422
    #12 0x5645d3a3a508 in rexp2 asm/eval.c:396
    #13 0x5645d3a3a6a8 in rexp1 asm/eval.c:369
    #14 0x5645d3a3a838 in rexp0 asm/eval.c:342
    #15 0x5645d3a3a838 in cexpr asm/eval.c:305
    #16 0x5645d3a3ad08 in bexpr asm/eval.c:298
    #17 0x5645d3a3ad08 in evaluate asm/eval.c:1032
    #18 0x5645d39e4f20 in parse_line asm/parser.c:959
    #19 0x5645d399e243 in assemble_file asm/nasm.c:1735
    #20 0x5645d3998801 in main asm/nasm.c:719
    #21 0x7faee8aaed8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #22 0x7faee8aaee3f in __libc_start_main_impl ../csu/libc-start.c:392
    #23 0x5645d399acd4 in _start (/home/ivan/d/nasm/nasm+0x2e5cd4)

SUMMARY: AddressSanitizer: 360 byte(s) leaked in 90 allocation(s).

This problem is reproducible on test utf.asm.

The problem was caused by the fact that eval_strfunc doesn't free the string
allocated by string_transform.

Signed-off-by: Ivan Sorokin <vanyacpp@gmail.com>
2025-10-06 14:50:40 -07:00
Elyes Haouas
fc720e7040 Remove useless parentheses in return statements
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 14:28:54 -07:00
H. Peter Anvin
f6a17a29c0 nasmlib.h: protect list_last() macro against misuse
The list_last() macro is a statement macro; wrap it in a
do { ... } while(0) block to prevent accidental misuse.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 14:27:30 -07:00
Elyes Haouas
f744ec431f Remove trailing semicolon in macros
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
[ hpa: only one of the defined issues was valid, removed the rest. ]
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2025-10-06 14:26:42 -07:00
Elyes Haouas
d9494d5240 output/outmacho.c: Add missing space at break quoted strings
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
2025-10-06 14:22:59 -07:00
Elyes Haouas
346a1b3344 SubmittingPatches: Update git link
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
2025-10-06 14:22:50 -07:00
H. Peter Anvin
81dd083291 outelf.c: remove stray semicolon
Harmless, but undesirable.

Fixes: https://github.com/netwide-assembler/nasm/pull/57
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 14:19:15 -07:00
H. Peter Anvin
0c3a964caf doc: remove stray "are"
"are generate" -> "generate"

Fixes: https://github.com/netwide-assembler/nasm/pull/87
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 14:14:09 -07:00
H. Peter Anvin
5b9099c058 asm/parser: print the actual token in an error, not its value
Printing an internal token value is not very user-friendly :) Print
the contents of the actual token in question.

Fixes: https://github.com/netwide-assembler/nasm/pull/90
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 14:07:33 -07:00