From: George Rimar Date: Thu, 10 Mar 2016 18:57:17 +0000 (+0000) Subject: [ELF] - Fixed handling R_X86_64_DTPOFF64 relocation relaxation X-Git-Tag: llvmorg-3.9.0-rc1~12049 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1452f485e24138235671086d36249635f97051e6;p=platform%2Fupstream%2Fllvm.git [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 llvm-svn: 263150 --- diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 4cd51ae..e61a072 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -895,6 +895,9 @@ size_t X86_64TargetInfo::relaxTls(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, 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::TlsPhdr->p_memsz); + return 0; case R_X86_64_GOTTPOFF: relocateTlsIeToLe(Loc, BufEnd, P, SA); return 0; diff --git a/lld/test/ELF/tls-opt.s b/lld/test/ELF/tls-opt.s index 06577d7..3be3bbf 100644 --- a/lld/test/ELF/tls-opt.s +++ b/lld/test/ELF/tls-opt.s @@ -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,@object .section .tbss,"awT",@nobits @@ -91,3 +96,12 @@ _start: .word 0x6666 rex64 call __tls_get_addr@plt + + //LD to LE (2): +_DTPOFF64_1: + .quad tls0@DTPOFF + nop + +_DTPOFF64_2: + .quad tls1@DTPOFF + nop