Commit graph

3270 commits

Author SHA1 Message Date
Cyrill Gorcunov
9e8c2466a4 nsis: Import x64.nsh
From NSIS-3.0 source code (Include/x64.nsh).
Hopefully it will be enough for nsis-v2.5
to support Win64.

https://sourceforge.net/p/nsis/code/HEAD/tree/NSIS/trunk/Include/x64.nsh

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-10-23 16:27:44 +03:00
H. Peter Anvin
f5287231c1 Move canned OpenWatcom config to config/watcom.h.
Move the canned OpenWatcom configuration file to config/watcom.h.
Also exclude config/config.h from being a dependency for MSVC.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-19 13:23:04 -07:00
H. Peter Anvin
4c9132e3a0 compiler.h: include <sys/types.h>
Apparently, at least on some OS/2 compilers, <sys/types.h> needs to be
included for off_t to be defined.  This seems like a generically good
idea to include this header whenever it is available.

Remove reference to <types.h>.  This was supposedly for MSVC, but
there is no actual evidence that it is useful beyond <sys/types.h>.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-19 13:13:38 -07:00
H. Peter Anvin
1fe546cf35 Run make alldeps
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-14 15:09:52 -07:00
H. Peter Anvin
44e3a11087 compiler.h: fix typo in the non-gcc case
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-14 15:05:28 -07:00
H. Peter Anvin
9b733a5845 compiler.h: for newer gcc attributes, we can use __has_attribute()
For newer gcc attributes, we can use __has_attribute() to test for
attribute presence.  This improves compatibility both with older gcc
and with clang, at least with -Werror enabled.

Reported-by: Daniel Lundqvist <daniel@malarhojden.nu>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-14 15:01:06 -07:00
H. Peter Anvin
9df6b4c8c2 output/legacy.c: include outlib.h
Add outlib.h for the prototype of nasm_do_legacy_output().

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-06 14:19:02 -07:00
H. Peter Anvin
8220533cda rdoff/rdlar.h: include "compiler.h" not "config.h"
We should not include config.h "naked"; include "compiler.h".

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-06 14:18:21 -07:00
H. Peter Anvin
c58b4c3c76 distclean: clean up config/config.h
When doing "make distclean", clean config/config.h as config.h has
moved.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-06 14:17:38 -07:00
H. Peter Anvin
93c93b0a2e alldeps: handle uses of full pathnames, e.g. "config/config.h"
Sometimes we really want to use an extended pathname for an include
file, for documentation purposes; e.g. "config/config.h".  This makes
alldeps handle that case correctly (and also adds the config/
directory to directories scanned by alldeps).

It is unclear if this will work correctly if there are include files
with the same name in different directories, but we currently do not
have any case like that.

Reported-by: anonymous coward <nasm64developer@users.sf.net>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-06 14:12:39 -07:00
H. Peter Anvin
194751404b nasmint.h: change header guards to NASM_NASMINT_H
Change the header guards for nasmint.h to NASM_NASMINT_H instead of
INTTYPES_H.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 18:11:57 -07:00
H. Peter Anvin
4b189f89d0 nasmint.h: add support for the MSVS < 2005 __int64 type
MSVS < 2005 doesn't have "long long", so use the MSVC-specific
__int64, I64, and ...[u]i64 constructs.  nasmint.h makes this easy
enough that it is worth doing.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 18:09:01 -07:00
H. Peter Anvin
2024ae60d6 config/msvc.h: inttypes.h and stdbool.h introduced in MSVS 2013
<inttypes.h> and <stdbool.h> were introduced in MS Visual Studio 2013,
not 2015.  See:

https://blogs.msdn.microsoft.com/vcblog/2013/07/19/c99-library-support-in-visual-studio-2013/

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 17:50:53 -07:00
H. Peter Anvin
276785a8ff config: add configuration file for unknown compilers
Add a config header file for the most conservative case of a totally
unknown compiler.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 17:13:50 -07:00
H. Peter Anvin
397c169736 Move config.h to a subdirectory, add MSVC-specific config file
Instead of trying to do hacks in the Makefiles, define header files
for specific compilers if they can't use autoconf.  Currently defined
for Microsoft Visual Studio, based on MSDN documentation.  It is
currently untested.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 17:01:59 -07:00
H. Peter Anvin
9255b51369 test: simple pragma preprocessor test
Simple test to examine the preprocessor output from %pragma.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 15:01:34 -07:00
H. Peter Anvin
bc7f4fe275 preproc: add plumbing for the %pragma directive
Plumb the %pragma directive through the preprocessor and make it
generate an assembly directive unless given as %pragma preproc.  So
far no actual pragmas are actually defined.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 14:57:17 -07:00
H. Peter Anvin
76c49379b7 test/Makefile: add rule to generate preprocessor output
Add a rule in the test directory to run the preprocessor.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 14:56:37 -07:00
H. Peter Anvin
e93572e6be Merge remote-tracking branch 'origin/nasm-2.12.xx' 2016-10-04 14:09:07 -07:00
H. Peter Anvin
3f87a2ac50 preproc: add dummy %pragma directive
In future versions of NASM we will presumably have "real" pragmas; add
dummy support for the %pragma directive for forward compatibility.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 14:07:19 -07:00
Daniel Lundqvist
439875c1d9 ldrdf: Remove output file if there are any errors
If there are any errors while linking, we should not create an
output file.

