[lld] r252686 - [elf2] Add support for local TLS symbols.

Michael J. Spencer via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 10 17:28:23 PST 2015


Author: mspencer
Date: Tue Nov 10 19:28:23 2015
New Revision: 252686

URL: http://llvm.org/viewvc/llvm-project?rev=252686&view=rev
Log:
[elf2] Add support for local TLS symbols.

Modified:
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/test/elf2/tls-dynamic.s

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=252686&r1=252685&r2=252686&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Nov 10 19:28:23 2015
@@ -719,11 +719,16 @@ lld::elf2::getLocalRelTarget(const Objec
   if (!Sym)
     error("Unsupported relocation without symbol");
 
+  InputSectionBase<ELFT> *Section = File.getSection(*Sym);
+
+  if (Sym->getType() == STT_TLS)
+    return (Section->OutSec->getVA() + Section->getOffset(*Sym) + Addend) -
+           Out<ELF64LE>::TlsPhdr->p_vaddr;
+
   // According to the ELF spec reference to a local symbol from outside
   // the group are not allowed. Unfortunately .eh_frame breaks that rule
   // and must be treated specially. For now we just replace the symbol with
   // 0.
-  InputSectionBase<ELFT> *Section = File.getSection(*Sym);
   if (Section == &InputSection<ELFT>::Discarded || !Section->isLive())
     return Addend;
 

Modified: lld/trunk/test/elf2/tls-dynamic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/tls-dynamic.s?rev=252686&r1=252685&r2=252686&view=diff
==============================================================================
--- lld/trunk/test/elf2/tls-dynamic.s (original)
+++ lld/trunk/test/elf2/tls-dynamic.s Tue Nov 10 19:28:23 2015
@@ -18,9 +18,7 @@
   .align 4
 a:
 	.long	0
-  
-  .global	b
-  .hidden b
+
 	.section	.tbss,"awT", at nobits
   .align 4
 b:




More information about the llvm-commits mailing list