Commit graph

316 commits

Author SHA1 Message Date
H. Peter Anvin
ece809789e Merge remote-tracking branch 'origin/nasm-2.13.xx'
Resolved conflicts:
	version

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-01 10:37:18 -07:00
H. Peter Anvin
aaefc7fe6b BR 3392442: correct vmin in overflow_general()
The calculation of vmin in overflow_general() was bogus, causing
silliness like ~80h being warned about in a byte context.

Reported-by: C. Masloch <pushbx@38.de>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-10-11 13:12:17 -07:00
H. Peter Anvin
81fd01f9d0 BR 3392362: generate RMI versions of PEXTRW when possible
We could generate the MRI version (SSE 4.1) instead of the RMI
(SSE 2) version of these instructions if a 64-bit register was given
as the destination.

Reported-by: Vasiliy Olekhov <olekhov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-09-27 15:55:57 -07:00
H. Peter Anvin
59d5291a3a test: add Makefile target for RDOFF files
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-09-27 15:53:48 -07:00
H. Peter Anvin
e38654a24e BR 3392411: smartalign: make sure we always define the end symbol
We need to always define the end symbol, otherwise we might find
ourselves in a situation where the alignment code grows (common!) and
then the symbol is defined late.

Reported-by: ig <glucksmann@avast.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-09-27 15:29:01 -07:00
H. Peter Anvin
94ead27971 BR 3392437: Fix diagnostic for negative value in TIMES
Issue a diagnostic and don't panic for invalid TIMES values.

Reported-by: C. Masloch <pushbx@38.de>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-09-27 15:22:23 -07:00
H. Peter Anvin
621603da26 BR 3392418: MachO: support 16-character section names, debug flag
Support 16-character section names, and support the debug section
flag.

Reported-by: Andrey Timofeyev <timofeyev@bk.ru>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-09-27 14:42:08 -07:00
H. Peter Anvin
d5e7c072bd test: add test code for BR 3392439
Bug report BR 3392439 test code.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-09-27 14:25:44 -07:00
H. Peter Anvin
fbce0bfb4e Merge remote-tracking branch 'origin/nasm-2.13.xx'
Resolved Conflicts:
	asm/directiv.dat
	asm/preproc.c
	misc/omfdump.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-08-16 22:41:40 -07:00
H. Peter Anvin
2998226fa1 test/Makefile: output dependency information files
Generate dependency information files as output to make sure we really
do the right thing.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-08-16 16:43:04 -07:00
H. Peter Anvin
92a8326f0d test/Makefile: separate NASM and NASMDEP
Separate out the NASM and NASMDEP variables, in case one wants to
override the former.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-06-25 19:32:41 -07:00
H. Peter Anvin
aac369d5b0 Merge remote-tracking branch 'origin/nasm-2.13.xx'
Resolved Conflicts:
	common/common.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-06-23 14:48:08 -07:00
H. Peter Anvin
8a6903c43d test/reldef.asm: add some global symbols
Make some symbols global for more testing.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-06-22 18:39:52 -07:00
H. Peter Anvin
f61dd0fdbb reldef.asm: add more test cases for reference
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-06-22 18:32:49 -07:00
H. Peter Anvin
37b9be3402 reldef.asm: more comprehensive test
More testing of various relative operations.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-06-22 18:20:44 -07:00
H. Peter Anvin
a7b6bfca68 Sanitize the handling of segments a bit
Make the internal handling of segment numbers just a little more
sane.  The whole use of when we have done ofmt->segbase or not is
crazy, though...

In the meantime, add a few more hacks to the dbg output format to make
it more useful.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-05-03 17:33:04 -07:00
H. Peter Anvin
3e458a89d8 a) Fix handling of DZ/ZWORD; b) don't crash on TIMES JMP
a) Fix a number of missing instances of DZ and ZWORD.

b) NASM would crash if TIMES was used on an instruction which varies
   in size, e.g. JMP.  Fix this by moving the handling of TIMES at a
   higher level, so we generate the instruction "de novo" for each
   iteration.  The exception is INCBIN, so we can avoid reading the
   included file over and over.

