Commit graph

4937 commits

Author SHA1 Message Date
H. Peter Anvin
3fe5b3f5a1 preproc: distinguish between directives and functions
Some preprocessor functions have the same name as directives. In those
cases, they should be expanded as functions if and only if they are
followed by a left parenthesis. Although it is not inherently true that
either preprocessor functions require a paren nor that directives
cannot start with one, but it is true and will remain true for all
cases where there is a namespace collision.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-11 19:51:22 -08:00
H. Peter Anvin
359e21e773 preproc: implement %strlen as a preprocessor function
Implement a %strlen() preprocessor function, equivalent to the %strlen
directive.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-11 19:15:35 -08:00
H. Peter Anvin
4150848a7d preproc: implement %substr() and %tok() preprocessor functions
Implement preprocessor functions equivalent to the %substr and %deftok
directive.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-11 19:02:41 -08:00
H. Peter Anvin
913901e529 preproc: skip invalid advance in %substr
%substr contained a token skip to "skip expanded ID", which is
incorrect, as that has already been skipped at that point. It worked
anyway, accidentally, as this token would always be a whitespace token
-- but we then do skip_white() immediately thereafter.

Delete this to allow this code to be factored.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-11 18:28:11 -08:00
H. Peter Anvin
57fbd34d9f preproc: implement %str() and %strcat() functions
Add function equivalents of the %defstr and %strcat directives.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-11 18:18:04 -08:00
H. Peter Anvin
a5d0284634 doc: improve the HTML index readability
Make the HTML index more like what you would expect an index to look
like.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-09 21:37:16 -08:00
H. Peter Anvin
df243389e0 doc/changes.src: begin changes.src for 2.16
Once again, need to write these damned release notes.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-09 19:04:01 -08:00
H. Peter Anvin
5219d14e6f doc: don't include "chapter", "section" etc in the HTML index
The use of statements like "chapter", "section" and so on makes the
HTML index insanely verbose. Remove them; they don't add any
information.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-09 19:02:56 -08:00
H. Peter Anvin
beabb3ccb7 warnings.pl: add back formatting for group alias lists
Add back proper formatting for the list of warnings represented by a
group alias.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-09 19:01:54 -08:00
H. Peter Anvin
f7163e343c doc: allow replicated index entries (\IR), make index sorting smarter
Allow a single index entry key to be defined with \IR more than once,
generating multiple entries in the index; this is really useful for
example to always generate "macros, single-line" and "single-line
macros" entries sorted at different places.

