Commit graph

3790 commits

Author SHA1 Message Date
H. Peter Anvin
ef4e5e209f .gitignore: add asm/directbl.h
asm/directbl.h was missing from .gitignore, making this generated file
show up as a file not checked in.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-18 11:38:47 -07:00
H. Peter Anvin
1bcc1e012a test: test for ELF symbol visibility
Add test for declaring ELF visibility.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-18 11:37:17 -07:00
H. Peter Anvin
f7be8b3253 pragma: define a hander for generic output (and debug) pragmas
There are cases where we may want to implement generic pragmas, while
still make them selective based on output and/or debug formats.
Initially, use this for the prefix/suffix options.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: Chang Seok Bae <chang.seok.bae@intel.com>
2018-06-18 11:34:33 -07:00
H. Peter Anvin
41103ab431 test/Makefile: qualify the names of list files with output format
It is quite likely we may want to build the same input with multiple
output formats; make it so we don't lose the list file.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-18 11:30:48 -07:00
H. Peter Anvin
8eb3096f7a nasm.h: remove unused constants
Remove unused constants for prefix and suffix, long since obsolete.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-18 11:12:49 -07:00
H. Peter Anvin
fee097f724 NASM 2.14rc5 2018-06-16 00:16:12 -07:00
H. Peter Anvin
854730bf62 insns.dat: update with instructions from ISE 319433-034
Add instructions from the Intel Instruction Set Extensions and Future
Features Programming Reference, document 319433-034, May 2018.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-06-16 00:13:58 -07:00
H. Peter Anvin
79561027a0 Make limits 64 bits, add globallines limit to configurable limits
Make all limit counters 64 bits, in case someone really has a usage
for an insanely large program. The globallines limit was omitted, add
it to the list of configurable limits.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-06-15 17:57:15 -07:00
H. Peter Anvin
675618c5dd Makefile.in: remove duplicated $(ALL_CFLAGS)
We really don't need every C compiler flag repeated twice.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-06-15 17:41:46 -07:00
H. Peter Anvin
14a10935f7 Merge commit '7daa26f9ba3ca45813d16ce540564448c13b16fa' into nasm-2.14.xx
Merge in some warning workarounds/possible bugs discovered by a recent
gcc.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-06-15 17:25:57 -07:00
H. Peter Anvin
430d41ede8 NASM 2.14rc4 2018-06-14 20:01:22 -07:00
H. Peter Anvin
46c839a03d labels: allocation of a segment number counts as a change
If we allocate a new segment number, that has to cause
global_offset_changed to be incremented.  Thus, we should not update
lptr->defn.segment until that would ordinarily be done.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-14 20:00:07 -07:00
H. Peter Anvin
af5f918a92 Don't keep assigning segment numbers to EXTERN or COMMON
If a symbol is EXTERN or COMMON, then we should not keep assigning it
new segment numbers over and over. Instead, change the label code so
that it assignes a new segment value if and only if one has not been
assigned before.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-14 19:53:45 -07:00
H. Peter Anvin
58ab877402 NASM 2.14rc3 2018-06-14 17:16:05 -07:00
H. Peter Anvin
b91b63d164 outmacho: don't do encoding magic in the segment index
Encoding magic (in this case, subsection number) by bitfields in the
segment index has several problems:

1. It limits the number of *external symbols* as well as
   segments/subsections.
2. It is inefficient for the assembler (creates a very large RAA).

This is also a really good opportunity for removing linear lookups in
the MachO backend. We now use an RAA to do look up segment by index,
and a hash table to look up segment by name. Subsections are simply
handled by allocating a new index using seg_alloc() but still point it
to the same section structure in the index RAA.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-14 17:14:36 -07:00
H. Peter Anvin
29695c85fb labels: add a subsection field available for backend use
Allow the subsection to store a subsection value directly in the
label, rather than having to do strange encoding hacks.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-14 17:04:32 -07:00
H. Peter Anvin
13587802fe segalloc: DO NOT reset segment numbers
We are not supposed to reset the segment numbers; this was an
attempted fix for a convergence bug that didn't actually exist. The
backend is required to return the same segment number for the same
segment; if it does not, the front end will not converge, but that is
in fact the correct behavior.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-14 16:42:03 -07:00
H. Peter Anvin
e39202c96a RAA: add functions for storing pointers in RAA's
RAAs can, and should be, usable for storing pointers as well as
integers. In reality it is exactly the same code, but make it explicit
by having different entry points.  In the actual RAA the data is
stored as a union, which in practice will not occupy any more space
than the existing code.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-14 16:05:34 -07:00
H. Peter Anvin
2ef5400ee1 NASM 2.14rc2 2018-06-12 14:24:30 -07:00
H. Peter Anvin
c805fd774d Fix parsing of long options; actually warn on bad limit
Fix the parsing of long options (arguments with = broke things.)