c) When using the RESx instructions, just fold TIMES into the reserved
   space size; there is absolutely no point to iterate over it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 21:13:15 -07:00
H. Peter Anvin
08e71e7dc4 test/Makefile: add a rule to run omfdump on an .obj file
omfdump is really useful while debugging obj output, so add an
explicit rule to generate omfdump output.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 15:09:44 -07:00
H. Peter Anvin
e83311c73d BR 3392396: fix EVEX compressed displacements
The fvm: annotation to generate the correct EVEX compressed
displacements had inadvertently gotten dropped from a handful of
instructions in checkin c33d95fde9:

BR 3392370: {z} decorator allowed on MOVDQ* memory operands

Put them back, and verify they work.

Reported-by: Henrik <henrik@gramner.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-06 18:52:08 -07:00
H. Peter Anvin
3646e7dde0 BR 3392399: float: get rid of bogus exponent calculation
It turns out that the calculation of "twopwr" in ieee_flconvert_bin()
was more complex than necessary, and wrong in the case of a pure
fraction.

Reported-by: Roel <roelsuidgeest@zonnet.nl>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-05 21:47:20 -07:00
H. Peter Anvin
14858d7343 Makefiles: distribute file generation rules via syncfiles.pl
Distribute the file generation rules to auxiliary Makefiles via
syncfiles.pl.  These rules are OS- and Make-dialect-generic enough
that our mangling script handles them well enough.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-03 11:13:29 -07:00
H. Peter Anvin
aac01ff479 Always remove a stale list file
Remove the list file before running the first pass, so in case we
die before running pass 2 then there won't be a stale list file
sitting around.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-02 19:11:40 -07:00
H. Peter Anvin
8f62246560 Further improve error messages for confused decorators
Try to generate more sensible error messages for bogus combinations
of decorators.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-02 19:02:29 -07:00
H. Peter Anvin
8e37ff4ea1 BR3392392: fix broadcast decorators and improve error messages
Checkin c33d95fde9:
    BR 3392370: {z} decorator allowed on MOVDQ* memory operands

... inadvertently broke broadcast operations, which only apply to
memory operands and therefore were only handled in one of the two
brace-parser implementations.  Fix that.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-02 18:38:58 -07:00
H. Peter Anvin
1980abfb7a BR 3392363: clear the operands when making an artificial I_RESB
When we make an artificial RESB instructions (due to isolated
prefixes) we need to make sure there isn't any crap left in the
operands structure.  The easiest way to guarantee that is to force it
to zero.

