[lld] r265981 - Simplify the creation of __rel[a]_iplt_{start,end}.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 11 12:15:00 PDT 2016


Author: rafael
Date: Mon Apr 11 14:14:59 2016
New Revision: 265981

URL: http://llvm.org/viewvc/llvm-project?rev=265981&view=rev
Log:
Simplify the creation of __rel[a]_iplt_{start,end}.

They can be regular DefinedSynthetic.

Modified:
    lld/trunk/ELF/Symbols.h
    lld/trunk/ELF/Writer.cpp
    lld/trunk/test/ELF/aarch64-gnu-ifunc.s
    lld/trunk/test/ELF/gnu-ifunc-i386.s
    lld/trunk/test/ELF/gnu-ifunc.s

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=265981&r1=265980&r2=265981&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Mon Apr 11 14:14:59 2016
@@ -407,8 +407,8 @@ template <class ELFT> struct ElfSym {
 
   // __rel_iplt_start/__rel_iplt_end for signaling
   // where R_[*]_IRELATIVE relocations do live.
-  static DefinedRegular<ELFT> *RelaIpltStart;
-  static DefinedRegular<ELFT> *RelaIpltEnd;
+  static SymbolBody *RelaIpltStart;
+  static SymbolBody *RelaIpltEnd;
 };
 
 template <class ELFT> DefinedRegular<ELFT> *ElfSym<ELFT>::Etext;
@@ -418,8 +418,8 @@ template <class ELFT> DefinedRegular<ELF
 template <class ELFT> DefinedRegular<ELFT> *ElfSym<ELFT>::End;
 template <class ELFT> DefinedRegular<ELFT> *ElfSym<ELFT>::End2;
 template <class ELFT> DefinedRegular<ELFT> *ElfSym<ELFT>::MipsGp;
