[hjl@gnu-6 pr46275]$ cat p.c #include <stdio.h> int main() { puts("Hello, world!"); return 0; } [hjl@gnu-6 pr46275]$ make gcc -m32 -masm=intel -fPIC -S p.c gcc -m32 -o p p.s ./p [hjl@gnu-6 pr46275]$ For some reason, the addend in R_386_GOTPC reloc is missing when compiled with -masm=intel. The objdump difference between -masm=att [hello.o] that works and -masm=intel [hello_.o] that fails is: @@ -1,5 +1,5 @@ -hello.o: file format elf32-i386 +hello_.o: file format elf32-i386 Disassembly of section .text: @@ -12,7 +12,7 @@ 7: 83 ec 1c sub $0x1c,%esp a: e8 fc ff ff ff call b <main+0xb> b: R_386_PC32 __i686.get_pc_thunk.bx - f: 81 c3 02 00 00 00 add $0x2,%ebx + f: 81 c3 00 00 00 00 add $0x0,%ebx 11: R_386_GOTPC _GLOBAL_OFFSET_TABLE_ 15: 8d 83 00 00 00 00 lea 0x0(%ebx),%eax 17: R_386_GOTOFF .rodata
Following, coming from GCC bug 46275 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46275).
Fixed by http://sourceware.org/ml/binutils/2010-11/msg00056.html