[lld] r262957 - Remove an unnecessary hack.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 8 13:17:31 PST 2016


Author: rafael
Date: Tue Mar  8 15:17:31 2016
New Revision: 262957

URL: http://llvm.org/viewvc/llvm-project?rev=262957&view=rev
Log:
Remove an unnecessary hack.

It doesn't look like anything is depending on using local dynamic tls
relocations with preemptable  symbols.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/OutputSections.h
    lld/trunk/ELF/Target.cpp
    lld/trunk/ELF/Writer.cpp
    lld/trunk/test/ELF/tls-dynamic-i686.s
    lld/trunk/test/ELF/tls-dynamic.s

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=262957&r1=262956&r2=262957&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Mar  8 15:17:31 2016
@@ -271,7 +271,7 @@ void InputSectionBase<ELFT>::relocate(ui
     }
 
     uintX_t SymVA = Body->getVA<ELFT>();
-    bool CBP = canBePreempted(Body, Type);
+    bool CBP = canBePreempted(Body);
     if (Target->needsPlt<ELFT>(Type, *Body)) {
       SymVA = Body->getPltVA<ELFT>();
     } else if (Target->needsGot(Type, *Body)) {

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=262957&r1=262956&r2=262957&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Mar  8 15:17:31 2016
@@ -176,7 +176,7 @@ template <class ELFT> void GotSection<EL
     // for detailed description:
     // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
     // As the first approach, we can just store addresses for all symbols.
-    if (Config->EMachine != EM_MIPS && canBePreempted(B, 0))
+    if (Config->EMachine != EM_MIPS && canBePreempted(B))
       continue; // The dynamic linker will take care of it.
     uintX_t VA = B->getVA<ELFT>();
     write<uintX_t, ELFT::TargetEndianness, sizeof(uintX_t)>(Entry, VA);
@@ -932,16 +932,9 @@ elf::getLocalRelTarget(const ObjectFile<
 
 // Returns true if a symbol can be replaced at load-time by a symbol
 // with the same name defined in other ELF executable or DSO.
-bool elf::canBePreempted(const SymbolBody *Body, unsigned Type) {
+bool elf::canBePreempted(const SymbolBody *Body) {
   if (!Body)
     return false;  // Body is a local symbol.
-
-  // FIXME: Both gold and bfd consider that a local dynamic tls relocation to
-  // a symbol will not be preempted. Is that actually relevant? The compiler
-  // should not use it if the symbol can be preempted.
-  if (Target->isTlsLocalDynamicRel(Type))
-    return false;
-
   if (Body->isShared())
     return true;
 

Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=262957&r1=262956&r2=262957&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Tue Mar  8 15:17:31 2016
@@ -53,7 +53,7 @@ getLocalRelTarget(const ObjectFile<ELFT>
                   const llvm::object::Elf_Rel_Impl<ELFT, IsRela> &Rel,
                   typename llvm::object::ELFFile<ELFT>::uintX_t Addend);
 
-bool canBePreempted(const SymbolBody *Body, unsigned Type);
+bool canBePreempted(const SymbolBody *Body);
 
 bool isValidCIdentifier(StringRef S);
 

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=262957&r1=262956&r2=262957&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Tue Mar  8 15:17:31 2016
@@ -278,7 +278,7 @@ bool TargetInfo::canRelaxTls(uint32_t Ty
   // Initial-Exec relocs can be relaxed to Local-Exec if the symbol is locally
   // defined.
   if (isTlsInitialExecRel(Type))
-    return !canBePreempted(S, Type);
+    return !canBePreempted(S);
 
   return false;
 }
@@ -317,7 +317,7 @@ TargetInfo::PltNeed TargetInfo::needsPlt
                                          const SymbolBody &S) const {
   if (isGnuIFunc<ELFT>(S))
     return Plt_Explicit;
-  if (canBePreempted(&S, Type) && needsPltImpl(Type))
+  if (canBePreempted(&S) && needsPltImpl(Type))
     return Plt_Explicit;
 
   // This handles a non PIC program call to function in a shared library.
@@ -470,7 +470,7 @@ bool X86TargetInfo::needsCopyRelImpl(uin
 
 bool X86TargetInfo::needsGot(uint32_t Type, SymbolBody &S) const {
   if (S.IsTls && Type == R_386_TLS_GD)
-    return Target->canRelaxTls(Type, &S) && canBePreempted(&S, Type);
+    return Target->canRelaxTls(Type, &S) && canBePreempted(&S);
   if (Type == R_386_TLS_GOTIE || Type == R_386_TLS_IE)
     return !canRelaxTls(Type, &S);
   return Type == R_386_GOT32 || needsPlt<ELF32LE>(Type, S);
@@ -548,7 +548,7 @@ size_t X86TargetInfo::relaxTls(uint8_t *
                                const SymbolBody *S) const {
   switch (Type) {
   case R_386_TLS_GD:
-    if (canBePreempted(S, Type))
+    if (canBePreempted(S))
       relocateTlsGdToIe(Loc, BufEnd, P, SA);
     else
       relocateTlsGdToLe(Loc, BufEnd, P, SA);
@@ -732,7 +732,7 @@ bool X86_64TargetInfo::refersToGotEntry(
 
 bool X86_64TargetInfo::needsGot(uint32_t Type, SymbolBody &S) const {
   if (Type == R_X86_64_TLSGD)
-    return Target->canRelaxTls(Type, &S) && canBePreempted(&S, Type);
+    return Target->canRelaxTls(Type, &S) && canBePreempted(&S);
   if (Type == R_X86_64_GOTTPOFF)
     return !canRelaxTls(Type, &S);
   return refersToGotEntry(Type) || needsPlt<ELF64LE>(Type, S);
@@ -899,7 +899,7 @@ size_t X86_64TargetInfo::relaxTls(uint8_
     relocateTlsIeToLe(Loc, BufEnd, P, SA);
     return 0;
   case R_X86_64_TLSGD: {
-    if (canBePreempted(S, Type))
+    if (canBePreempted(S))
       relocateTlsGdToIe(Loc, BufEnd, P, SA);
     else
       relocateTlsGdToLe(Loc, BufEnd, P, SA);
@@ -1466,7 +1466,7 @@ size_t AArch64TargetInfo::relaxTls(uint8
   case R_AARCH64_TLSDESC_LD64_LO12_NC:
   case R_AARCH64_TLSDESC_ADD_LO12_NC:
   case R_AARCH64_TLSDESC_CALL: {
-    if (canBePreempted(S, Type))
+    if (canBePreempted(S))
       fatal("Unsupported TLS optimization");
     uint64_t X = S ? S->getVA<ELF64LE>() : SA;
     relocateTlsGdToLe(Type, Loc, BufEnd, P, X);

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=262957&r1=262956&r2=262957&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Mar  8 15:17:31 2016
@@ -281,7 +281,7 @@ static bool handleTlsRelocation(uint32_t
       }
       return true;
     }
-    if (!canBePreempted(Body, Type))
+    if (!canBePreempted(Body))
       return true;
   }
   return false;
@@ -327,7 +327,7 @@ void Writer<ELFT>::scanRelocs(
     if (Body)
       Body = Body->repl();
 
-    bool CBP = canBePreempted(Body, Type);
+    bool CBP = canBePreempted(Body);
     if (handleTlsRelocation<ELFT>(Type, Body, C, RI))
       continue;
 

Modified: lld/trunk/test/ELF/tls-dynamic-i686.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/tls-dynamic-i686.s?rev=262957&r1=262956&r2=262957&view=diff
==============================================================================
--- lld/trunk/test/ELF/tls-dynamic-i686.s (original)
+++ lld/trunk/test/ELF/tls-dynamic-i686.s Tue Mar  8 15:17:31 2016
@@ -19,6 +19,14 @@ tls1:
  .long 0
  .size tls1, 4
 
+.type  tls2, at object
+.globl tls2
+.hidden tls2
+.align 4
+tls2:
+ .long 0
+ .size tls2, 4
+
 .section .text
 .globl _start
 _start:
@@ -28,13 +36,13 @@ call __tls_get_addr at plt
 leal tls1 at tlsgd(,%ebx,1),%eax
 call __tls_get_addr at plt
 
-leal tls0 at tlsldm(%ebx),%eax
+leal tls2 at tlsldm(%ebx),%eax
 call __tls_get_addr at plt
-leal tls0 at dtpoff(%eax),%edx
+leal tls2 at dtpoff(%eax),%edx
 
-leal tls1 at tlsldm(%ebx),%eax
+leal tls2 at tlsldm(%ebx),%eax
 call __tls_get_addr at plt
-leal tls1 at dtpoff(%eax),%edx
+leal tls2 at dtpoff(%eax),%edx
 
 movl %gs:0,%eax
 addl tls0 at gotntpoff(%ebx),%eax
@@ -81,10 +89,10 @@ addl tls1 at gotntpoff(%ebx),%eax
 // -16 is a local module tls index offset.
 // DIS-NEXT: 1018: 8d 83 f0 ff ff ff leal -16(%ebx), %eax
 // DIS-NEXT: 101e: e8 4d 00 00 00    calll 77
-// DIS-NEXT: 1023: 8d 90 00 00 00 00 leal (%eax), %edx
+// DIS-NEXT: 1023: 8d 90 08 00 00 00 leal 8(%eax), %edx
 // DIS-NEXT: 1029: 8d 83 f0 ff ff ff leal -16(%ebx), %eax
 // DIS-NEXT: 102f: e8 3c 00 00 00    calll 60
-// DIS-NEXT: 1034: 8d 90 04 00 00 00 leal 4(%eax), %edx
+// DIS-NEXT: 1034: 8d 90 08 00 00 00 leal 8(%eax), %edx
 // Initial exec model:
 // DIS-NEXT: 103a: 65 a1 00 00 00 00 movl %gs:0, %eax
 // DIS-NEXT: 1040: 03 83 f8 ff ff ff addl -8(%ebx), %eax

Modified: lld/trunk/test/ELF/tls-dynamic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/tls-dynamic.s?rev=262957&r1=262956&r2=262957&view=diff
==============================================================================
--- lld/trunk/test/ELF/tls-dynamic.s (original)
+++ lld/trunk/test/ELF/tls-dynamic.s Tue Mar  8 15:17:31 2016
@@ -14,13 +14,13 @@
   leaq  c at tlsgd(%rip), %rdi
   rex64
   callq __tls_get_addr at PLT
-  leaq  c at dtpoff(%rax), %rcx
+  leaq  a at dtpoff(%rax), %rcx
   // Initial Exec Model Code Sequence, II
   movq c at gottpoff(%rip),%rax
   movq %fs:(%rax),%rax
   movabs $a at dtpoff, %rax
   movabs $b at dtpoff, %rax
-  movabs $c at dtpoff, %rax
+  movabs $a at dtpoff, %rax
 
   .global a
   .hidden a
@@ -79,9 +79,9 @@ c:
 // DIS-NEXT:     102c: 00 00
 // DIS-NEXT:     102e: {{.+}} leaq    4267(%rip), %rdi
 // DIS-NEXT:     1035: {{.+}} callq
-// DIS-NEXT:     103b: {{.+}} leaq    8(%rax), %rcx
+// DIS-NEXT:     103b: {{.+}} leaq    (%rax), %rcx
 // DIS-NEXT:     1042: {{.+}} movq    4263(%rip), %rax
 // DIS-NEXT:     1049: {{.+}} movq    %fs:(%rax), %rax
 // DIS-NEXT:     104d: {{.+}} movabsq $0, %rax
 // DIS-NEXT:     1057: {{.+}} movabsq $4, %rax
-// DIS-NEXT:     1061: {{.+}} movabsq $8, %rax
+// DIS-NEXT:     1061: {{.+}} movabsq $0, %rax




More information about the llvm-commits mailing list