.text
.type foo, @gnu_indirect_function
.globl foo
foo:
leaq __foo(%rip), %rax
retq
.type __foo, @function
__foo:
retq
.type _start, @function
.globl _start
_start:
call foo
1: jmp 1b

$ as -o t.o t.s
$ ld -static -o t t.o
$ readelf -Wr t
Relocation section '.rela.plt' at offset 0xb0 contains 1 entries:
    Offset             Info             Type               Symbol's Value 
Symbol's Name + Addend
00000000006000e8  0000000000000025 R_X86_64_IRELATIVE                           
  00000000004000d8
$ strip t
$ readelf -Wr t
Relocation section '.rela.plt' at offset 0xb0 contains 1 entries:
    Offset             Info             Type               Symbol's Value 
Symbol's Name + Addend
00000000006000e8  0000000000000025 R_X86_64_IRELATIVE                           
  00000000004000d8
$ ld -static -s -o t t.o
Relocation section '.rela.plt' at offset 0xb0 contains 1 entries:
    Offset             Info             Type               Symbol's Value 
Symbol's Name + Addend
0000000000000000  0000000000000000 R_X86_64_NONE                                
  0000000000000000

While this minimal testcase won't work in any case, when actually linking a real
program (say replace _start with main and link with -lc), the program will die
because of unexpected reloc type in statically linked binary.

-- 
           Summary: ld -s -static breaks IRELATIVE relocations
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: jakub at redhat dot com
                CC: bug-binutils at gnu dot org
GCC target triplet: x86_64-linux


http://sourceware.org/bugzilla/show_bug.cgi?id=10911

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to