Actually issue a warning if we specify a wrong limit on the command
line.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-12 14:23:05 -07:00
H. Peter Anvin
987dc9c9db Make any execution limit configurable, add eval limit
Make any "deadman"-style execution limit configurable on the command
line (--limit-foo) or via a pragma (%pragma limit foo).

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-12 13:54:42 -07:00
H. Peter Anvin
d49e6dc08e NASM 2.14rc1 2018-06-11 14:56:25 -07:00
H. Peter Anvin
734824823e Unbreak special segment symbols, unbreak COMMON
Recent changes broke:

1. Backend-provided special segments, due to seg_alloc() getting
   reset.
2. COMMON; the old code would pass size in the "offset" *without*
   setting it in the label structure. Containing all this information
   in the label structure requires another field.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-11 14:54:14 -07:00
H. Peter Anvin
0599034321 Add --pragma and --before option; make --include = -P
Add --pragma to add pragmas on the command line; --before option to
add *any* statement on the command line, and add --include as an alias
for -P for familiarity with other toolchains.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-11 13:32:42 -07:00
Cyrill Gorcunov
a7f318c307 directive: Make cpu directive case insensitive back again
During code suffle we occasionally made cpu directive to
take letter case into account despite the documentation.

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

Reported-by: Rebecca Cran <rebecca@bluestop.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-06-07 00:06:58 +03:00
H. Peter Anvin
7daa26f9ba gcc: fix mistakes discovered by recent gcc
Recent versions of gcc issue a couple of warnings, which may be real
bugs.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-06-02 23:48:16 -07:00
H. Peter Anvin
c4e16f7e7c gcc: newer gcc trip on -Wstringop-truncation for valid uses of strncpy()
strncpy() is correctly used to fill in a zero-*padded* (not
zero-terminated) field in several places.  Make gcc not complain about
those uses.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-06-02 23:47:57 -07:00
H. Peter Anvin
3cb9068ee0 asm/directiv.c: fix bug in perm_alloc()
Fix dumb thinko in perm_alloc().

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-01 21:05:45 -07:00
H. Peter Anvin
69f0551f6f macho: Turn off OFMT_KEEP_ADDR
OFMT_KEEP_ADDR seems to not work properly. Now when we have proper
subsections, there is no need for that anymore.

This reverts commit 69ed82447a.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-01 18:14:16 -07:00
H. Peter Anvin
98578071b9 Cleanup of label renaming infrastructure, add subsection support
In order to support Mach-O better, add support for subsections, as
used by Mach-O "subsections_via_symbols". We also want to add
infrastructure to support this by downcalling to the backend to
indicate if a new subsection is needed.

Currently this supports a maximum of 2^14 subsections per section for
Mach-O; this can be addressed by adding a level of indirection (or
cleaning up the handling of sections so we have an actual data
structure.)

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-01 18:06:25 -07:00
H. Peter Anvin
8413e8167a test: add test for subsections via symbols
Add a test for subsections via symbols.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-05-30 14:48:45 -07:00
H. Peter Anvin
892c4818ce Add support for backend-defined subsections and label hacks
MachO has this odd thing called "subsections via symbols", by which a
symbol can magically start what effectively is a new section. To
support this, add support for a calldown into the backend when a new
symbol is defined *at the current output location*, and allow it to
switch the current segment.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-05-30 14:48:18 -07:00
H. Peter Anvin
b7136487bd pragma.c: make the generic "output" and "debug" pragma namespaces work
"output" and "debug" are supposed to redirect to the current output
and debug formats. Fix it so it actually does.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-05-30 14:42:06 -07:00
H. Peter Anvin
7310d0bd5b configure.ac: add -fvisibility=hidden if supported
None of our symbols are available for a dynamic library, and if they
were, there would be no point in allowing them to be overridden. This
optimizes code generation for global symbols.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-05-30 11:48:00 -07:00
H. Peter Anvin
740ec3572b malloc: simplify nasm_malloc code, add nasm_strcatn()
Simplify the nasm_malloc() code by moving the pointer check into a
common subroutine.

We can now issue a filename error even for failures like malloc().

Add support for the gcc sentinel attribute (verify that a list ends
with NULL).

