Commit Graph

4339 Commits

Author SHA1 Message Date
H. Peter Anvin
5282cea85b Merge branch 'master' of ssh://repo.or.cz/nasm
Resolved Conflicts:
	asm/preproc.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-06-06 16:26:22 -07:00
H. Peter Anvin
249c217070 quote: drop merging of adjacent strings; allow some control chars
The merging of adjacent ' or " strings really does nothing but
introduce gratuitous incompatiblities; drop it.

Allow *some* control characters (BEL BS TAB ESC) in
nasm_unquote_cstr().

The ` state machine can be greatly simplified by treating \0 as just
another character and let it terminate the string in appropriate
contexts, just like `. The only difference with ` is when it occurs
in state st_backslash: you can't escape the null character.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-06-06 16:21:01 -07:00
Chang S. Bae
0995aa24aa outbin: Fix infinite dashes written to map file
Unfortunately, there is an assumption that the section name is bounded to '65'
characters and dashes have been appended so far. A simple fix for this report:

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

We may need to cleanup further for those hardcoded numbers in decorating the
section info.

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2019-06-02 23:51:35 +03:00
Chang S. Bae
55f3dd5792 insns.dat: Fix MOVDDUP instruction
https://bugzilla.nasm.us/show_bug.cgi?id=3392554

Suggested-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2019-06-02 23:51:31 +03:00
Chang S. Bae
fea22697e2 preproc: Fix the initial enum value in stdmac_ptr()
TOKEN_ID is from enum pp_token_type, but struct Type has enum
token_type. TOK_ID seems to be a matched one.s

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
2019-06-02 23:51:25 +03:00
H. Peter Anvin (Intel)
1a254898e7 file.c: the "rb" os_fopen() flags are static in two places, simplify
We can still allocate these as a static array, just not a static
string.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-05-15 13:20:38 -07:00
H. Peter Anvin (Intel)
471120f485 file.c: handle long pathnames on Windows
Windows supports pathnames up to 32767 UTF-16 characters, but using
the standard interfaces only up to 260 characters. Wrap the functions
that take filenames on Windows.

Clean up the compatiblity layers some more for reduced #ifdefs.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-05-15 13:07:21 -07:00
H. Peter Anvin (Intel)
a7afe276da preproc: factor out getting a line of tokens and detokenizing it
Split the code for getting a line of tokens from the code that sets
verror and detokenizes the resulting string.

While we are at it, merge the handling of EOF and ^Z into the general
loop in read_line().

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-04-26 00:34:04 -07:00
H. Peter Anvin (Intel)
41e9682efe preproc: massive cleanup of smacro expansion
The smacro expansion code was virtually impossible to understand, and
was leading to very strange failures. Clean it up, and do much better
handling of magic macros.  This should also allow for recursive
macros, but recursive macros are extremely tricky in that it is very
hard to keep them from recursing forever, unless there is at least one
argument which is never expanded. They are not currently implemented.

Even so, I believe token pasting makes it possible to create infinite
loops; e.g.:

%define foo foo %+

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-04-25 18:00:32 -07:00
H. Peter Anvin (Intel)
6189133363 Merge remote-tracking branch 'origin/nasm-2.14.xx' 2019-04-24 11:15:14 -07:00
H. Peter Anvin (Intel)
9bb55bd127 Merge branch 'evalmacro'
Resolved Conflicts:
	asm/preproc.c
	output/elf.h
	output/outelf.c
	output/outelf.h
	version

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-04-24 11:14:43 -07:00
H. Peter Anvin (Intel)
2680152a80 Merge remote-tracking branch 'origin/nasm-2.14.xx' into nasm-2.14.xx 2019-04-24 10:58:14 -07:00
H. Peter Anvin
bb42d30737 quote: disallow control characters in C strings; concatendate; cleanups
In nasm_unquote_cstr(), disallow any control character, not just
NUL. This will matter when allowing quoting symbols.

Merge nasm_unquote() and nasm_unquote_cstr().

Strings can now be concatenated, C style: adjacent quoted strings
(including whitespace-separated) are merged into a single string.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-04-22 14:34:22 -07:00
Cyrill Gorcunov
982186a1a3 preproc: Fix nil dereference on error paths
https://bugzilla.nasm.us/show_bug.cgi?id=3392562

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2019-03-16 23:19:12 +03:00
H. Peter Anvin
8b26247442 preproc: add %i... variants, evaluated macro parameters, cleanups
All directives which create single-line macros now have %i... variants
to define case-insensitive versions. Case insensitive rather sucks,
but at least this way it is consistent.

Single-line macro parameters can now be evaluated as a number, as done
by %assign. To do so, declare a parameter starting with =, for
example:

%define foo(x,=y) mov [x],macro_array_y

... would evaluate y as a number but leave x as a string.

NOTE: it would arguably be better to have this as a per-instance
basis, but it is easily handled by having a secondary macro called
with the same argument twice.

Finally, add a more consistent method for defining "magic" macros,
which need to be evaluated at runtime. For now, it is only used by the
special macros __FILE__, __LINE__, __BITS__, __PTR__, and __PASS__.

__PTR__ is a new macro which evaluates to word, dword or qword
matching the value of __BITS__.

The magic macro framework, however, provides a natural hook for a
future plug-in infrastructure to hook into a scripting language.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-02-26 14:00:54 -08:00
H. Peter Anvin
a8604c83fa ELF: the .note section should be 4-byte aligned
The ELF .note section contains of 4-byte words and should be aligned
accordingly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-02-26 02:36:15 -08:00
H. Peter Anvin
dc5939b496 Handle more ELF section types
note, preinit_array, init_array, and fini_array are ELF section types
that can matter to the assembly programmer.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-02-26 01:44:55 -08:00
H. Peter Anvin
b2004511dd ELF: handle more than 32,633 sections
Dead code elimination in ELF uses separate ELF sections for every
functions or data items that may be garbage collected. This can end up
being more than 32,633 sections which, when the ELF internal and
relocation sections are added in, can exceed the legacy ELF maximum of
65,279 sections.

Newer versions of the ELF specification has added support for much
larger number of sections by putting a place holder value (usually
SHN_XINDEX == 0xffff, but 0 in some cases) into fields where the
section index is a 16-bit value, and storing the full value in a
diffent place: the program header uses entries in section header 0,
the symbol table uses an auxiliary segment with the additional
indicies; the section header did not need it as the sh_link field is
already 32 (or 64) bits long.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-02-26 00:02:35 -08:00
H. Peter Anvin
437e0ffa01 SAA: allow seeking beyond the end of the array
If putting the file pointer past the end of the array, expand the
array with zeroes.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-02-25 21:02:18 -08:00
H. Peter Anvin
efee3ea312 configure.ac: add --enable-profiling option
Add option to enable profiling without having to modify Makefile.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-02-25 21:00:43 -08:00
H. Peter Anvin
0bddd0f1b1 autoconf: move aux directory, define AC_CONFIG_AUX_DIR()
The name "aux" is reserved on Windows platforms, a legacy from CP/M
via MS-DOS. Rename it to "helpers".

Turns out that that directory wasn't actually used properly, because
AC_CONFIG_AUX_DIR was never defined, and there was a redundant copy of
install-sh checked into the base of the source tree.

Reported-by: Ehsan Alem Mohammad Ghasemlou <e.ghasemloo@gmail.com>
NASM-Bugzilla: https://bugzilla.nasm.us/show_bug.cgi?id=3392560
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-02-22 01:18:04 -08:00
H. Peter Anvin
69fa3c2e8e outelf: hash sections for performance
Use a hash table to look up sections by name, and an RAA to look up
sections by index; thus remove O(n) searches. This becomes important
since ELF uses sections for dead code elimination.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-01-12 00:35:20 -08:00
H. Peter Anvin (Intel)
d7450a6478 sectalign: "sectalign on|off" should not affect an explicit directive
sectalign on|off is documented to only affect the align/alignb
directives, *not* an explicit sectalign directive. This is fairly
obviously the proper behavior, so make it work accordingly.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-01-11 13:24:36 -08:00
H. Peter Anvin (Intel)
5a3b4d3802 alignb: disable warnings for use in a progbits section
Allow the alignb directive to be used in either a progbits or a nobits
section, by suppressing the zeroing warning.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-01-11 13:15:35 -08:00
H. Peter Anvin (Intel)
1df7263ae9 warnings: add [warning push] and [warning pop]
Add [warning push] and [warning pop] directives.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-01-11 13:13:03 -08:00
H. Peter Anvin (Intel)
38ddb19977 Warnings: move zeroing reserved space to a separate warning class
Zeroing reserved space in a progbits section really should be a
separate warning class, so it can be controlled independently.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-01-11 12:27:02 -08:00
H. Peter Anvin
52266ad424 NASM 2.14.03rc2 2018-12-30 07:56:59 -08:00
H. Peter Anvin
88477764f3 ELF: add support for the ELF "merge" attribute
Add support for the "merge" attribute in ELF, along with the
associated "strings" and size specifier attributes.

Fix a few places where we used "int", but a larger type really ought
to have been used.

Be a bit more lax about respecifying attributes. For example, align=
can be respecified; the highest resulting value is used.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-30 07:54:48 -08:00
H. Peter Anvin
ef4f23d76a tokhash.pl: zero all the fields for a not-found token
Make sure we zero all the token fields if we don't find something in
the hash.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-29 20:14:50 -08:00
H. Peter Anvin
6a4f0b36c8 tokens.dat: TOKEN_SIZE sizes belong in inttwo, not in flags
TOKEN_SIZE size values ended up in the wrong place, which caused
parser errors due to being mistaken as flags.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-29 20:13:35 -08:00
H. Peter Anvin
e88f752e67 nasmlib.h: clarify the semantics of nasm_aprintf_size()
nasm_aprintf_size() does include the final NUL byte, but does not
include any prefix storage allocated by nasm_[v]axprintf().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-27 12:50:56 -08:00
H. Peter Anvin
4c50b6c892 Move <strings.h> inclusion to "compiler.h"
Move the inclusion of <strings.h> from nasmlib.h to compiler.h

Try to centralize compiler dependences as much as possible.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-27 12:46:55 -08:00
H. Peter Anvin
8960e1bc83 Remove #includes already provided by "compiler.h"
"compiler.h" already includes a bunch of common include files. There
is absolutely no reason to duplicate them in individual files, and in
fact it robs us of central control of how these files are used.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-27 12:45:44 -08:00
H. Peter Anvin
c2f3f26015 Replace <ctype.h> includes with "nctype.h"
For almost everything we should use "nctype.h". Right now we don't
have a nasm_toupper() to use <ctype.h> for things that need toupper().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-27 12:37:25 -08:00
H. Peter Anvin
bd2803964e Merge tag 'nasm-2.14.03rc1'
NASM 2.14.03rc1

Resolved Conflicts:
	asm/labels.c
	include/error.h

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-27 11:37:22 -08:00
H. Peter Anvin
81f98fe79b NASM 2.14.03rc1 2018-12-27 11:34:12 -08:00
H. Peter Anvin
8eedebc1ed changes.src: document suppressed messages
Document the suppression of error messages from "label changed".

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-27 11:32:42 -08:00
H. Peter Anvin
4cf86ddde8 BR 3392539: some errors can "cascade". Allow suppressing if dead.
In BR 3392539, the error:

helloW.s:18: error: label `rurt' changed during code generation
[-w+error=label-redef-late]

