From: Peter Johnson Date: Tue, 27 Sep 2005 03:46:34 +0000 (-0000) Subject: * gas-bison.y: Allow .data, .text, and .bss to be used in expressions (they X-Git-Tag: v0.5.0rc1~129 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8545380851df32713b4fd5d9472f99025b11464f;p=yasm * gas-bison.y: Allow .data, .text, and .bss to be used in expressions (they come through as unique directive tokens, not as DIR_ID). * dataref-imm.*: Test for this. svn path=/trunk/yasm/; revision=1248 --- diff --git a/modules/parsers/gas/gas-bison.y b/modules/parsers/gas/gas-bison.y index 1e3b0203..0cd096c7 100644 --- a/modules/parsers/gas/gas-bison.y +++ b/modules/parsers/gas/gas-bison.y @@ -106,7 +106,7 @@ static void gas_parser_directive %type line lineexp instr -%type label_id +%type expr_id label_id %type memaddr %type expr regmemexpr %type explabel @@ -568,7 +568,7 @@ expr: INTNUM { $$ = p_expr_new_ident(yasm_expr_int($1)); } | '(' expr ')' { $$ = $2; } ; -explabel: label_id { +explabel: expr_id { /* "." references the current assembly position */ if ($1[1] == '\0' && $1[0] == '.') $$ = yasm_symtab_define_label(p_symtab, ".", parser_gas->prev_bc, @@ -577,7 +577,7 @@ explabel: label_id { $$ = yasm_symtab_use(p_symtab, $1, cur_line); yasm_xfree($1); } - | label_id '@' label_id { + | expr_id '@' label_id { /* TODO: this is needed for shared objects, e.g. sym@PLT */ $$ = yasm_symtab_use(p_symtab, $1, cur_line); yasm_xfree($1); @@ -585,6 +585,12 @@ explabel: label_id { } ; +expr_id: label_id + | DIR_DATA { $$ = yasm__xstrdup(".data"); } + | DIR_TEXT { $$ = yasm__xstrdup(".text"); } + | DIR_BSS { $$ = yasm__xstrdup(".bss"); } +; + label_id: ID | DIR_ID; %% diff --git a/modules/parsers/gas/tests/Makefile.inc b/modules/parsers/gas/tests/Makefile.inc index 72e6f325..eb4df040 100644 --- a/modules/parsers/gas/tests/Makefile.inc +++ b/modules/parsers/gas/tests/Makefile.inc @@ -3,6 +3,9 @@ TESTS += modules/parsers/gas/tests/gas_test.sh EXTRA_DIST += modules/parsers/gas/tests/gas_test.sh +EXTRA_DIST += modules/parsers/gas/tests/dataref-imm.asm +EXTRA_DIST += modules/parsers/gas/tests/dataref-imm.errwarn +EXTRA_DIST += modules/parsers/gas/tests/dataref-imm.hex EXTRA_DIST += modules/parsers/gas/tests/datavis.asm EXTRA_DIST += modules/parsers/gas/tests/datavis.errwarn EXTRA_DIST += modules/parsers/gas/tests/datavis.hex diff --git a/modules/parsers/gas/tests/dataref-imm.asm b/modules/parsers/gas/tests/dataref-imm.asm new file mode 100644 index 00000000..3bfff168 --- /dev/null +++ b/modules/parsers/gas/tests/dataref-imm.asm @@ -0,0 +1,5 @@ +movl $(.data+160),%eax +.data +.long .text +.long .data +.long .bss diff --git a/modules/parsers/gas/tests/dataref-imm.errwarn b/modules/parsers/gas/tests/dataref-imm.errwarn new file mode 100644 index 00000000..e69de29b diff --git a/modules/parsers/gas/tests/dataref-imm.hex b/modules/parsers/gas/tests/dataref-imm.hex new file mode 100644 index 00000000..9e4c6b1c --- /dev/null +++ b/modules/parsers/gas/tests/dataref-imm.hex @@ -0,0 +1,592 @@ +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 +10 +01 +00 +00 +00 +00 +00 +00 +34 +00 +00 +00 +00 +00 +28 +00 +08 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +b8 +a0 +00 +00 +00 +00 +00 +00 +01 +00 +00 +00 +01 +02 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +01 +03 +00 +00 +04 +00 +00 +00 +01 +02 +00 +00 +08 +00 +00 +00 +01 +04 +00 +00 +00 +2e +74 +65 +78 +74 +00 +2e +64 +61 +74 +61 +00 +2e +72 +65 +6c +2e +74 +65 +78 +74 +00 +2e +72 +65 +6c +2e +64 +61 +74 +61 +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 +2d +00 +2e +62 +73 +73 +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 +06 +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 +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 +00 +31 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +74 +00 +00 +00 +3b +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +b0 +00 +00 +00 +08 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +29 +00 +00 +00 +02 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +b8 +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 +05 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +10 +00 +00 +00 +00 +00 +00 +00 +0d +00 +00 +00 +09 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +48 +00 +00 +00 +08 +00 +00 +00 +03 +00 +00 +00 +04 +00 +00 +00 +04 +00 +00 +00 +08 +00 +00 +00 +07 +00 +00 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +50 +00 +00 +00 +0c +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +04 +00 +00 +00 +00 +00 +00 +00 +17 +00 +00 +00 +09 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +5c +00 +00 +00 +18 +00 +00 +00 +03 +00 +00 +00 +06 +00 +00 +00 +04 +00 +00 +00 +08 +00 +00 +00