Reported-by: Henrik <henrik@gramner.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-31 14:53:24 -07:00
H. Peter Anvin
31a14699fb outdbg: update to dump new backend interface data
Update the debug output format to dump (most of) the information that
is available via the new backend format, as well as the legacy backend
format -- probably the only backend ever which will ever want both!

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-31 11:32:53 -07:00
H. Peter Anvin
55e06dead1 test/imm.asm: test more combinations of immediates
A few more combinations of immediates that can or should be converted.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-01 13:23:52 -08:00
H. Peter Anvin
ed71316e2b test/pcrel.asm: make test output a bit easier to understand
Make the output of the test a bit easier to pick apart.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-02-20 13:06:02 -08:00
H. Peter Anvin
164d24677a Support self-relative expressions in offsets and immediates
Handle, hopefully correctly, self-relative expressions (that is,
expressions of the form X - Y where Y is a symbol in the current
segment, possibly $ or $$) used as offsets or immediates, as opposed
to arguments to Dx statements (which have already been supported for a
while.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-02-20 02:39:56 -08:00
H. Peter Anvin
70d0458050 Merge remote-tracking branch 'origin/nasm-2.12.xx'
Resolved Conflicts:
	output/outelf32.c
	output/outelf64.c

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-11-15 12:00:23 -08:00
H. Peter Anvin
c7ea29b247 Add rdpid instruction
Add the RDPID instruction, documented in the Intel SDM October 2016.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-11-15 11:55:14 -08:00
H. Peter Anvin
472a7c1d17 Allow relative references to external symbols in data
Allow constructs like:

      dd foo - $

... where foo is an external symbol.  Currently this is only
implemented for extops, i.e. dx opcodes.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-31 08:44:25 -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
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
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
3736895c07 Fix and clean up listing of macro expansion
Fix the printing of the macro stack: we need to follow the
mstk->next_active list, not mstk->next, and we need to reverse the
order so that the highest-level inclusion comes first.

Since this should be a rare or at least performance-insensitive
operation, do it using simple function recursion.

Finally, add an ellipsis before the "from macro" message; it greatly
enhances readability.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 14:10:32 -07:00
H. Peter Anvin
4def1a8db4 Show the expanded macro stack when displaying diagnostics
It can be hard to find errors inside potentially nested macros.
Show the mmacro expansion stack when printing diagnostics.
Note that a list file doesn't help for errors that are detected
before the code-generation pass.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 13:59:44 -07:00
H. Peter Anvin
69550eac55 Specifically if we encounter the PTR keyword
Issue a specific suppressible warning if we encounter the PTR keyword.
This usually indicates someone mistakenly using MASM syntax in NASM.

This introduces a generic infrastructure for issuing warnings for such
keywords.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 12:05:56 -07:00
H. Peter Anvin
fc0ff223b2 labels: emit the same label name to the output and debug backends!!
When a local label was seen, the debug backend would not receive the
full label name!  In order to both simplify the code and avoid this
kind of discrepancy again, make both the output and debug format calls
from a common static function.

However, none of the current debug format backends want to see NASM
special symbols (that start with .. but not ..@) so filter those from
the debug backend.

Finally, fix an incorrect comment in nasm.h: the debug format is
called *after* the output format.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Jim Kukunas <james.t.kukunas@linux.intel.com>
2016-03-07 22:00:01 -08:00
H. Peter Anvin
d414e5f4cd test/cv8struc.asm: fix missing comma in test case
Fix a missing comma in the test case which make the test case bogus.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-04 10:59:13 -08:00
H. Peter Anvin
a9a1b5c318 test: add test for cv8 structure bug (BR 3392342 and 3392343)
Add test case for bugs 3392342 and 3392343.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-03 17:05:20 -08:00
H. Peter Anvin
114ba75f7b test/Makefile: add a rule for nasm itself
If NASM needs to be rebuilt, build it in the proper directory.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-18 13:06:04 -08:00
H. Peter Anvin
89f78f5010 Merge branch 'nasm-2.11.xx'
Resolved Conflicts:
	assemble.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-05-21 08:30:40 -07:00
H. Peter Anvin
0a9250c2ab BR 3392279: Fix duplicated REX prefixes
The fix for BR 3392278:

aa29b1d93f assemble.c: Don't drop rex prefix from instruction itself

... would cause multiple REX prefixes to be emitted for some
instructions.  Create a new flag to indicate that REX has already been
emitted, which can be cleared for each instance of an instruction.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-05-21 08:24:21 -07:00
H. Peter Anvin
49de44e56d Merge remote-tracking branch 'origin/signrel' 2014-05-09 15:09:43 -07:00
H. Peter Anvin
1eef781594 BR 3392275: Don't require xmm0 to be specified when implicit
BR 3392275 complains about xmm0 having to be explicitly included in
the assembly syntax when it is implicit in the encoding.  In the
interest of "be liberal in what you accept", accept either form in the
input.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2014-02-16 10:25:25 -08:00
Jin Kyu Song
b0c729baeb mpx: Clean up instruction data
Cleaned up unneccessary size specifiers in the instruction data.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-12-18 22:37:36 -08:00
H. Peter Anvin
621a69ac5c Add {vex3} and {vex2} prefixes by analogy with {evex}
Allow specifying {vex3} or {vex2} (the latter is currently always
redundant, unless we end up with instructions at some point can be
specified with legacy prefixes or VEX) to select a specific encoding
of VEX-encoded instructions.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-11-28 12:21:11 -08:00
Jin Kyu Song
376701ef9a testcase: Remove escape characters - '\'
Since the multi-line macro preprocessor is modified to expand
grouped parameter with braces. The escape character is not needed
any more.
The testcase converter script is also modified not to generate '\'.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-27 21:01:01 -08:00