... occurs a number of times after we have already issued an
error. This is because the erroring instruction computes to a
different size during code generation; this causes each subsequent
label to cause a phase error.

The phase error simply doesn't make much sense to report: if we are
already committed to erroring out, it is more likely an error cascade
rather than an error in its own right, so just suppress it in that
case.

Reported-by: <russvz@comcast.net>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-27 11:24:17 -08:00
H. Peter Anvin
2f0f5b0189 Merge tag 'nasm-2.14.02'
NASM 2.14.02

Resolved Conflicts:
	asm/listing.c
2018-12-26 07:15:28 -08:00
H. Peter Anvin
38a96f0e06 compiler.h: need to cast a (void *) to (char *) before adding
In the implementation of mempcpy():

Doing arithmetic on (void *) isn't permitted, so we need to cast it to
(char *); it then get automatically converted to void * by the return.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-26 06:49:18 -08:00
H. Peter Anvin
a162092532 nasmlib/ver.[ch]: add "compiler.h"
We should use "compiler.h", not just include <stdlib.h> explicitly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-26 06:37:25 -08:00
H. Peter Anvin
2e53f27e9d Move <string.h> inclusion to compiler.h
There is absolutely no reason not to include <string.h> globally, and
with the inline function for mempcpy() we need it there anyway.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-26 06:32:37 -08:00
H. Peter Anvin
0a2b1c3498 Mkfiles: run "make cleandist"
Run "make cleandist" to update the file lists.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-26 06:31:54 -08:00
H. Peter Anvin
06f72bb968 Test for the mempcpy() function and add alternative if missing
If memcpy() doesn't exist, then add an inline alternative using
memcpy().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-26 06:22:47 -08:00
H. Peter Anvin
77703ae4a4 nasm.spec.in: remove obsolete files
README and TODO are deleted and CHANGES is meaningless.
2018-12-26 06:13:06 -08:00
H. Peter Anvin
2e9a6e870f TODO: delete completely obsolete file 2018-12-26 06:12:13 -08:00
H. Peter Anvin
72f2acc595 nasm.spec.in: we need *automake*; autoheader is in autoconf
We need the automake package for autogen.sh; the autoheader program is
in the autoconf package.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-26 06:06:02 -08:00
H. Peter Anvin
33ce149330 nasm.spec.in: need autoheader, use autogen.sh
We need to use our new autogen.sh, which in turn needs autoheader.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-26 06:03:57 -08:00
Cyrill Gorcunov
74246c499e NASM 2.14.02 2018-12-26 16:41:15 +03:00
H. Peter Anvin
b3f7c8eb2b tools/release: handle new binary files
With the travis tests, we have a lot more binary files to worry about.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-26 05:11:26 -08:00