Commit Graph

2534 Commits

Author SHA1 Message Date
Cyrill Gorcunov
49e8f698fc preproc: Add dump_token helper
While being debugging some nifty problem I found
that it might be useful to produce a full dump of
tokens, in particular text of tokens.

For this reason dump_token is here just to not loose
it. It doesn't affect normal build procedure since it
requires a special -DNASM_TRACE to be passed to the
compiler. Which of course we don't in a regular
compilations.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:35 +03:00
Cyrill Gorcunov
574fbf1972 preproc: Use nasm_zalloc more
To eliminate possible access into heap data

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:30 +03:00
Cyrill Gorcunov
a22e7a983c preproc: Use memset for stack allocated structure
To be on safe side

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:24 +03:00
Cyrill Gorcunov
6f38fe6cd5 preproc: inc_fopen -- set sl->next early
It's safer to init it early and be sure we not
miss anything after.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:18 +03:00
Cyrill Gorcunov
c515774a92 preproc: Use nasm_zalloc for new_ExpDef, new_ExpInv
Srink the code and make it a bit faster.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:13 +03:00
Cyrill Gorcunov
29cb0bb1b3 preproc: Use nasm_zalloc in new_Line
It's shorter

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:07 +03:00
Cyrill Gorcunov
325768ed4c autoconf: Add --with-ccache option
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:02 +03:00
Cyrill Gorcunov
a5aea577dd preproc.c: Get rid of tab/space mess
No change on binary level

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:43:56 +03:00
Cyrill Gorcunov
55cc4d0423 preproc: do_directive: Allocate 'Include' from zeroified-memory
If not all members of structure being allocated from
heap get initialized we better to use nasm_zalloc instead
of nasm_malloc.

For example inc gets allocated in do_directive being parially
initialized and we erroniously get mmac_depth set to some
crappy value leading to SIGSEV in result.

