Commit graph

1804 commits

Author SHA1 Message Date
H. Peter Anvin
67d520c7fa Merge branch 'master' into new-preproc 2009-07-15 16:32:49 -04:00
H. Peter Anvin
cc6ee1acf2 changes: document fixed crash on invalid UTF-8 sequences
Document nasm_quote() fixes.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 16:31:55 -04:00
H. Peter Anvin
252c2db7d9 quote: use nasm_assert() instead of plain assert()
We have nasm_assert() now, so use it...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 16:30:30 -04:00
H. Peter Anvin
4d5029dd76 quote: we must do unsigned comparison to get length of octal escape
When computing the length of an octal escape, we need to do an
unsigned compare, otherwise we only allocate space for one character
for bytes in the \200..\377 range, which is obviously incorrect.

Reported-by: Ed Beroset <beroset@mindspring.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 16:30:22 -04:00
H. Peter Anvin
b93c1881f6 quote: don't use sprintf()
There is no point in using sprintf(), and it adds the possibility of
either bugs due to the output not matching what the byte count loop is
expecting, or just cause people to freak out due to the notion that
"sprinf is unsafe".

Reported-by: Ed Beroset <beroset@mindspring.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 16:30:15 -04:00
H. Peter Anvin
d46ac3c87d quote: use nasm_assert() instead of plain assert()
We have nasm_assert() now, so use it...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 16:28:43 -04:00
H. Peter Anvin
13028a5a19 quote: we must do unsigned comparison to get length of octal escape
When computing the length of an octal escape, we need to do an
unsigned compare, otherwise we only allocate space for one character
for bytes in the \200..\377 range, which is obviously incorrect.

