This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[4.1/4.0/3.4 PATCH] Fix -m32 -march=i386 -masm=intel -fpic set_got
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 6 Jul 2005 12:46:26 -0400
- Subject: [4.1/4.0/3.4 PATCH] Fix -m32 -march=i386 -masm=intel -fpic set_got
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Without this patch
int i; int foo (void) { return i; }
compiled with -march=i386 -m32 -masm=intel -fpic results in:
call .L3
.L3:
pop %ecx
add %ecx, _GLOBAL_OFFSET_TABLE_+(.-.L3)
which is assembled into:
3: e8 00 00 00 00 call 8 <foo+0x8>
8: 59 pop %ecx
9: 03 0d 03 00 00 00 add 0x3,%ecx
b: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
which is not the desired immediate addition to %ecx.
Without -masm=intel the right sequence is:
call .L3
.L3:
popl %ecx
addl $_GLOBAL_OFFSET_TABLE_+[.-.L3], %ecx
and with -masm=intel and this patch:
call .L3
.L3:
pop %ecx
add %ecx, OFFSET FLAT:_GLOBAL_OFFSET_TABLE_+(.-.L3)
which both assemble into identical:
3: e8 00 00 00 00 call 8 <foo+0x8>
8: 59 pop %ecx
9: 81 c1 03 00 00 00 add $0x3,%ecx
b: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
Ok for HEAD, 4.0 (after branch reopens) and 3.4?
2005-07-06 Jakub Jelinek <jakub@redhat.com>
* config/i386/i386.c (output_set_got): Don't omit OFFSET FLAT:
in Intel syntax add %reg, OFFSET FLAT:_GLOBAL_OFFSET_TABLE_+(.-.Lx).
--- gcc/config/i386/i386.c.jj 2005-07-03 13:53:06.000000000 +0200
+++ gcc/config/i386/i386.c 2005-07-06 18:24:52.000000000 +0200
@@ -4175,7 +4175,7 @@ output_set_got (rtx dest)
if (!flag_pic || TARGET_DEEP_BRANCH_PREDICTION)
output_asm_insn ("add{l}\t{%1, %0|%0, %1}", xops);
else if (!TARGET_MACHO)
- output_asm_insn ("add{l}\t{%1+[.-%a2], %0|%0, %a1+(.-%a2)}", xops);
+ output_asm_insn ("add{l}\t{%1+[.-%a2], %0|%0, %1+(.-%a2)}", xops);
return "";
}
Jakub