bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gas/29551] New: Wrong relocations against _GLOBAL_OFFSET_TABLE_


From: hjl.tools at gmail dot com
Subject: [Bug gas/29551] New: Wrong relocations against _GLOBAL_OFFSET_TABLE_
Date: Tue, 06 Sep 2022 15:53:01 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=29551

            Bug ID: 29551
           Summary: Wrong relocations against _GLOBAL_OFFSET_TABLE_
           Product: binutils
           Version: 2.40 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gas
          Assignee: unassigned at sourceware dot org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---
            Target: i386,x86-64

[hjl@gnu-tgl-3 tmp]$ cat 32.s 
        .text
        movl $_GLOBAL_OFFSET_TABLE_, %eax
        .data
        .long _GLOBAL_OFFSET_TABLE_
[hjl@gnu-tgl-3 tmp]$ gcc -c 32.s -m32 
[hjl@gnu-tgl-3 tmp]$ readelf -r 32.o

Relocation section '.rel.text' at offset 0xa0 contains 1 entry:
 Offset     Info    Type            Sym.Value  Sym. Name
00000001  0000010a R_386_GOTPC       00000000   _GLOBAL_OFFSET_TABLE_

Relocation section '.rel.data' at offset 0xa8 contains 1 entry:
 Offset     Info    Type            Sym.Value  Sym. Name
00000000  0000010a R_386_GOTPC       00000000   _GLOBAL_OFFSET_TABLE_
[hjl@gnu-tgl-3 tmp]$ 

R_386_32 should be used.

[hjl@gnu-tgl-3 tmp]$ cat 64.s 
        .text
        movl $_GLOBAL_OFFSET_TABLE_, %eax
        movq _GLOBAL_OFFSET_TABLE_@GOTPCREL(%rip), %rax
        .data
        .quad _GLOBAL_OFFSET_TABLE_
[hjl@gnu-tgl-3 tmp]$ gcc -c 64.s
[hjl@gnu-tgl-3 tmp]$ readelf -rW 64.o

Relocation section '.rela.text' at offset 0xd0 contains 2 entries:
    Offset             Info             Type               Symbol's Value 
Symbol's Name + Addend
0000000000000001  000000010000001a R_X86_64_GOTPC32       0000000000000000
_GLOBAL_OFFSET_TABLE_ + 1
0000000000000008  0000000100000019 R_X86_64_GOTOFF64      0000000000000000
_GLOBAL_OFFSET_TABLE_ - 4

Relocation section '.rela.data' at offset 0x100 contains 1 entry:
    Offset             Info             Type               Symbol's Value 
Symbol's Name + Addend
0000000000000000  000000010000001d R_X86_64_GOTPC64       0000000000000000
_GLOBAL_OFFSET_TABLE_ + 0
[hjl@gnu-tgl-3 tmp]$ 

Relocations should be

[hjl@gnu-tgl-3 tmp]$ readelf -rW 64x.o 

Relocation section '.rela.text' at offset 0xe8 contains 2 entries:
    Offset             Info             Type               Symbol's Value 
Symbol's Name + Addend
0000000000000001  000000010000000a R_X86_64_32            0000000000000000
_GLOBAL_OFFSET_TABLE_ + 0
0000000000000008  000000010000002a R_X86_64_REX_GOTPCRELX 0000000000000000
_GLOBAL_OFFSET_TABLE_ - 4

Relocation section '.rela.data' at offset 0x118 contains 1 entry:
    Offset             Info             Type               Symbol's Value 
Symbol's Name + Addend
0000000000000000  0000000100000001 R_X86_64_64            0000000000000000
_GLOBAL_OFFSET_TABLE_ + 0
[hjl@gnu-tgl-3 tmp]$

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]