Add a handful of safe_alloc attributes.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-05-30 11:40:42 -07:00
H. Peter Anvin
1ce81e10ef Revert "output: macho -- Check the actual size of 64-bit absolute address"
This reverts commit 69ed82447a.
2018-05-08 12:46:55 -07:00
H. Peter Anvin
6d36d8684c Fix implicit fallthrough that trips -Werror
-Werror now trips on implicit fallthroughs. There is also at least one
that probably should not be, although it appears to be harmless.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-05-08 12:45:00 -07:00
Chang S. Bae
f0ceb1e122 assemble: Check global line limit
Without the limit, the while loop opens to semi-infinite
that will exhaustively consume the heap space. Also, the
index value gets into the garbage.

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

Reported-by : Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-05-05 23:44:33 +03:00
Chang S. Bae
427d8e3e57 output: macho -- Avoid conversion of addresses to RAWDATA
Without relocation, the linker may do erroneous dead strip.
For the relocation, the conversion of addresses to RAWDATA
should be avoided for Mach-O.

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

Reported-by: Andrew Fish <afish@apple.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-05-05 23:44:33 +03:00
Chang S. Bae
69ed82447a output: macho -- Check the actual size of 64-bit absolute address
Even though the size is set to 64-bit, actual value can be
in 32-bit range. In that case, the use of such absolute
address is prevented.

The side effect of 58d2ab17 is resolved.

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

Reported-by: Richard Russell <rtrussell@gmail.com>
Reported-by: Michael Petch <mpetch@capp-sysware.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-05-05 23:43:57 +03:00
Fabian Giesen
713fd1ffc8 output: codeview -- change version number written
Windows Store and Xbox One apps need to pass WACK, the Windows App
Certification Kit, and part of that process involves a tool named
BinScope that checks the debug info of all object files making up
the final executable against a list of minimum versions.

These minimum versions get increased periodically as new SDKs and
compilers are released. In a patch 2 years ago, I made NASM
pretend it was MASM and output a then-current MASM version number.

Well, the minimum version number has increased again, and
periodically hardcoding a new random MASM version to keep BinScope
happy doesn't seem like the way to go.

It turns out that BinScope does not impose any minimum version
requirements on object files listing a source language BinScope
doesn't know about.

I have no idea how to officially request a new CodeView language
ID (or whether there even is a way to do so for someone outside
MS). But experimentally, using 'N' (0x4e) for NASM seems to be
working just fine and is far away from the range of currently
allocated language IDs (which stop at 0x10).

Long story short, make NASM emit a source language ID of 0x4e,
with the actual NASM version in the version number fields.
BinScope is happy to accept that, and since the language ID field
is purely an informational field in an optional debug info record
that (as far as I can tell) is not used for anything else, this
seems reasonably safe and unlikely to cause trouble.

Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-04-20 11:27:19 +03:00
Cyrill Gorcunov
dd6a2cdcf4 Revert "compiler: Add fallthrough() helper"
This reverts commit 8ba28e13ea.
2018-02-25 22:25:57 +03:00
Cyrill Gorcunov
72fd205bcf Revert "Use fallthrough() to placate compiler"
This reverts commit 8a7c6009fb.
2018-02-25 22:25:07 +03:00
Cyrill Gorcunov
5829bbd9ed Revert "aclocal.m4: Use Werror in PA_CHECK_FALLTHROUGH_ATTRIBUTE"
This reverts commit 8b211a0a3b.
2018-02-25 22:24:53 +03:00
Cyrill Gorcunov
8b211a0a3b aclocal.m4: Use Werror in PA_CHECK_FALLTHROUGH_ATTRIBUTE
In sake of https://bugzilla.nasm.us/show_bug.cgi?id=3392465

Suggested-by: Ozkan Sezer <sezeroz@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-25 22:01:20 +03:00
Cyrill Gorcunov
562561640d insns.dat: Update UD0 encoding to fit the specification
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-25 18:50:52 +03:00
Matthieu Darbois
9adfd34b03 output: macho -- Add support for N_PEXT in macho output
This allows to mark global symbols as private external.
Similar to visibility hidden in ELF output.

Signed-off-by: Matthieu Darbois <mayeut@users.noreply.github.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-25 17:41:54 +03:00
Cyrill Gorcunov
8a7c6009fb Use fallthrough() to placate compiler
https://bugzilla.nasm.us/show_bug.cgi?id=3392465

Reported-by: Ozkan Sezer <sezeroz@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-25 17:21:54 +03:00
Cyrill Gorcunov
8ba28e13ea compiler: Add fallthrough() helper
https://bugzilla.nasm.us/show_bug.cgi?id=3392465

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-25 17:09:11 +03:00
Cyrill Gorcunov
fb9e00a1c3 output: outobj -- Fix typo in obj_init
In 51b453b097 occasionally
used wrong operand for sizeof.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-25 16:12:34 +03:00