Signed-off-by: Daniel Lundqvist <daniel@malarhojden.nu>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-04 03:36:27 -07:00
H. Peter Anvin
436e367874 Factor out common string list handling code
Simplify the preprocessor code by factoring out the common string list
handling code.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-04 01:12:28 -07:00
H. Peter Anvin
9924d1ea85 preproc: clean up handing of the dependency lists
We search the dependency list anyway (ouch...) so we might as well
use that instead of keeping track of a tail pointer.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-04 00:59:39 -07:00
H. Peter Anvin
ccad6f929f preproc: return found_path as a constant string
Always return found_path as a constant string.  We end up making an
internal copy of it anyway to put in the fullpath hash, so there is no
reason to make a duplicate of it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-04 00:34:35 -07:00
H. Peter Anvin
da8659dfd0 Merge remote-tracking branch 'origin/nasm-2.12.xx'
Resolved Conflicts:
	version

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-04 00:30:17 -07:00
H. Peter Anvin
ce63783e85 changes.src: typographical adjustment
Extremely minor typographical fix.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-04 00:04:44 -07:00
H. Peter Anvin
20a38e43e4 NASM 2.12.03rc1 2016-10-03 23:57:44 -07:00
H. Peter Anvin
6a6a40c268 changes.src: document CLWB and PCOMMIT
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-03 23:37:51 -07:00
H. Peter Anvin
9b630b4361 insns: add OBSOLETE flag for instructions removed from architecture
There aren't that many instructions which have been rmeoved from the
x86 architecture, but there is a handful.  Flag those with an OBSOLETE
flag.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-03 23:35:25 -07:00
H. Peter Anvin
a617487b50 Add the CLWB and (already deprecated) PCOMMIT instructions
Add the CLWB and PCOMMIT instructions.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-03 23:23:02 -07:00
H. Peter Anvin
5e0d3b773f changes.src: update for a 2.12.03 release
We seem to have accumulated enough fixes that it ought to be time for
a 2.12.03 release.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-03 23:01:58 -07:00
H. Peter Anvin
e346b3b4a0 assemble: avoid redundant repetition in RESx warning message
Clean up the language in this warning message, so as not be so
unnecessarily repetitive.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-03 22:45:23 -07:00
H. Peter Anvin
c5d40b3576 assemble: print a warning on a forward reference in RESx
Print a warning on a forward reference in RESx.  This really should
have been a critical expression, and a forward reference should have
been an error, but it wasn't implemented that way and as such we can't
just randomly break people's code, even if it is dangerous.
2016-10-03 22:18:31 -07:00
H. Peter Anvin
55568c1193 nasm: scan the command line twice
Scan the command line twice, so we among other things can set up the
proper preprocessor before calling any of the preprocessor entry
points.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-03 19:46:49 -07:00
H. Peter Anvin
169ac7c152 Add a hash for pathname searches, instead of searching very pass
We have been doing a pathname search every time we encounter a file,
which means every file in every pass.  Instead, put the pathnames
found in a hash table.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-09-25 17:08:05 -07:00
H. Peter Anvin
96921a5ad8 backend: psas inslen == 0 to the backend for the INCBIN case
An INCBIN "instruction" can be enormous (up to an off_t size.)  There
is no reason to burden the rest of the code by widening the inslen and
insoffs fields just for INCBIN, so set inslen == 0 to indicate fields
not valid.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-09-24 09:53:03 -07:00
H. Peter Anvin
fa803abc61 backend: move wrapper for legacy output functions to a library routine
Move the wrapper for legacy output into a library routine so the
backends can be ported one at a time.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-09-24 09:46:47 -07:00
H. Peter Anvin
04445364fc incbin: if we have to fread(), try to do it only once...
If we can't mmap a file and instead have to fread(), if the data is
small enough that we can reasonably accomodate it in a memory buffer,
then just read it once.

It seems rather unlikely that very large files would be used with
TIMES anyway.

