[lld] r269982 - Drop vestigial support for UseLazyBinding=false.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed May 18 14:03:37 PDT 2016


Author: rafael
Date: Wed May 18 16:03:36 2016
New Revision: 269982

URL: http://llvm.org/viewvc/llvm-project?rev=269982&view=rev
Log:
Drop vestigial support for UseLazyBinding=false.

Lazy binding is quite important for use case like a shared build of
llvm. Also, if someone wants to disable it, it is better done in the
compiler (disable plt generation).

The only reason to keep it is to make it easier to add a new
architecture. But it doesn't really help much as it is possible to start
with non lazy relocation and plt code but still let the generic part
create a dedicated .got.plt and .rela.plt.

Modified:
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/Target.cpp
    lld/trunk/ELF/Target.h
    lld/trunk/ELF/Writer.cpp
    lld/trunk/test/ELF/ppc64-toc-restore.s

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=269982&r1=269981&r2=269982&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed May 18 16:03:36 2016
@@ -270,17 +270,14 @@ PltSection<ELFT>::PltSection()
 
 template <class ELFT> void PltSection<ELFT>::writeTo(uint8_t *Buf) {
   size_t Off = 0;
-  if (Target->UseLazyBinding) {
-    // At beginning of PLT, we have code to call the dynamic linker
-    // to resolve dynsyms at runtime. Write such code.
-    Target->writePltZero(Buf);
-    Off += Target->PltZeroSize;
-  }
+  // At beginning of PLT, we have code to call the dynamic linker
+  // to resolve dynsyms at runtime. Write such code.
+  Target->writePltZero(Buf);
+  Off += Target->PltZeroSize;
   for (auto &I : Entries) {
     const SymbolBody *B = I.first;
     unsigned RelOff = I.second;
-    uint64_t Got =
-        Target->UseLazyBinding ? B->getGotPltVA<ELFT>() : B->getGotVA<ELFT>();
+    uint64_t Got = B->getGotPltVA<ELFT>();
     uint64_t Plt = this->getVA() + Off;
     Target->writePlt(Buf + Off, Got, Plt, B->PltIndex, RelOff);
     Off += Target->PltEntrySize;
@@ -289,9 +286,7 @@ template <class ELFT> void PltSection<EL
 
 template <class ELFT> void PltSection<ELFT>::addEntry(SymbolBody &Sym) {
   Sym.PltIndex = Entries.size();
-  unsigned RelOff = Target->UseLazyBinding
-                        ? Out<ELFT>::RelaPlt->getRelocOffset()
-                        : Out<ELFT>::RelaDyn->getRelocOffset();
+  unsigned RelOff = Out<ELFT>::RelaPlt->getRelocOffset();
   Entries.push_back(std::make_pair(&Sym, RelOff));
 }
 

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=269982&r1=269981&r2=269982&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Wed May 18 16:03:36 2016
@@ -264,7 +264,6 @@ X86TargetInfo::X86TargetInfo() {
   TlsGotRel = R_386_TLS_TPOFF;
   TlsModuleIndexRel = R_386_TLS_DTPMOD32;
   TlsOffsetRel = R_386_TLS_DTPOFF32;
-  UseLazyBinding = true;
   PltEntrySize = 16;
   PltZeroSize = 16;
   TlsGdToLeSkip = 2;
@@ -495,7 +494,6 @@ X86_64TargetInfo::X86_64TargetInfo() {
   TlsGotRel = R_X86_64_TPOFF64;
   TlsModuleIndexRel = R_X86_64_DTPMOD64;
   TlsOffsetRel = R_X86_64_DTPOFF64;
-  UseLazyBinding = true;
   PltEntrySize = 16;
   PltZeroSize = 16;
   TlsGdToLeSkip = 2;
@@ -760,7 +758,7 @@ RelExpr PPCTargetInfo::getRelExpr(uint32
 }
 
 PPC64TargetInfo::PPC64TargetInfo() {
-  GotRel = R_PPC64_GLOB_DAT;
+  PltRel = GotRel = R_PPC64_GLOB_DAT;
   RelativeRel = R_PPC64_RELATIVE;
   PltEntrySize = 32;
 
@@ -936,7 +934,6 @@ AArch64TargetInfo::AArch64TargetInfo() {
   TlsGotRel = R_AARCH64_TLS_TPREL64;
   TlsModuleIndexRel = R_AARCH64_TLS_DTPMOD64;
   TlsOffsetRel = R_AARCH64_TLS_DTPREL64;
-  UseLazyBinding = true;
   PltEntrySize = 16;
   PltZeroSize = 32;
 }
@@ -1235,7 +1232,6 @@ template <class ELFT> MipsTargetInfo<ELF
   PltEntrySize = 16;
   PltZeroSize = 32;
   ThunkSize = 16;
-  UseLazyBinding = true;
   CopyRel = R_MIPS_COPY;
   PltRel = R_MIPS_JUMP_SLOT;
   if (ELFT::Is64Bits)

Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=269982&r1=269981&r2=269982&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Wed May 18 16:03:36 2016
@@ -84,7 +84,6 @@ public:
   unsigned GotPltHeaderEntriesNum = 3;
 
   uint32_t ThunkSize = 0;
-  bool UseLazyBinding = false;
 
   virtual void relaxTlsGdToIe(uint8_t *Loc, uint32_t Type, uint64_t Val) const;
   virtual void relaxTlsGdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const;

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=269982&r1=269981&r2=269982&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed May 18 16:03:36 2016
@@ -170,11 +170,9 @@ template <class ELFT> void elf::writeRes
     GnuHashTab.reset(new GnuHashTableSection<ELFT>);
   if (Config->SysvHash)
     HashTab.reset(new HashTableSection<ELFT>);
-  if (Target->UseLazyBinding) {
-    StringRef S = Config->Rela ? ".rela.plt" : ".rel.plt";
-    GotPlt.reset(new GotPltSection<ELFT>);
-    RelaPlt.reset(new RelocationSection<ELFT>(S, false /*Sort*/));
-  }
+  StringRef S = Config->Rela ? ".rela.plt" : ".rel.plt";
+  GotPlt.reset(new GotPltSection<ELFT>);
+  RelaPlt.reset(new RelocationSection<ELFT>(S, false /*Sort*/));
   if (!Config->StripAll) {
     StrTab.reset(new StringTableSection<ELFT>(".strtab", false));
     SymTabSec.reset(new SymbolTableSection<ELFT>(*Symtab, *StrTab));
@@ -733,20 +731,12 @@ void Writer<ELFT>::scanRelocs(InputSecti
       if (Body.isGnuIFunc())
         Rel = Preemptible ? Target->PltRel : Target->IRelativeRel;
       else
-        Rel = Target->UseLazyBinding ? Target->PltRel : Target->GotRel;
+        Rel = Target->PltRel;
 
-      if (Target->UseLazyBinding) {
-        Out<ELFT>::GotPlt->addEntry(Body);
-        Out<ELFT>::RelaPlt->addReloc({Rel, Out<ELFT>::GotPlt,
-                                      Body.getGotPltOffset<ELFT>(),
-                                      !Preemptible, &Body, 0});
-      } else {
-        if (Body.isInGot())
-          continue;
-        Out<ELFT>::Got->addEntry(Body);
-        AddDyn({Rel, Out<ELFT>::Got, Body.getGotOffset<ELFT>(), !Preemptible,
-                &Body, 0});
-      }
+      Out<ELFT>::GotPlt->addEntry(Body);
+      Out<ELFT>::RelaPlt->addReloc({Rel, Out<ELFT>::GotPlt,
+                                    Body.getGotPltOffset<ELFT>(), !Preemptible,
+                                    &Body, 0});
       continue;
     }
 

Modified: lld/trunk/test/ELF/ppc64-toc-restore.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/ppc64-toc-restore.s?rev=269982&r1=269981&r2=269982&view=diff
==============================================================================
--- lld/trunk/test/ELF/ppc64-toc-restore.s (original)
+++ lld/trunk/test/ELF/ppc64-toc-restore.s Wed May 18 16:03:36 2016
@@ -53,8 +53,8 @@ last:
 // CHECK: Disassembly of section .plt:
 // CHECK: .plt:
 // CHECK: 10010020:       f8 41 00 28     std 2, 40(1)
-// CHECK: 10010024:       3d 62 00 00     addis 11, 2, 0
-// CHECK: 10010028:       e9 8b 80 00     ld 12, -32768(11)
+// CHECK: 10010024:       3d 62 10 03     addis 11, 2, 4099
+// CHECK: 10010028:       e9 8b 80 18     ld 12, -32744(11)
 // CHECK: 1001002c:       e9 6c 00 00     ld 11, 0(12)
 // CHECK: 10010030:       7d 69 03 a6     mtctr 11
 // CHECK: 10010034:       e8 4c 00 08     ld 2, 8(12)




More information about the llvm-commits mailing list