Index: lld/trunk/ELF/InputSection.cpp =================================================================== --- lld/trunk/ELF/InputSection.cpp +++ lld/trunk/ELF/InputSection.cpp @@ -411,8 +411,10 @@ } uintX_t AddrLoc = this->OutSec->getVA() + Offset; - uint64_t SymVA = SignExtend64( - getSymVA(Type, Addend, AddrLoc, Sym, R_ABS)); + uint64_t SymVA = 0; + if (!Sym.isTls() || Out::TlsPhdr) + SymVA = SignExtend64( + getSymVA(Type, Addend, AddrLoc, Sym, R_ABS)); Target->relocateOne(BufLoc, Type, SymVA); } } Index: lld/trunk/test/ELF/gc-debuginfo-tls.s =================================================================== --- lld/trunk/test/ELF/gc-debuginfo-tls.s +++ lld/trunk/test/ELF/gc-debuginfo-tls.s @@ -0,0 +1,23 @@ +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld %t.o --gc-sections -shared -o %t1 +# RUN: ld.lld %t.o -shared -o %t2 +# RUN: llvm-readobj -symbols %t1 | FileCheck %s --check-prefix=GC +# RUN: llvm-readobj -symbols %t2 | FileCheck %s --check-prefix=NOGC + +# NOGC: Symbol { +# NOGC: Name: .tbss +# NOGC: Value: 0x1000 +# NOGC: Size: 0 +# NOGC: Binding: Local +# NOGC: Type: TLS +# NOGC: Other: 0 +# NOGC: Section: .tbss +# NOGC: } + +# GC-NOT: tbss + +.section .tbss,"awT",@nobits +patatino: + .long 0 + .section .noalloc,"" + .quad patatino