Given the following simpl.s: .file "simpl.c" .globl thrd .section .tdata,"awT",@progbits .align 4 .type thrd, @object .size thrd, 4 thrd: .long 2 .text .globl func .type func, @function func: .byte 0x42 .quad thrd@dtpoff .byte 0x42 .long thrd@dtpoff .byte 0x42 Assembled with gas and then linked with gold produces: 00000e0 0004 0000 0000 0000 fc42 ffff ffff ffff 00000f0 42ff fffc ffff 0042 0002 0000 0004 0000 ie: fffffffffffffffc fffffffc Whereas with binutils-ld: 00000e0 0004 0000 0000 0000 f842 6000 0000 0000 00000f0 4200 fffc ffff 0042 0002 0000 2e00 7973 ie: 00000000006000f8 fffffffc
(this came up while implementing TLS debug info in Clang - it's possible that TLS support in Clang will use this relocation & thus be broken when using binutils-ld to link)
& I guess http://sourceware.org/ml/binutils/2002-09/msg00601.html might be relevant (mentions that this wasn't implemented way back in 2002, perhaps it's still just as unimplemented)
(In reply to David Blaikie from comment #0) > Given the following simpl.s: > > .file "simpl.c" > .globl thrd > .section .tdata,"awT",@progbits > .align 4 > .type thrd, @object > .size thrd, 4 > thrd: > .long 2 > .text > .globl func > .type func, @function > func: > .byte 0x42 > .quad thrd@dtpoff > .byte 0x42 > .long thrd@dtpoff > .byte 0x42 > This insn sequence isn't valid in text section. It can only appear in debug section.
Created attachment 7098 [details] A patch Please try this.
Apologies for the problematic reproduction - just trying to reduce this & accidentally dropped the debug_info section. Of course it does reproduce from within the debug_info section as well. (In reply to H.J. Lu from comment #4) > Created attachment 7098 [details] > A patch > > Please try this. This patch works for me - once I fix a bug in LLVM regarding these very same relocations (for some reason Clang was assembling these as "R_X86_64_64 tls" instead of "R_X86_64_DTPOFF64 tls" yet Gold was somehow OK with that & seemed to give the right answer)
CVSROOT: /cvs/src Module name: src Changes by: hjl@sourceware.org 2013-06-28 15:07:55 Modified files: ld/testsuite : ChangeLog ld/testsuite/ld-x86-64: tlsg.s tlsg.sd bfd : ChangeLog elf64-x86-64.c Log message: Handle R_X86_64_DTPOFF64 bfd/ PR ld/15685 * elf64-x86-64.c (elf_x86_64_relocate_section): Handle R_X86_64_DTPOFF64. ld/testsuite/ PR ld/15685 * ld-x86-64/tlsg.s: Add a test for R_X86_64_DTPOFF64. * ld-x86-64/tlsg.sd: Updated. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1732&r2=1.1733 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/tlsg.s.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/tlsg.sd.diff?cvsroot=src&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.6089&r2=1.6090 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=src&r1=1.297&r2=1.298
.