Reported-by: Ed Beroset <beroset@mindspring.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 16:22:47 -04:00
H. Peter Anvin
62f2863860 doc: use consistent title case
Section titles are in title case and don't end with a period.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 09:27:10 -04:00
H. Peter Anvin
9bd5e12f53 doc: fix formatting of the bin multisection header
"Multisection" is not a keyword...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 09:21:01 -04:00
H. Peter Anvin
89cee57ad0 preproc: style cleanups
Fix indentation, space between if and (, and prefer (foo) and (!foo)
to (foo != NULL) and (foo == NULL).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 09:16:54 -04:00
H. Peter Anvin
a758c48c61 NASM 2.07rc5 2009-07-15 09:08:28 -04:00
H. Peter Anvin
db8f96e0e6 preproc: formatting cleanups
Fix inconsistent indentation, and legacy use of partial directives
instead of simply pp_directives[i].

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 09:07:29 -04:00
Keith Kanios
d37a38c359 pptok: change %rimacro to %irmacro
preproc: change PP_RIMACRO to PP_IRMACRO
nasmdoc: add entries for %[i]deftok and %[i]rmacro
2009-07-14 21:00:40 -05:00
H. Peter Anvin
cd0943e277 preproc: don't pass an enum to %s
Need to use pp_directives[directive], not the plain directive, which
is an enum.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 15:17:11 -04:00
H. Peter Anvin
f9c9a6717c preproc: generic solution for error on NUL characters in string
Strings returned by nasm_unquote() can contain NUL characters, which
will not be legal if then used as a C string.  Create a general
function which looks for NUL characters in the string and issues an
error if they are found.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 15:14:05 -04:00
H. Peter Anvin
2f55bdaaca preproc: reject NUL characters in %deftok directives
We could either error out or convert them to whitespace; this
implements the error option.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 15:04:04 -04:00
H. Peter Anvin
466ba97d68 quote: don't use sprintf()
There is no point in using sprintf(), and it adds the possibility of
either bugs due to the output not matching what the byte count loop is
expecting, or just cause people to freak out due to the notion that
"sprinf is unsafe".

Reported-by: Ed Beroset <beroset@mindspring.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 14:48:26 -04:00
H. Peter Anvin
bf0247af7a Don't try to fclose() the output if ofile is NULL
ofile == NULL means no output file is open, so don't try to close the
output file if that is true.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 14:47:41 -04:00
H. Peter Anvin
68bec0872f outobj: don't fclose() the output
Missed fclose() in outobj when converting system to global fclose().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 14:47:04 -04:00
Keith Kanios
b83fd0b947 preproc: add %[i]deftok support
pptok: add %deftok and %ideftok preprocessor directives
2009-07-14 01:04:12 -05:00
H. Peter Anvin
340ee009d6 Merge branch 'master' into new-preproc
Conflicts:
	.gitignore
2009-07-13 21:41:33 -04:00
H. Peter Anvin
44a0d177f0 gitignore: add test results, *.dbg
Add test result directories and *.dbg to gitignore.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-13 21:27:21 -04:00
H. Peter Anvin
2a3154c4d3 ELF: add debug support for TY_YWORD
Add debug support for TY_YWORD (256 bits/32 bytes).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-13 21:25:36 -04:00
Cyrill Gorcunov
e3042cb103 elf32: debug32_typevalue - fix TY_OWORD size
TY_OWORD is 8 * TY_WORD = 16 bytes length

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-13 17:19:21 -04:00
H. Peter Anvin
ad01495da8 .gitignore: add testresults, a few more version.* versions, *.dbg
Update .gitignore.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-13 14:57:58 -04:00
H. Peter Anvin
80e0f4d68f directives: split global directives from backend-specific ones
Split out the global directives into a separate section, that allows
the switch() in the main code to be slightly faster.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-13 14:57:48 -04:00
H. Peter Anvin
afa06137fa Hash even backend-specific directives, unify null functions
Hash all directives, even the ones that are backend-specific,
and instead pass the backend an already-parsed directive number.

Furthermore, unify null functions across various backends.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-12 12:55:24 -07:00
H. Peter Anvin
d0fbb7f0ab Don't fclose() the output in the backend
We fopen() the output file in common code but fclose() it in the
backend.  This is bad for a variety of reasons:

1. it is generally an awkward interface to change ownership.
2. we should use ferror() to test for write errors, and that is
   better done in common code.
3. it requires more code.
4. we still need to fclose() in common code during error handing.

Thus, move the fclose() of the output out of the backends, and add
fflush() so we can test ferror() on output.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-12 12:15:35 -07:00
H. Peter Anvin
323fcff32b Use a phash to decode directives
We can use a perfect hash to decode directives as well.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-12 12:04:56 -07:00
Keith Kanios
852f1eeed5 preproc: add %exitmacro support and clean up recursive macro handling 2009-07-12 00:19:55 -05:00
Keith Kanios
093513d0bc preproc: refine appropriate handling of PP_RMACRO/PP_RIMACRO/PP_MACRO/PP_IMACRO 2009-07-11 14:48:09 -05:00
Keith Kanios
0af5ee2732 pptok: add rmacro/rimacro
preproc: revamp for use with rmacro/rimacro instead of overloading macro/imacro with optional recursion parameter
2009-07-11 14:26:34 -05:00
Keith Kanios
8059902f12 preproc: fix potential bug regarding MMacro->prev and %rep 2009-07-11 06:18:43 -05:00
Keith Kanios
891775e5ba preproc: add recursive macro expansion support 2009-07-11 06:08:54 -05:00
H. Peter Anvin
8da1557a3e NASM 2.07rc4 2009-07-08 21:43:34 -07:00
H. Peter Anvin
a6e25b5356 Document macho64 output format
At least mention the 64-bit macho format in the documentation.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-08 21:42:18 -07:00
Keith Kanios
c5a87ba0a1 Revert "NASM 2.07rc4"
This reverts commit 6d67ced3a4.
2009-07-08 23:28:31 -05:00
Keith Kanios
6d67ced3a4 NASM 2.07rc4 2009-07-08 23:21:28 -05:00
Keith Kanios
6d0d0d2736 macho64: Manually merge macho64 branch with master branch. 2009-07-08 23:04:52 -05:00
Keith Kanios
745560e65a outmacho.c: fix section/relocation alignment issue 2009-07-07 23:09:22 -05:00
H. Peter Anvin
52a3fbd74d NASM 2.07rc3 2009-07-07 16:09:55 -07:00
H. Peter Anvin
a7a14b2fcb changes: document listing fix
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-07 16:08:56 -07:00
H. Peter Anvin
931cab64d6 preproc: revert to older form of preprocessor user error messages
When the user generates an error via %warning, %error, or %fatal,
treat is as any other error message.  The attempt at making them stand
out really looked ugly when the preprocessor adds additional tracing
information.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-07 16:06:21 -07:00
H. Peter Anvin
8287daf2a4 preproc: always reprocess smacros after %+ - pasting
We always need to process %+ at least once, but we also always need to
reprocess smacros after pasting.  The solution to this is to make sure
we always reprocess %+ after the first expansion pass.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-07 16:00:58 -07:00
H. Peter Anvin
a23aa4a3e9 listing: preserve list file on error, include errors
Instead of removing the list file on error, keep the list file and
include the errors in the list file.  This makes it actually possible
to debug things that involve deep macro recursion, where the line
number is pretty much meaningless.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-07 12:04:12 -07:00
H. Peter Anvin
5bc87609d2 outdbg: be excrutiatingly correct...
outdbg is actually a good starting point to make a new backend, so we
really should endeavor to make it do things "right".

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-07 10:27:51 -07:00
H. Peter Anvin
62c0e8379c outdbg: fix OUT_REL*ADR, add OUT_REL8ADR
The OUT_REL*ADR types pass a pointer which points to an int64_t
which then should be truncated down to size.  This matters on
bigendian platforms.

Add OUT_REL8ADR.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-07 10:24:52 -07:00
H. Peter Anvin
215086ace8 outbin: be consistent in spelling "Intel hex" with those caps
The documentation uses "Intel hex", with that capitalization (Intel
being a proper noun, hex being descriptive) so make the help message
match.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-06 23:37:00 -07:00
H. Peter Anvin
75639312f0 NASM 2.07rc2 2009-07-06 19:28:00 -07:00
H. Peter Anvin
e227fe6f80 changes: add Mach-O alignment issue fix
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-06 19:27:33 -07:00