Hi Per, Hi H.J.,
H.J. - this email is in response to a x86 assembler bug report from Per
that was posted here:
http://lists.gnu.org/archive/html/bug-binutils/2008-09/msg00006.html
I have a patch to fix the problem (attached) but I am not sure if you
will like it. Possibly the error should be caught earlier, before the
attempt to apply the fixup ?
The patch includes a new test to cover the example in the original email
and a tweak to an existing test that is altered by the patch. If you
are OK with it please let me know and I will apply the patch to the sources.
Cheers
Nick
gas/ChangeLog
2008-09-18 Nick Clifton <[EMAIL PROTECTED]>
* config/tc-i386.c (md_apply_fix): Refuse fixups against register
symbols.
gas/testsuite/ChangeLog
2008-09-18 Nick Clifton <[EMAIL PROTECTED]>
* gas/i386/inval-symbol.s: New test.
* gas/i386/inval-symbol.l: Expected listing.
* gas/i386/i386.exp: Run new test.
* gas/i386/inval-equ-2.l: Update expecting listing output.
Index: gas/config/tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.352
diff -c -3 -p -r1.352 tc-i386.c
*** gas/config/tc-i386.c 3 Sep 2008 15:44:33 -0000 1.352
--- gas/config/tc-i386.c 18 Sep 2008 11:35:53 -0000
*************** md_apply_fix (fixP, valP, seg)
*** 7644,7649 ****
--- 7644,7658 ----
char *p = fixP->fx_where + fixP->fx_frag->fr_literal;
valueT value = *valP;
+ if (fixP->fx_addsy != NULL
+ && S_GET_SEGMENT (fixP->fx_addsy) == reg_section)
+ {
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("cannot use a register name as symbolic value"));
+ fixP->fx_done = 1;
+ return;
+ }
+
#if !defined (TE_Mach)
if (fixP->fx_pcrel)
{
Index: gas/testsuite/gas/i386/i386.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/i386/i386.exp,v
retrieving revision 1.105
diff -c -3 -p -r1.105 i386.exp
*** gas/testsuite/gas/i386/i386.exp 28 Aug 2008 09:42:11 -0000 1.105
--- gas/testsuite/gas/i386/i386.exp 18 Sep 2008 11:35:53 -0000
*************** if [expr ([istarget "i*86-*-*"] || [ist
*** 28,33 ****
--- 28,34 ----
run_list_test "inval" "-al"
run_list_test "segment" "-al"
run_list_test "inval-seg" "-al"
+ run_list_test "inval-symbol" "-al"
run_list_test "modrm" "-al --listing-lhs-width=2"
run_dump_test "naked"
run_dump_test "opcode"
Index: gas/testsuite/gas/i386/inval-equ-2.l
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/i386/inval-equ-2.l,v
retrieving revision 1.1
diff -c -3 -p -r1.1 inval-equ-2.l
*** gas/testsuite/gas/i386/inval-equ-2.l 3 Mar 2008 15:28:58 -0000
1.1
--- gas/testsuite/gas/i386/inval-equ-2.l 18 Sep 2008 11:35:53 -0000
***************
*** 1,4 ****
--- 1,7 ----
.*: Assembler messages:
+ .*:3: Error: .*
+ .*:5: Error: .*
+ .*:8: Error: .*
.*:8: Error: .*
.*:8: Error: .*
.*:8: Error: .*
*************** GAS LISTING .*
*** 7,19 ****
[ ]*1[ ]+\.globl bar1
[ ]*2[ ]+\.set bar1,\(%eax\+1\)
! [ ]*3[ ]+\?\?\?\? A12A0000 mov bar1,%eax
[ ]*3[ ]+00
[ ]*4[ ]+\.set bar2,\(%eax\+1\)
! [ ]*5[ ]+\?\?\?\? A12A0000 mov bar2,%eax
[ ]*5[ ]+00
[ ]*6[ ]+\.globl bar2
[ ]*7[ ]+\.set bar3,\(%eax\+1\)
! [ ]*8[ ]+\?\?\?\? A12A0000 mov bar3,%eax
\*\*\*\* Error:can't make global register symbol `bar3'
[ ]*8[ ]+00
--- 10,22 ----
[ ]*1[ ]+\.globl bar1
[ ]*2[ ]+\.set bar1,\(%eax\+1\)
! [ ]*3[ ]+\?\?\?\? A1..0000 mov bar1,%eax
[ ]*3[ ]+00
[ ]*4[ ]+\.set bar2,\(%eax\+1\)
! [ ]*5[ ]+\?\?\?\? A1..0000 mov bar2,%eax
[ ]*5[ ]+00
[ ]*6[ ]+\.globl bar2
[ ]*7[ ]+\.set bar3,\(%eax\+1\)
! [ ]*8[ ]+\?\?\?\? A1..0000 mov bar3,%eax
\*\*\*\* Error:can't make global register symbol `bar3'
[ ]*8[ ]+00
*** /dev/null 2008-09-18 08:05:37.567254421 +0100
--- gas/testsuite/gas/i386/inval-symbol.s 2008-09-18 11:33:38.000000000
+0100
***************
*** 0 ****
--- 1,2 ----
+ .text
+ cmp (%ax)-1, %ax
*** /dev/null 2008-09-18 08:05:37.567254421 +0100
--- gas/testsuite/gas/i386/inval-symbol.l 2008-09-18 11:39:06.000000000
+0100
***************
*** 0 ****
--- 1,9 ----
+ .*: Assembler messages:
+ .*:2: Error: .*
+ GAS LISTING .*
+
+
+ 1 [ ]* .text
+ 2 .* cmp \(%ax\)-1, %ax
+ .*Error:cannot use a register name as symbolic value
+ 2 .*0+0
_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils