Commit graph

3257 commits

Author SHA1 Message Date
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
Fabian Giesen
f47f451a85 output: elf -- Fix debug info.
df_dwarf and df_stabs were orphans of the elf32/64 merge; clean up.

Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-08-18 00:51:20 +03:00
Henrik Gramner
de1fb48c3a 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-18 00:50:31 +03:00
Henrik Gramner
865c31c676 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-18 00:50:14 +03:00
H. Peter Anvin
40fc4dcb39 Run make alldeps 2016-08-16 15:06:11 -07:00
H. Peter Anvin
6e01ea2bc6 Run make alldeps
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-08-16 14:48:54 -07:00
H. Peter Anvin
3ffe8525e6 mkdep.pl: don't scan files until we know all the paths
Consistently identify dependencies by their path, not by their
basename.  This avoids missing indirect dependencies.  Furthermore, we
cannot start scanning files until we know the paths of all potential
targets.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-08-16 14:47:19 -07:00
H. Peter Anvin
43e026277b configure.ac: disable common data to avoid problems with some linkers
Disable common data to:

a) discover problems with common data as quickly as possible (we
   should not use common data as some compilers may not handle it);
b) work around a problem with the OSX linker causing it to not find
   zero_buffer even though it is defined in nasmlib/zerobuf.c.

Reported-by: anonymous coward <nasm64developer@users.sf.net>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-08-02 09:28:22 -07:00
Cyrill Gorcunov
43bb293432 Merge branch 'nasm-2.12.xx'
* nasm-2.12.xx:
  codeview: Fix ill-formed "S_COMPILE2" record.
  rdoff: Add rdf2bin input dependency
  labels: Warn if new label created on pass two
  Add explicit void parameter to newmembuf() function declaration.
  compiler.h: always undefine __STRICT_ANSI__ for gcc

| Conflicts:
|	rdoff/Makefile.in

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-07-27 01:08:51 +03:00
Fabian Giesen
1df89ea039 codeview: Fix ill-formed "S_COMPILE2" record.
write_symbolinfo_properties didn't match the S_COMPILE2 record it's
supposed to be writing (the "compiler version" string was emitted
starting in the final "version" field); fix that.

Write version 8.0.50727; the Windows App Certification Kit (WACK)
checks compiler versions as given in app debug info and complains
when the toolchain is too old. 8.0.50727 is the lowest permitted
"MASM" version for WACK to be happy, so that's what we write.

Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-07-27 01:06:09 +03:00
Fabian Giesen
199f3d7354 rdoff: Add rdf2bin input dependency
On host platforms where $(LN_S) is cp, need to make sure to
link rdf2bin first.

Backport of 6d67dbfa95

Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-07-27 01:03:45 +03:00
Fabian Giesen
bb0fa088fb codeview: Fix ill-formed "S_COMPILE2" record.
write_symbolinfo_properties didn't match the S_COMPILE2 record it's
supposed to be writing (the "compiler version" string was emitted
starting in the final "version" field); fix that.

Write version 8.0.50727; the Windows App Certification Kit (WACK)
checks compiler versions as given in app debug info and complains
when the toolchain is too old. 8.0.50727 is the lowest permitted
"MASM" version for WACK to be happy, so that's what we write.

Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-07-18 14:55:55 +03:00
Fabian Giesen
6823d01c82 Make "make clean" actually clean all object files.
Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-07-18 14:52:27 +03:00
Fabian Giesen
6d67dbfa95 rdoff: Add rdf2bin input dependency
On host platforms where $(LN_S) is cp, need to make sure to
link rdf2bin first.

Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-07-18 14:52:27 +03:00