Also note: the previous comment about nasm_file_size[_by_path]() being
invoked twice was spurious; it does not actually happen.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-09-21 15:56:19 -07:00
H. Peter Anvin
d81a235f33 file: improve the file access interface
A number of fairly common operations are invoked way too many times,
especially when using incbin.  Drastically reduce the number of system
calls that need to be executed, and use memory mapping to reduce
unnecessary double buffering.

We could improve this further by leaving files open once used;
however, that might run into file count problems on some systems.

Still unclear is why we seem to invoke nasm_file_size() twice per pass
for incbin.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-09-21 14:07:17 -07:00
H. Peter Anvin
c170089e7c nasmlib: move fseeko/ftello/off_t replacements to nasmlib.h
Move fseeko, ftello, and off_t definitions to nasmlib.h so that files
other than nasmlib/file.c can use them (already added to
asm/assemble.c).

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-09-20 18:26:42 -07:00
H. Peter Anvin
e8b01c6f72 Merge remote-tracking branch 'origin/nasm-2.12.xx'
Bring the branches in sync.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

Resolved Conflicts:
	Makefile.in
	Mkfiles/msvc.mak
	Mkfiles/netware.mak
	Mkfiles/openwcom.mak
	Mkfiles/owlinux.mak
	asm/assemble.c
2016-09-20 16:51:19 -07:00
H. Peter Anvin
637b9cc581 Correct /is4 encoding for EVEX instructions
For EVEX instructions, /is4 can contain a fifth register bit, encoded
in bit 3 of the imm8.  Properly generate this case, and simplifiy the
/is4 generation code somewhat.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

Cherry picked and ported from nasm-2.12.xx commit
976ba73062.

Resolved Conflicts:
	asm/assemble.c
2016-09-20 16:48:17 -07:00
H. Peter Anvin
976ba73062 Correct /is4 encoding for EVEX instructions
For EVEX instructions, /is4 can contain a fifth register bit, encoded
in bit 3 of the imm8.  Properly generate this case, and simplifiy the
/is4 generation code somewhat.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-09-20 16:39:46 -07:00
H. Peter Anvin
a77692b34d New backend interface - assembler internals #1
This provides the first pass of assembler internals for a new, richer,
backend interface.  It also reduces the amount of data carried in
function parameters inside the assembler.

The new interface is in the form of a structure, which will contain
substantially more information that the previous interface.  This will
allow things like ELF GOT32X and Mach-O X86_64_RELOC_BRANCH
relocations to be reliably emitted.

This provides the initial set of structures.  Future additions should
include:

1. Pass down the base symbol, if any.
2. Segments should be a structure rather than a number, and the
   horrible hack of adding one for a segment reference should be
   removed (OUT_SEGMENT replaces it.)

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-09-20 16:05:09 -07:00
H. Peter Anvin
9938bb6333 outelf: add panic() for unknown output types
If we get an output type we don't know how to handle, do a panic()
rather than a compile-time error; this will be necessary in the short
time pending a change to the backend interface.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-09-20 14:00:56 -07:00
Andy Willis
3f546034f3 nasm: Add --version option
Alias for known -v shorthand.

Signed-off-by: Andy Willis <abwillis1@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-09-13 00:02:21 +03:00
H. Peter Anvin
7a82ebe7bd disp8: make constant arrays in get_disp8N() static
The constant arrays in get_disp8N() should be static; otherwise the
compiler has to manifest them on the stack for every execution which
makes no sense at all.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-08-25 17:40:13 -07:00
Henrik Gramner
ae707bace4 insns.dat: Enable contracted forms for additional instructions
Improve consistency by allowing contracted forms for EVEX-encoded
instructions when it's allowed for similar VEX-encoded instructions.

Previously the behavior would change depending on the vector size or
the register number which could be somewhat confusing:

    vaddps xmm0, xmm1  ; ok
    vaddps ymm0, ymm1  ; ok
    vaddps zmm0, zmm1  ; error
    vaddps xmm0, xmm16 ; error

Also allow contracted forms for a few additional older AVX instructions
where it makes sense.

Signed-off-by: Henrik Gramner <henrik@gramner.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-08-25 17:22:40 -07:00
Henrik Gramner
4098f5655f insns.dat: Fix EVEX vpbroadcast(b|w), vpextr(b|w), and vpinsr(b|w)
Use the correct T1S compressed displacements.

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

Signed-off-by: Henrik Gramner <henrik@gramner.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-08-25 17:22:34 -07:00
Fabian Giesen
0cb6739ba4 output: elf -- Generate SHT_RELA relocs for elfx32/elf64 stabs
stabs is the default debug format and GNU gold dies with an assertion
failure when it encounters a SHT_REL section in an x64 ELF file.

Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-08-18 00:51:36 +03:00