[ http://forum.nasm.us/index.php?topic=921.msg3257#msg3257 ]

nb: I've cleaned verror from tab/space mess while were at it

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-10 23:17:34 +03:00
H. Peter Anvin
5fa1b1f47a preproc.c: use nasm_strdup() rather than naked strdup() 2010-11-08 08:37:14 -08:00
Keith Kanios
9858cecf02 preproc.c: placate errors in OpenWatcom Compiler 2010-11-08 00:58:02 -06:00
Victor van den Elzen
d55a158cec BR3104852: only warn once for repeated prefixes 2010-11-07 23:47:13 +01:00
Victor van den Elzen
b3cee5a57a BR3058845: mostly fix bogus warning with implicit operand size override
The implicit operand size override code didn't set the operand size
prefix, which confused the size calculation code for the range check.

The BITS 64 operand size calculation is still off, but "fixing" it by
making it 32-bit unless REX.W is set breaks PUSH and maybe others.
2010-11-07 23:27:48 +01:00
Keith Kanios
0bae3e5ffa preproc.c: Fix OpenWatcom compiler error 2010-11-07 16:21:00 -06:00
Cyrill Gorcunov
329e9665eb preproc.c: Fix OpenWatcom compiler error
It doesn't like when we mess scope of variables
declaration.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-08 00:47:10 +03:00
Victor van den Elzen
db6b9cfa62 Fix autoconf 2.68 warning.
The first argument of AC_COMPILE_IFELSE needs to be wrapped with
AC_LANG_SOURCE.
2010-11-07 17:31:27 +01:00
Victor van den Elzen
bc8522e3a0 Fix Perl deprecation warnings.
Use of defined on aggregates (hashes and arrays) is deprecated.
You should instead use a simple test for size.
2010-11-07 17:20:23 +01:00
Keith Kanios
af43b97514 NASM 2.10rc2 2010-11-06 18:09:15 -05:00
Keith Kanios
02f3495e86 version: reverting back to 2.10rc1 2010-11-06 18:08:32 -05:00
Keith Kanios
b307a4f1eb preproc.c: merge from preproc-rewrite branch
pptok.dat: merge from preproc-rewrite branch
macros.pl: merge from preproc-rewrite branch
version: changed to 2.10rc2
2010-11-06 17:41:51 -05:00
Cyrill Gorcunov
2672af7379 coff: Cover 'else' with cond compilation
It was a nit in first place.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-07 01:09:36 +03:00
Cyrill Gorcunov
1a824c2182 test: Add br3104312.asm test
Not automated yet

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-06 23:09:47 +03:00
Cyrill Gorcunov
9f135edde9 eval: rexp3 should operate with 64bit numbers
reloc_value returns 64bit numbers but we strip it down
to 'int' which causes problems if the former value is
big enough to overflow 'int'. Fix it.

[ BR3104312 ]

Reported-by: Christian Masloch
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-06 23:08:11 +03:00
Cyrill Gorcunov
f0921a0c9c Merge branch 'owc' 2010-11-06 18:50:10 +03:00
Cyrill Gorcunov
d9fddf047e test: Add br3092924.asm
coff massive relocations test

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-06 18:44:48 +03:00
Cyrill Gorcunov
01102ee8e6 coff: Handle massive relocations
In case if relocations number exceed 16bit values
we have to hande such case by a special way, as described
in COFF specification.

 "IMAGE_SCN_LNK_NRELOC_OVFL indicates that the count of
relocations for the section exceeds the 16 bits that are
reserved for it in the section header. If the bit is set
and the NumberOfRelocations field in the section header
is 0xffff, the actual relocation count is stored in the
32-bit VirtualAddress field of the first relocation. It
is an error if IMAGE_SCN_LNK_NRELOC_OVFL is set and
there are fewer than 0xffff relocations in the section."

[ BR3092924 ]

Reported-by: Robert Yates
Investigated-by: nasm64developer
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-06 18:38:00 +03:00
Cyrill Gorcunov
359b63f897 coff: Issue fatal signal on relocations more then 0xffff
Actually it's temporary action. We have to support more
relocations then that but it requires some more code rework.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-06 02:45:45 +03:00
Cyrill Gorcunov
0d485cbdd6 make: Add tags and TAGS targets
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-05 14:18:51 +03:00
Cyrill Gorcunov
4db724fdd7 coff: Add IMAGE_SCN_MAX_RELOC constant
We will need it to analyze if section relocations
are overflowed.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-05 13:50:04 +03:00
Anthony Williams
a4adc238a4 make: Lift up openwcom.mak for build on FreeDOS
Signed-off-by: Anthony Williams <rugxulo@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-30 20:07:50 +04:00
Cyrill Gorcunov
81d53791b0 make: Add "test" target into .PHONY
Michael proposed to run

 | sed -i -e '/^.PHONY: all/s/$/ test/' Makefile.in

since we have test/ directory. Good idea.

Reported-by: Michael Sterrett
Patch-by: Michael Sterrett
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-29 00:40:16 +04:00
Cyrill Gorcunov
27fe347a8b Merge branch 'nasm-2.09.xx'
Conflicts:
	version

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-27 22:42:12 +04:00
Cyrill Gorcunov
4794de2f5b NASM 2.09.03
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-27 21:52:40 +04:00
Cyrill Gorcunov
fdbe8baf7a doc: Update changes for 2.09.03
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-27 21:50:20 +04:00
Cyrill Gorcunov
6cdc900d8d preproc.c: Restore concat rules on context local variables
This is a backport of commits

8dcbbd7af0
575d4289c9

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-27 21:43:03 +04:00
Cyrill Gorcunov
0457bcbf2e preproc: Issue warning on unterminated %{ construct
As being pointed by "matching braces" topic on
[ http://forum.nasm.us/index.php?topic=905.0 ]
we don't issue warning on missed match for "{"
brace opened.

Strictly speaking we should issue error instead and
force user to fix asm source code but since it's
here for a long time already -- lets be "admissive".

Reported-by: Klod
CC: Frank Kotler <fbkotler@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-27 21:41:35 +04:00
Frank Kotler
582b3d0c70 BR3079777: Explain %00 in documentation
Signed-off-by: Frank Kotler <fbkotler@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-27 21:41:19 +04:00
Cyrill Gorcunov
2c157002f2 BR3079550: NASM crash on run-time for OMF output format
We could have accessed malloc'ed data on external symbols
in obj and ieee output formats. Fix it by using nasm_zalloc.

Reported-by: Jiri Malak
Patch-by: Jiri Malak
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-27 21:41:11 +04:00
Cyrill Gorcunov
71787fda1b BR3074517: Print %macro name inside %rep blocks
If we're to print inside %rep block we should find
out which %macro it belongs.

Reported-by: Rob Neff
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-27 21:40:59 +04:00
Cyrill Gorcunov
e0fdd77584 preproc: Issue warning on unterminated %{ construct
As being pointed by "matching braces" topic on
[ http://forum.nasm.us/index.php?topic=905.0 ]
we don't issue warning on missed match for "{"
brace opened.

Strictly speaking we should issue error instead and
force user to fix asm source code but since it's
here for a long time already -- lets be "admissive".

Reported-by: Klod
CC: Frank Kotler <fbkotler@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-07 19:42:12 +04:00
H. Peter Anvin
5129625225 Merge branch 'nasm-2.09.xx' 2010-10-06 16:28:43 -07:00
H. Peter Anvin
db6975919c doc: fix spelling of "compatibility"
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-10-06 16:28:07 -07:00
Cyrill Gorcunov
575d4289c9 preproc.c: Support multiple matches in paste_tokens
In mmacro params head TOK_NUM should be concat'ed with
tail TOK_NUM only, otherwise the weird construction like

    %define id1      1
    %define idid1    2
    %define TOK_NUM  1
    %define TOK_ID  id

    %macro m 2
        mov eax, 1%1id%2 ; this expands to 1idid1
                         ; where idid1 expands to 2
                         ; and then to 12
    %endmacro

    m TOK_ID, TOK_NUM

issue error.

N.B. I've checked nasm-0.98.39 and it compiles this macro
perfectly well, for the record.

Reported-by: nasm64developer@users.sf.net
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-07 01:16:26 +04:00
Frank Kotler
9d0701ecbf BR3079777: Explain %00 in documentation
Signed-off-by: Frank Kotler <fbkotler@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-05 18:41:11 +04:00
Cyrill Gorcunov
2405344e7b Add SubmittingPatches file
Adopted from Linux's Documentation/SubmittingPatches

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-03 21:02:08 +04:00
Cyrill Gorcunov
9e8f0ac460 BR3079550: NASM crash on run-time for OMF output format
We could have accessed malloc'ed data on external symbols
in obj and ieee output formats. Fix it by using nasm_zalloc.

Reported-by: Jiri Malak
Patch-by: Jiri Malak
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-02 01:21:00 +04:00
Cyrill Gorcunov
d4ddfac484 NASM 2.10rc1
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-09-30 22:45:57 +04:00
Cyrill Gorcunov
8dcbbd7af0 BR30730640: Restore preprocessor token concatenation rules
During nasm-2.06 development we broke the rules for
concatenation of preprocessor tokens (d784a083a3).

The former candidates for concatenation were (in terms of RE)

expand_smacro
    [(TOK_ID|TOK_PREPROC_ID)][(TOK_ID|TOK_PREPROC_ID|TOK_NUMBER)]

expand_mmac_params
    [(TOK_ID|TOK_NUMBER|TOK_FLOAT)][(TOK_ID|TOK_NUMBER|TOK_FLOAT|TOK_OTHER)]

[ nb: review commits ec88c1beac , 20a94ad7fe and 984279b1dd if
  you going to change this one ]

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-09-30 22:28:53 +04:00
Cyrill Gorcunov
4402af0c59 More tests automation
Not all covered but still worth to put in

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-09-30 22:10:34 +04:00
Cyrill Gorcunov
e6775697bb test: Add br3074517.asm
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-09-24 15:25:59 +04:00