Be smarter about sorting the index: sort (nearly) all special
characters before alphanumerics, and (attempt to) sort numbers in
numerical order rather than alphabetical (so BITS8 sorts before
BITS16).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-09 18:38:45 -08:00
H. Peter Anvin
7727fbb59a doc: move instruction list to the end
The web site currently assumes that the release history is always in
appendix C. Humor it for now, besides, it doesn't really make sense
for the huge machine-generated instruction list to be anywhere but the
end.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-08 18:40:11 -08:00
H. Peter Anvin
ebbe01b573 NASM 2.16rc4 2022-11-08 18:30:21 -08:00
H. Peter Anvin
d794e0e593 nsis: remove references to RDOFF tools
The rdoff tools are gone; obviously we can't expect to install them.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-08 18:22:25 -08:00
H. Peter Anvin
15a02b5474 NASM 2.16rc3 2022-11-08 18:12:11 -08:00
H. Peter Anvin
caffd140c0 asm: factor out more warnings into warning classes
Hopefully we'll eventually get rid of WARN_OTHER completely...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-08 17:50:45 -08:00
H. Peter Anvin
63049146f6 warnings.pl: format the warning class list better
Better formatting for the warning class list (a little bit less like
trying to be prose.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-08 15:26:03 -08:00
H. Peter Anvin
a5fc643cb9 doc/genps.pl: handle large lists of index entries
If a list of index entries is so long that the whole list can't fit
onto a single page, we *have* to break it. Treat the hanging-comma
line as a potential widow, but allow column breaks elsewhere in the
list.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-08 15:24:24 -08:00
H. Peter Anvin
d77a86b666 psfonts.ph: add more font aliases
Add a bunch more aliases for various fonts. Apparently this really can
be in flux.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-08 15:12:31 -08:00
H. Peter Anvin
61db795f3b NASM 2.16rc2 2022-11-07 17:06:57 -08:00
H. Peter Anvin
b9646f9e39 nasmlib: fix stub when os_fstat() is not defined
Use the correct variable to quiet unused variable warning in
os_fstat() stub.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 16:56:56 -08:00
H. Peter Anvin
3f08242752 Merge remote-tracking branch 'chengzhycn/fix/fonts' 2022-11-07 16:52:02 -08:00
H. Peter Anvin
93548c2de2 rdoff: kill it off
RDOFF has been deprecated as it has unfixable problems, and has been
announced that it will be killed off in NASM 2.16.

This deletes it once and for all.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 16:49:13 -08:00
Marco Vanotti
6224dd0b45 preproc: don't unmacro if macro cannot be found.
This commit adds a check to see if the macro that we want to unmacro exists.
A previous commit, introduced a check to see if the unmacro was undefining a macro being expanded, but that same check included a null pointer dereference if the macro to undefine did not exist.

The following code reproduced the issue:

```asm
%macro baz 0
  %unmacro F 0
%endmacro
baz
```

Compile with:
```shell
$ nasm -f elf64 -g -FDWARF -o tmp.o -werror file.asm
```

[hpa: adjusted code to match NASM style]

Fixes bug 3392761

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 16:30:49 -08:00
H. Peter Anvin
1e50772539 Merge remote-tracking branch 'Gramner/vpexpand' 2022-11-07 16:28:12 -08:00
H. Peter Anvin
ec2074d27f fp16: fix incorred handling of broadcast flags
The FP16 patch had a case of bit overlap. Clean up the handling of
broadcast flags a little in the process.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 16:24:39 -08:00
H. Peter Anvin
8f2e3cc376 asm/assemble.c: fix bogus warnings on explicit [rel]
Warnings with explicit [rel] would pretty much *always* warn after
checkin f4e7a636a8. Fix this.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 16:20:04 -08:00
H. Peter Anvin
665e5e3da8 travis: update COFF tests to not expect an embedded filename
When doing a reproducible build with COFF, since checkin
e1423b0573 the filename is suppressed.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 16:18:50 -08:00
H. Peter Anvin
1a5fcb070a Revert "preproc: fix memory leak (and possibly CVEs?)"
This reverts commit 8fcc785f95.

This patch causes test a32offs.asm, and in general *any* use of the
"bits" macro, to totally fail.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 13:08:30 -08:00
H. Peter Anvin
d9593aaaca Merge remote-tracking branch 'hut8/master' 2022-11-07 12:55:20 -08:00
H. Peter Anvin
ed70640526 Merge remote-tracking branch 'johannkoenig/master' 2022-11-07 12:54:22 -08:00
H. Peter Anvin
b18e870d90 Merge remote-tracking branch 'ElyesH/typos' 2022-11-07 12:39:44 -08:00
H. Peter Anvin
3516258783 Merge remote-tracking branch 'ElyesH/comments' 2022-11-07 12:39:34 -08:00
H. Peter Anvin
7a60c29995 Merge remote-tracking branch 'ElyesH/master' 2022-11-07 12:39:26 -08:00
H. Peter Anvin
c115cf4864 Merge remote-tracking branch 'igg0/strcat' 2022-11-07 12:36:24 -08:00
H. Peter Anvin
665a9820f5 Merge remote-tracking branch 'vszakats/outcoff-file-repro' 2022-11-07 12:35:34 -08:00
zhrf2020
8fcc785f95 preproc: fix memory leak (and possibly CVEs?)
case PP_ENDM:
    case PP_ENDMACRO:
        if (!(defining && defining->name)) {
            nasm_nonfatal("`%s': not defining a macro", tok_text(tline));
            goto done;
        }
        mmhead = (MMacro **) hash_findi_add(&mmacros, defining->name);
        defining->next = *mmhead;
        *mmhead = defining;
        defining = NULL;
        break;

The variable: mmacros has not been released, which will cause a memory
leak. Repair cve-2021-33450 cve-2021-33452 synchronously

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 12:34:04 -08:00
H. Peter Anvin
0582a32300 Merge remote-tracking branch 'rygorous/master' 2022-11-07 12:31:54 -08:00
H. Peter Anvin
ffedb33c33 Merge remote-tracking branch 'lkslawek/master' 2022-11-07 12:26:13 -08:00
H. Peter Anvin
13e338af8b Merge remote-tracking branch 'iglosiggio/fix-DW_AT_high_pc-relocation' 2022-11-07 12:23:36 -08:00
Iouri Kharon
21d8dbfabb restire: Support of AVX512-FP16 Instructions
Add support for AVX512-FP16 instructions and the associated
handling. Allow "mapN" syntax as well as "mN" syntax to match the
documentation.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 12:21:23 -08:00
H. Peter Anvin
e87647e2c9 Merge remote-tracking branch 'photograveur/doc_unimacro' 2022-11-07 12:16:51 -08:00
H. Peter Anvin
a131b1129c preproc: fix use of free() instead of nasm_free()
free() and nasm_free() are required to be compatible (as we may end up
having memory allocated on the heap by the C library), but that
doesn't mean we shouldn't use it whereever possible to allow for
better debugging.

Fixes: https://bugzilla.nasm.us/show_bug.cgi?id=3392804
Reported-by: C. Masloch <pushbx@ulukai.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 12:09:04 -08:00
H. Peter Anvin
7b8cd67d51 preproc: add warning for empty %{} construct
An empty %{} becomes % which is simply the arithmetic
operator. Although that is consistent, it might be surprising for
users, to issue a warning.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 12:01:00 -08:00
H. Peter Anvin
baae422e61 preproc: an empty %[] construct generates a null token, drop
%[] amounts to an empty token; this needs to be handled specially so
that it gets properly dropped.

Fixes: https://bugzilla.nasm.us/show_bug.cgi?id=3392806
Reported-by: C. Masloch <pushbx@ulukai.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 11:47:22 -08:00
H. Peter Anvin
2d4e695241 quote_for_pmake: fix counter underrun resulting in segfault
while (nbs--) { ... } ends with nbs == -1. Rather than a minimal fix,
introduce mempset() to make these kinds of errors less likely in the
future.

Fixes: https://bugzilla.nasm.us/show_bug.cgi?id=3392815
Reported-by: <13579and24680@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 10:26:03 -08:00
H. Peter Anvin
7a2b5c9221 x86/insns.dat: fix VCVTNEPS2BF16
The VCVTNEPS2BF16 instruction was incorrectly specified as
VCVTNE2S2BF16. Fortunately, the correct opcode for the latter was
specified first, so it would emit the correct result when that
instruction was specified.

Fixes: https://bugzilla.nasm.us/show_bug.cgi?id=3392821
Reported-by: Agner <agner@agner.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 10:03:45 -08:00
H. Peter Anvin
7351302477 output/elf: remove efmt->rela_size
There are no use cases for of RELA on i386, and the intent has always been
that efmt->rel_size would be the size of the desired relocation
section type. Rename it from rel_size to relsize to make it more
obvious that it matches efmt->reltype rather than SHT_REL, and delete
efmt->rela_size to keep it from being misused again.

This should avoid a repeat of:

    https://bugzilla.nasm.us/show_bug.cgi?id=3392807

fixed in adf7507e29.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 09:54:33 -08:00
Kai Burghardt
d88660fc1e
document %imacro%unimacro (case-insensitive)
There is no documentation of the `%unimacro` directive.
This is particularly confusing when you’re trying to remove a macro
that has previously been defined with the `%imacro` directive.
2022-10-09 19:24:41 +00:00
H. Peter Anvin
bb1233ccde Add FRED instructions
Add the FRED instructions: ERETU, ERETS, LKGS

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-10-05 13:31:30 -07:00
H. Peter Anvin
91580319bc Merge remote-tracking branch 'github/nasm-2.15.xx' 2022-10-05 12:31:33 -07:00