[lld] r263150 - [ELF] - Fixed handling R_X86_64_DTPOFF64 relocation relaxation

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 10 11:17:44 PST 2016


Heh, thanks - I remember hitting the fact that binutils LD didn't implement
this reloc either (GCC would produce 32 bits of zeros, then the 32 bit
reloc - I implementdd it in Clang to juse use the 64 bit reloc instead) had
a bug or something for about a decade about it. That's how I found out I
wasn't using gold... (Gold doesn't have this bug) :)
On Mar 10, 2016 11:02 AM, "George Rimar via llvm-commits" <
llvm-commits at lists.llvm.org> wrote:

> Author: grimar
> Date: Thu Mar 10 12:57:17 2016
> New Revision: 263150
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263150&view=rev
> Log:
> [ELF] - Fixed handling R_X86_64_DTPOFF64 relocation relaxation
>
> R_X86_64_DTPOFF64 was not handled properly.
> Next sample app was impossible to link before this patch:
>
> ~/pg/release/bin/clang -target x86_64-pc-linux testthread.cpp -c -g
> ~/pg/d+a/bin/ld.lld testthread.o
> "Unknown TLS optimization" (value was 17)
>
> __thread int x = 0;
> void _start() {
> }
>
> It works fine now.
>
> Differential revision: http://reviews.llvm.org/D18039
>
> Modified:
>     lld/trunk/ELF/Target.cpp
>     lld/trunk/test/ELF/tls-opt.s
>
> Modified: lld/trunk/ELF/Target.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=263150&r1=263149&r2=263150&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/Target.cpp (original)
> +++ lld/trunk/ELF/Target.cpp Thu Mar 10 12:57:17 2016
> @@ -895,6 +895,9 @@ size_t X86_64TargetInfo::relaxTls(uint8_
>    case R_X86_64_DTPOFF32:
>      relocateOne(Loc, BufEnd, R_X86_64_TPOFF32, P, SA);
>      return 0;
> +  case R_X86_64_DTPOFF64:
> +    write64le(Loc, SA - Out<ELF64LE>::TlsPhdr->p_memsz);
> +    return 0;
>    case R_X86_64_GOTTPOFF:
>      relocateTlsIeToLe(Loc, BufEnd, P, SA);
>      return 0;
>
> Modified: lld/trunk/test/ELF/tls-opt.s
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/tls-opt.s?rev=263150&r1=263149&r2=263150&view=diff
>
> ==============================================================================
> --- lld/trunk/test/ELF/tls-opt.s (original)
> +++ lld/trunk/test/ELF/tls-opt.s Thu Mar 10 12:57:17 2016
> @@ -35,6 +35,11 @@
>  // DISASM-NEXT: 1109a: 48 8d 80 f8 ff ff ff                leaq -8(%rax),
> %rax
>  // DISASM-NEXT: 110a1: 64 48 8b 04 25 00 00 00 00          movq %fs:0,
> %rax
>  // DISASM-NEXT: 110aa: 48 8d 80 fc ff ff ff                leaq -4(%rax),
> %rax
> +// LD to LE (2):
> +// DISASM:      _DTPOFF64_1:
> +// DISASM-NEXT: 110b1: f8
> +// DISASM:      _DTPOFF64_2:
> +// DISASM-NEXT: 110ba: fc
>
>  .type tls0, at object
>  .section .tbss,"awT", at nobits
> @@ -91,3 +96,12 @@ _start:
>   .word 0x6666
>   rex64
>   call __tls_get_addr at plt
> +
> + //LD to LE (2):
> +_DTPOFF64_1:
> + .quad tls0 at DTPOFF
> + nop
> +
> +_DTPOFF64_2:
> + .quad tls1 at DTPOFF
> + nop
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160310/0f27f8bc/attachment.html>


More information about the llvm-commits mailing list