Bug 12186 - "add ebx, OFFSET FLAT:_GLOBAL_OFFSET_TABLE_" is incorrectly assembled
Summary: "add ebx, OFFSET FLAT:_GLOBAL_OFFSET_TABLE_" is incorrectly assembled
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-03 14:02 UTC by H.J. Lu
Modified: 2010-11-03 14:22 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2010-11-03 14:02:46 UTC
[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
Comment 1 hezekiahehud 2010-11-03 14:18:09 UTC
Following, coming from GCC bug 46275 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46275).
Comment 2 H.J. Lu 2010-11-03 14:22:38 UTC
Fixed by

http://sourceware.org/ml/binutils/2010-11/msg00056.html