Commit Graph

1863 Commits

Author SHA1 Message Date
Victor van den Elzen
15bb233036 Fix some format strings for nasm_error
Added a format attribute to nasm_error (only for GCC) and
used the resulting warnings to fix some format strings.
2009-08-11 02:43:41 +02:00
Cyrill Gorcunov
5a49e7c578 output/dwarf.h: update dwarf constants
There is a hope we'll be supporting dwarf in full form in future. So
I've encoded the standard constants (though binutils uses some
additional codes).

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-08-10 16:00:43 -07:00
H. Peter Anvin
eaa68f1c85 Add strlcpy() function
Add strlcpy() function and implementation, and use configure to detect
if strlcpy() is natively available on the system.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-08-10 15:59:34 -07:00
H. Peter Anvin
767750b666 output: change null_debug_routine to null_debug_directive
This is the null implementation of the function debug_directive.  For
some reason it ended up getting mangled as "null_debug_routine".

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-08-09 13:04:13 -07:00
Cyrill Gorcunov
0a45cc8ce8 disasm.c: eatbyte -- use snprintf to prevent potential buffer overflow
At moment we can't overrun buffer even if we would like to
but better to stay on a safe side and use snprintf.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-08-09 10:30:48 -07:00
Cyrill Gorcunov
c9b2d2a8ec headers/c: strip off useless spaces
All other templates do not have them
so lets unify the approach.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-08-09 10:28:27 -07:00
Cyrill Gorcunov
23c6f213bd insns.pl: remove redundant empty line in enum opcode
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-08-08 14:00:47 -07:00
H. Peter Anvin
8bec2c788f nasm.c: fix stack overrun in assemble_file
If [DEBUG id] has id longer then 80 symbols (well, 79 actually plus
EOS) then stack will be just overwritten.

Fix it with explicit check for identifier being too long.

Based on an initial version by Cyrill Gorcunov <gorcunov@gmail.com>.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
2009-08-08 13:49:00 -07:00
H. Peter Anvin
f903da144d Merge commit 'cyr/hpa-dat' 2009-08-07 09:16:47 -07:00
H. Peter Anvin
3815aa7783 Merge commit 'cyr/hpa-list' 2009-08-07 09:16:19 -07:00
Cyrill Gorcunov
509aa63b31 insns.dat -- convert FMA instructions
Convert FMA instructions to explicit sized ones.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-08-07 18:42:40 +04:00
Cyrill Gorcunov
e652f82798 insns.dat -- convert AVX instructions part2
Convert Intel AVX instructions to explisit size
format. Part 2.

Also CLMUL converted as well.

Btw, VPINSR was a bit broken since SB constraint
is not applied on all forms but requires 16,32,64
memory sizes too. Fixed.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-08-07 18:41:52 +04:00
Cyrill Gorcunov
b2cad279d9 insns.dat -- convert AVX instructions part1
Convert Intel AVX instructions to explisit size
format. Part 1.

Also SAR instruction is touched as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-08-07 00:26:54 +04:00
H. Peter Anvin
a5547dcb74 doc: \ needs to be repeated except in \c-line context; daily snapshots
Fix case where \\ needs to be written as \\\\ in order to appear as a
double backslash.  Also add mention of release candidates and
snapshots.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-08-02 14:16:07 -07:00
Cyrill Gorcunov
6f742649fe output/outbin.c -- use list helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-08-01 23:52:25 +04:00
H. Peter Anvin
f46c0d6733 nasm.c: consistently use the 'murrican spelling "optimize"
"Optimise" (and other -ise words) is en_GB, "optimize" (and other
"-ize" words) is en_US.  Stick to en_US since that is what we seens to
be using more already.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-31 08:03:32 -07:00
Cyrill Gorcunov
124a462cc2 nasm.1 -- update contents
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-31 14:30:33 +04:00
Cyrill Gorcunov
73b87c68b1 nasm.c -- update info on -O cmdline option
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-31 10:26:55 +04:00
H. Peter Anvin
e873c9b16b Merge commit 'cyr/hpa-list' 2009-07-30 15:06:47 -07:00
Cyrill Gorcunov
984c4db12f nasm.c -- update help message
Show all options we support at moment
via "nasm -h" invoked.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-31 00:32:17 +04:00
Cyrill Gorcunov
a95a76a868 outaout.c -- use list helpers
Note that we use list_for_each(var,var) sometime
which actually brings in at least one redundant
assignment in case of NULL being passed but save
us a few lines of code.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-28 23:26:12 +04:00
Cyrill Gorcunov
e6ccff9997 insns.dat: operand-size syntax for XOP instructions
Explicitly declare the sizes of immediate fields.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-27 15:49:11 -07:00
Cyrill Gorcunov
a92a3a5c49 assemble.c -- use list helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-27 22:33:59 +04:00
H. Peter Anvin
ed3e84f9cd assemble.c: quiet warning
Clear an uninitialized variable warning.  The case can't actually
happen, but the compiler doesn't know that.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-27 11:10:33 -07:00
Cyrill Gorcunov
fcd0a74330 nasm.c -- use list helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-27 16:26:26 +04:00
Cyrill Gorcunov
77df046f0b insns.dat -- operand-size syntax for XOP instructions
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-27 12:32:30 +04:00
H. Peter Anvin
60926244f1 assemble.c: clean up matches()
Simplify matches(), and quite possibly make it more correct.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-26 16:25:38 -07:00
H. Peter Anvin
5c143a2162 Merge branch 'nasm-2.07.xx' 2009-07-26 15:42:09 -07:00
H. Peter Anvin
47c9479dc3 BR 2826669: update licensing information in README
The code is now under the 2-clause BSD license.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-26 15:40:38 -07:00
H. Peter Anvin
e39dc8c5b2 Merge branch 'nasm-2.07.xx' 2009-07-26 15:31:59 -07:00
H. Peter Anvin
7ad24562dc BR 2827397: fix invalid C in outcoff AddExports()
The construct:

         if (i == nsects)
             directive_sec =
                 sects[coff_make_section
                       (EXPORT_SECTION_NAME, EXPORT_SECTION_FLAGS)];

