From: Peter Johnson Date: Mon, 5 Feb 2007 08:11:52 +0000 (-0000) Subject: Support forced identifiers ($foo) in directives. This makes yasm match X-Git-Tag: v0.6.0~33 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fdf47df3787862bcbfb2c8a97dc2376ec223d0d6;p=yasm Support forced identifiers ($foo) in directives. This makes yasm match NASM behavior with regards to e.g. extern $foo. Unfortunately this makes yasm start not matching NASM behavior with regards to the RDF module directive. In NASM, module $foo results in a literal $foo reference; yasm now requires either a double $ (e.g. $$foo) or quotes (e.g. "$foo"). The special case for section (section $foo --> literal $foo) is still present, but keeping this for other directives is extremely difficult. svn path=/trunk/yasm/; revision=1754 --- diff --git a/modules/objfmts/elf/tests/Makefile.inc b/modules/objfmts/elf/tests/Makefile.inc index ffb8ffe0..bf112037 100644 --- a/modules/objfmts/elf/tests/Makefile.inc +++ b/modules/objfmts/elf/tests/Makefile.inc @@ -45,6 +45,8 @@ EXTRA_DIST += modules/objfmts/elf/tests/elfvisibility.errwarn EXTRA_DIST += modules/objfmts/elf/tests/elfvisibility.hex EXTRA_DIST += modules/objfmts/elf/tests/nasm-sectname.asm EXTRA_DIST += modules/objfmts/elf/tests/nasm-sectname.hex +EXTRA_DIST += modules/objfmts/elf/tests/nasm-forceident.asm +EXTRA_DIST += modules/objfmts/elf/tests/nasm-forceident.hex EXTRA_DIST += modules/objfmts/elf/tests/amd64/Makefile.inc EXTRA_DIST += modules/objfmts/elf/tests/gas64/Makefile.inc diff --git a/modules/objfmts/elf/tests/nasm-forceident.asm b/modules/objfmts/elf/tests/nasm-forceident.asm new file mode 100644 index 00000000..dcd7705a --- /dev/null +++ b/modules/objfmts/elf/tests/nasm-forceident.asm @@ -0,0 +1,12 @@ +section ".text" + +section '.text' + +section $foo + +global $Test + +$Test: + mov ax, 0 + ret + diff --git a/modules/objfmts/elf/tests/nasm-forceident.hex b/modules/objfmts/elf/tests/nasm-forceident.hex new file mode 100644 index 00000000..4dda8685 --- /dev/null +++ b/modules/objfmts/elf/tests/nasm-forceident.hex @@ -0,0 +1,448 @@ +7f +45 +4c +46 +01 +01 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +01 +00 +03 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +d0 +00 +00 +00 +00 +00 +00 +00 +34 +00 +00 +00 +00 +00 +28 +00 +06 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +66 +b8 +00 +00 +c3 +00 +00 +00 +00 +2e +74 +65 +78 +74 +00 +24 +66 +6f +6f +00 +2e +73 +74 +72 +74 +61 +62 +00 +2e +73 +79 +6d +74 +61 +62 +00 +2e +73 +68 +73 +74 +72 +74 +61 +62 +00 +00 +00 +00 +2d +00 +54 +65 +73 +74 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +04 +00 +f1 +ff +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +03 +00 +05 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +03 +00 +04 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +10 +00 +05 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +1c +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +48 +00 +00 +00 +26 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +0c +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +70 +00 +00 +00 +08 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +14 +00 +00 +00 +02 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +78 +00 +00 +00 +50 +00 +00 +00 +02 +00 +00 +00 +04 +00 +00 +00 +04 +00 +00 +00 +10 +00 +00 +00 +01 +00 +00 +00 +01 +00 +00 +00 +06 +00 +00 +00 +00 +00 +00 +00 +40 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +10 +00 +00 +00 +00 +00 +00 +00 +07 +00 +00 +00 +01 +00 +00 +00 +02 +00 +00 +00 +00 +00 +00 +00 +40 +00 +00 +00 +05 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +01 +00 +00 +00 +00 +00 +00 +00 diff --git a/modules/objfmts/rdf/tests/rdfext.asm b/modules/objfmts/rdf/tests/rdfext.asm index 8bf5ea0f..1239c4dd 100644 --- a/modules/objfmts/rdf/tests/rdfext.asm +++ b/modules/objfmts/rdf/tests/rdfext.asm @@ -1,5 +1,5 @@ module thismodule -module $thismodule +module "$thismodule" global foo:export global bar:export proc global bar2:export function diff --git a/modules/parsers/nasm/nasm-token.re b/modules/parsers/nasm/nasm-token.re index 995af09e..cd45b3b9 100644 --- a/modules/parsers/nasm/nasm-token.re +++ b/modules/parsers/nasm/nasm-token.re @@ -605,8 +605,14 @@ directive2: RETURN(s->tok[0]); } + /* forced identifier */ + "$" [a-zA-Z0-9_$#@~.?]+ { + lvalp->str_val = yasm__xstrndup(TOK+1, TOKLEN-1); + RETURN(ID); + } + /* identifier; within directive, no local label mechanism */ - [a-zA-Z_$.?][a-zA-Z0-9_$#@~.?]* { + [a-zA-Z_.?][a-zA-Z0-9_$#@~.?]* { lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); RETURN(ID); }