Commit graph

3764 commits

Author SHA1 Message Date
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
Cyrill Gorcunov
51b453b097 output: elf,ieee,macho,obj -- Fix mofule name for commit 81b62b9f54
These modules need a reference to input filename.
For example elf put into symbol table

 | SYMBOL TABLE:
 | 0000000000000000 l    df *ABS*	0000000000000000 sha-64.asm

Otherwise this  become empty string.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-25 15:50:35 +03:00
Cyrill Gorcunov
8a231080e0 get_cpu: Fix a7ecf2646d
The call to iflag_clear_all has been occasionally dropped,
bring it back.

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

Reported-by: sezeroz@gmail.com
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-25 13:25:19 +03:00
Cyrill Gorcunov
fff27ab229 compiler: Fix typo in 6686fc6
https://bugzilla.nasm.us/show_bug.cgi?id=3392464

Reported-by: sezeroz@gmail.com
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-24 15:11:32 +03:00
H. Peter Anvin
b9fa743974 openwcom.mak: use \ as path separators
Apparently OS/2 really wants \ as path separators, and that is really
the main target for OpenWatcom these days, so change the path
separator in this Makefile.  For building on Linux we'd be better off
with a GNU Makefile anyway, but what is the point, really...

Reported-by: Andy Willis <abwillis1@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-02-22 15:02:42 -08:00
H. Peter Anvin
281f5bd92c Merge branch 'master' of ssh://repo.or.cz/srv/git/nasm 2018-02-22 14:53:46 -08:00
H. Peter Anvin
6686fc627e Introduce cold function attribute
Attribute to deemphasize certain code paths.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-02-22 14:52:50 -08:00
H. Peter Anvin
6feef84f25 outbin: check the status of lookup_label()
Make sure we actually found the label we looked at, to avoid undefined
behavior.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-02-22 14:51:59 -08:00
H. Peter Anvin
7418883b62 outelf: fix possibly uninitialized variable
Fix possibly uninitialized variable "currfile".

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-02-22 14:51:26 -08:00
H. Peter Anvin
4dbf3a96a4 Merge remote-tracking branch 'origin/nasm-2.13.xx'
Resolved Conflicts:
	version

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-20 12:40:11 -08:00
H. Peter Anvin
99d45c850e Fix problem with C99 inlines and -Werror=missing-prototypes
Some older versions of gcc (gcc 4.2.1 at least) produce a warning,
promoted to error, on C99 inlines.  Do some work to figure out if we
need to fall back to GNU inline syntax.

Fix some issues with GNU inline syntax.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-20 12:34:17 -08:00
H. Peter Anvin
f71820d605 version: bump to 2.13.04rc0 until we have an actual -rc
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-14 11:13:05 -08:00
H. Peter Anvin
8524e16303 insns.dat: add aliases of the RET instruction with explicit operand size
Make it possible to generate variants of RET(F) with explicit operand
size specified without having to use o16/o32/o64.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-14 11:09:07 -08:00
Cyrill Gorcunov
53371ddd17 Merge branch 'nasm-2.13.xx'
* nasm-2.13.xx:
  nasmlib: Drop pure_func attrib from seg_alloc
  nasmlib: Drop unused seg_init
2018-02-10 00:44:07 +03:00
Cyrill Gorcunov
9f45a77f46 nasmlib: Drop pure_func attrib from seg_alloc
It not only reads static variable but writes it back as well.

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

Reported-by: Michael Šimáček <msimacek@redhat.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-10 00:40:46 +03:00
Cyrill Gorcunov
5eb1838b4d nasmlib: Drop unused seg_init
The helper has been eliminated in 2c4a4d5810

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

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-10 00:34:10 +03:00
H. Peter Anvin
3366e31b8a asm: allow abort on panic to be specified at runtime
New option --abort-on-panic to make debugging easier.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-07 14:14:36 -08:00
H. Peter Anvin
1b53750430 Merge tag 'nasm-2.13.03'
NASM 2.13.03

Resolved Conflicts:
	include/iflag.h
	version
	x86/insns-iflags.ph

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-07 13:51:54 -08:00
H. Peter Anvin
ef7d18bfbb NASM 2.13.03 2018-02-07 13:38:58 -08:00
H. Peter Anvin
cb7b097b3e doc: some more documentation on 64-bit programming
Some more information about 64-bit programming and its quirks.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-07 12:28:42 -08:00
H. Peter Anvin
ddea5fc0cd doc: clarify need for ABS QWORD to do a 64-bit absolute load
The rarely used 64-bit absolute load instruction (what gas calls
movabsq) needs to be declared ABS if we are in relative mode, which is
normally the case.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-07 11:19:26 -08:00
H. Peter Anvin
f53c9778cd doc: add a bit more text about 64-bit immediates and pointers
There are some gotchas in how immediates and pointers are loaded in
64-bit mode and how they interact with optimization.  Document those
cases.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-07 11:16:20 -08:00
H. Peter Anvin
22d3a2b601 NASM 2.13.03rc6 2018-02-07 10:54:08 -08:00
H. Peter Anvin
73c804c31e doc/changes.src: add missing blank line between bullet points
Bullet points are considered paragraphs, so our documentation compiler
require an empty line between them.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-07 10:52:50 -08:00
H. Peter Anvin
75b35503fa vaesenc.asm: add a few more test cases
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-07 10:48:13 -08:00
H. Peter Anvin
7514970ffe NASM 2.13.03rc5 2018-02-06 14:52:02 -08:00
H. Peter Anvin
d08b1c4370 Merge remote-tracking branch 'origin/nasm-2.13.xx' into nasm-2.13.xx
Resolved Conflicts:
	include/iflag.h

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-06 14:50:08 -08:00