... where coff_make_section() can change the global variable "sects"
is undefined C, since there is no sequence point involved in the []
operator, and it is therefore fully permitted for the C compiler to
read the sects variable first.  Change this construct into two
statements to enforce defined behavior; this also ends up with the
code slightly simpler.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-26 15:29:09 -07:00
H. Peter Anvin
109b030f01 insns.pl: smarter handling of operand flags
Handle operand flags like "xmmrm128" correctly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-26 12:52:22 -07:00
H. Peter Anvin
3fb86f2cd6 assemble: defer "operand size missing" until end of type check
Defer the "operand size missing" error until we know all the other
operands have the correct type.  Otherwise we'll end up with false
positives, which result in noise entered into the xsizeflags array,
thus causing fuzzy matching to fail.

It's possible we should defer it even further.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-25 19:12:10 -07:00
H. Peter Anvin
a81655bffb Enable fuzzy matching of operand sizes
This allows automatic fuzzy matching of operand sizes.  If an operand
size is not specified, but there is exactly one possible size for the
instruction, select that instruction size.  This requires a second
pass through the instruction patterns, and so is slightly slower, but
should be a lot easier to get right than the S- flags, and works even
when there is more than one instruction.

The new SX (Size eXact) flag can be used to prevent fuzzy matching
completely.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-25 18:15:28 -07:00
H. Peter Anvin
23595f5946 assemble: move the instruction-matching loop into a common function
Move the instruction-matching loop into a common function.  This gives
us a single point to adjust the instruction-selection algorithm.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-25 17:44:25 -07:00
H. Peter Anvin
65289e84ed assemble: replace random integers with an enum for match results
Match results were reported with random integers.  Replace with an
enum.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-25 17:25:11 -07:00
Cyrill Gorcunov
2ec4ad8556 sync.c - introduce swap_sync helper
Just to remove code duplication

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-20 17:59:00 +04:00
Cyrill Gorcunov
10b4a18d7f preproc.c - remove redundant assignment
There is no need for tline assignment right
before it'll be assigned again in for() cycle.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-20 17:59:00 +04:00
Cyrill Gorcunov
2a75829452 nasmlib.h - introduce list iterator helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-20 17:59:00 +04:00
H. Peter Anvin
594c9646ae Merge branch 'new-preproc' 2009-07-19 22:36:44 -07:00
H. Peter Anvin
54dd03bfe5 NASM 2.07 2009-07-19 22:16:52 -07:00
H. Peter Anvin
dbb640b846 Drop efunc and evalfunc as input to the preprocessor
We only ever invoked the preprocessor with fixed values for efunc and
evalfunc, so call nasm_error() and evaluate() directly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-18 18:57:16 -07:00
H. Peter Anvin
00444ae04e Drop efunc and evaluate argument to parse_line()
We never invoked the parser with anything but the default definitions
for evaluate and efunc.  Unlike the backend, though, we sometimes
invoke parse_line() with redefine_label() instead of define_label().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-18 18:49:55 -07:00
H. Peter Anvin
605f5155ee Drop the ofmt and errfunc arguments to label definition functions
We never set ofmt and errfunc to anything but the global values.
Dropping them from the label definition function command line
simplifies the code.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-18 18:43:58 -07:00
H. Peter Anvin
ab6443969a Run make alldeps 2009-07-18 18:43:28 -07:00
H. Peter Anvin
9bd1506d59 Remove function pointers in output, simplify error handling
Remove a bunch of function pointers in the output stage; they are
never changed and don't add any value.  Also make "ofile" a global
variable and let the backend use it directly.

All we ever did with these variables were stashing it in locals and
using them as-is anyway for no benefit.

Also change the global error function, nasm_error() into a true
function which invokes a function pointer internally.  That lets us
use direct calls to it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-18 18:43:12 -07:00
H. Peter Anvin
159178f2aa Merge commit 'nasm-2.07rc7' into new-preproc 2009-07-17 00:55:17 -04:00
H. Peter Anvin
b2aae9441e NASM 2.07rc7 2009-07-17 00:35:58 -04:00
H. Peter Anvin
a5fd1ca895 outcoff: fix invalid reference to ofmt
ofmt is a static in nasm.c (why?), not a global...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-16 22:46:34 -04:00
H. Peter Anvin
892bafc9b1 test/Makefile: add more output rules
Add more output rules to be able to try things quickly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-16 22:44:43 -04:00