-template <class ELFT> DefinedRegular<ELFT> *ElfSym<ELFT>::RelaIpltStart;
-template <class ELFT> DefinedRegular<ELFT> *ElfSym<ELFT>::RelaIpltEnd;
+template <class ELFT> SymbolBody *ElfSym<ELFT>::RelaIpltStart;
+template <class ELFT> SymbolBody *ElfSym<ELFT>::RelaIpltEnd;
 
 } // namespace elf
 } // namespace lld

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=265981&r1=265980&r2=265981&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Apr 11 14:14:59 2016
@@ -806,10 +806,14 @@ void Writer<ELFT>::addRelIpltSymbols() {
   if (isOutputDynamic() || !Out<ELFT>::RelaPlt)
     return;
   StringRef S = Config->Rela ? "__rela_iplt_start" : "__rel_iplt_start";
-  ElfSym<ELFT>::RelaIpltStart = Symtab.addIgnored(S);
+  if (Symtab.find(S))
+    ElfSym<ELFT>::RelaIpltStart =
+        Symtab.addSynthetic(S, *Out<ELFT>::RelaPlt, 0, STV_HIDDEN);
 
   S = Config->Rela ? "__rela_iplt_end" : "__rel_iplt_end";
-  ElfSym<ELFT>::RelaIpltEnd = Symtab.addIgnored(S);
+  if (Symtab.find(S))
+    ElfSym<ELFT>::RelaIpltEnd = Symtab.addSynthetic(
+        S, *Out<ELFT>::RelaPlt, DefinedSynthetic<ELFT>::SectionEnd, STV_HIDDEN);
 }
 
 template <class ELFT> static bool includeInSymtab(const SymbolBody &B) {
@@ -1505,16 +1509,6 @@ static uint16_t getELFType() {
 // to each section. This function fixes some predefined absolute
 // symbol values that depend on section address and size.
 template <class ELFT> void Writer<ELFT>::fixAbsoluteSymbols() {
-  // Update __rel[a]_iplt_{start,end} symbols so that they point
-  // to beginning or ending of .rela.plt section, respectively.
-  if (Out<ELFT>::RelaPlt) {
-    uintX_t Start = Out<ELFT>::RelaPlt->getVA();
-    if (ElfSym<ELFT>::RelaIpltStart)
-      ElfSym<ELFT>::RelaIpltStart->Value = Start;
-    if (ElfSym<ELFT>::RelaIpltEnd)
-      ElfSym<ELFT>::RelaIpltEnd->Value = Start + Out<ELFT>::RelaPlt->getSize();
-  }
-
   // Update MIPS _gp absolute symbol so that it points to the static data.
   if (Config->EMachine == EM_MIPS)
     ElfSym<ELFT>::MipsGp->Value = getMipsGpAddr<ELFT>();

Modified: lld/trunk/test/ELF/aarch64-gnu-ifunc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-gnu-ifunc.s?rev=265981&r1=265980&r2=265981&view=diff
==============================================================================
--- lld/trunk/test/ELF/aarch64-gnu-ifunc.s (original)
+++ lld/trunk/test/ELF/aarch64-gnu-ifunc.s Mon Apr 11 14:14:59 2016
@@ -54,7 +54,7 @@
 // CHECK-NEXT:    Other [
 // CHECK-NEXT:      STV_HIDDEN
 // CHECK-NEXT:    ]
-// CHECK-NEXT:    Section: Absolute
+// CHECK-NEXT:    Section: .rela.plt
 // CHECK-NEXT:  }
 // CHECK-NEXT:  Symbol {
 // CHECK-NEXT:    Name: __rela_iplt_start
@@ -65,7 +65,7 @@
 // CHECK-NEXT:    Other [
 // CHECK-NEXT:      STV_HIDDEN
 // CHECK-NEXT:    ]
-// CHECK-NEXT:    Section: Absolute
+// CHECK-NEXT:    Section: .rela.plt
 // CHECK-NEXT:  }
 // CHECK-NEXT:  Symbol {
 // CHECK-NEXT:    Name: _start

Modified: lld/trunk/test/ELF/gnu-ifunc-i386.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gnu-ifunc-i386.s?rev=265981&r1=265980&r2=265981&view=diff
==============================================================================
--- lld/trunk/test/ELF/gnu-ifunc-i386.s (original)
+++ lld/trunk/test/ELF/gnu-ifunc-i386.s Mon Apr 11 14:14:59 2016
@@ -46,7 +46,7 @@
 // CHECK-NEXT:   Other [
 // CHECK-NEXT:     STV_HIDDEN
 // CHECK-NEXT:   ]
-// CHECK-NEXT:   Section: Absolute
+// CHECK-NEXT:   Section: .rel.plt
 // CHECK-NEXT: }
 // CHECK-NEXT: Symbol {
 // CHECK-NEXT:   Name: __rel_iplt_start
@@ -57,7 +57,7 @@
 // CHECK-NEXT:   Other [
 // CHECK-NEXT:     STV_HIDDEN
 // CHECK-NEXT:   ]
-// CHECK-NEXT:   Section: Absolute
+// CHECK-NEXT:   Section: .rel.plt
 // CHECK-NEXT: }
 // CHECK-NEXT: Symbol {
 // CHECK-NEXT:   Name: _start

Modified: lld/trunk/test/ELF/gnu-ifunc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gnu-ifunc.s?rev=265981&r1=265980&r2=265981&view=diff
==============================================================================
--- lld/trunk/test/ELF/gnu-ifunc.s (original)
+++ lld/trunk/test/ELF/gnu-ifunc.s Mon Apr 11 14:14:59 2016
@@ -45,7 +45,7 @@
 // CHECK-NEXT:    Other [
 // CHECK-NEXT:      STV_HIDDEN
 // CHECK-NEXT:    ]
-// CHECK-NEXT:    Section: Absolute
+// CHECK-NEXT:    Section: .rela.plt
 // CHECK-NEXT:  }
 // CHECK-NEXT:  Symbol {
 // CHECK-NEXT:    Name: __rela_iplt_start
@@ -56,7 +56,7 @@
 // CHECK-NEXT:    Other [
 // CHECK-NEXT:      STV_HIDDEN
 // CHECK-NEXT:    ]
-// CHECK-NEXT:    Section: Absolute
+// CHECK-NEXT:    Section: .rela.plt
 // CHECK-NEXT:  }
 // CHECK-NEXT:  Symbol {
 // CHECK-NEXT:    Name: _start




More information about the llvm-commits mailing list