[lld] r264032 - [ELF][MIPS] Delete GotSection::addMipsLocalEntry method

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 01:36:49 PDT 2016


Author: atanasyan
Date: Tue Mar 22 03:36:48 2016
New Revision: 264032

URL: http://llvm.org/viewvc/llvm-project?rev=264032&view=rev
Log:
[ELF][MIPS] Delete GotSection::addMipsLocalEntry method

Now local symbols have SymbolBody so we can handle all kind of symbols
in the GotSection::addEntry method. The patch moves the code from
addMipsLocalEntry to addEntry. NFC.

Differential Revision: http://reviews.llvm.org/D18302

Modified:
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/OutputSections.h
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=264032&r1=264031&r2=264032&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Mar 22 03:36:48 2016
@@ -90,14 +90,22 @@ GotSection<ELFT>::GotSection()
 }
 
 template <class ELFT> void GotSection<ELFT>::addEntry(SymbolBody &Sym) {
+  if (Config->EMachine == EM_MIPS) {
+    if (Sym.isPreemptible())
+      // All symbols with MIPS GOT entries should be represented
+      // in the dynamic symbols table. See "Global Offset Table" in Chapter 5:
+      // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
+      Sym.MustBeInDynSym = true;
+    else {
+      // FIXME (simon): Do not add so many redundant entries.
+      ++MipsLocalEntries;
+      return;
+    }
+  }
   Sym.GotIndex = Entries.size();
   Entries.push_back(&Sym);
 }
 
-template <class ELFT> void GotSection<ELFT>::addMipsLocalEntry() {
-  ++MipsLocalEntries;
-}
-
 template <class ELFT> bool GotSection<ELFT>::addDynTlsEntry(SymbolBody &Sym) {
   if (Sym.hasGlobalDynIndex())
     return false;

Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=264032&r1=264031&r2=264032&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Tue Mar 22 03:36:48 2016
@@ -100,7 +100,6 @@ public:
   void finalize() override;
   void writeTo(uint8_t *Buf) override;
   void addEntry(SymbolBody &Sym);
-  void addMipsLocalEntry();
   bool addDynTlsEntry(SymbolBody &Sym);
   bool addTlsIndex();
   bool empty() const { return MipsLocalEntries == 0 && Entries.empty(); }

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=264032&r1=264031&r2=264032&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Mar 22 03:36:48 2016
@@ -335,14 +335,6 @@ void Writer<ELFT>::scanRelocs(InputSecti
       Out<ELFT>::RelaDyn->addReloc({Target->RelativeRel, &C, RI.r_offset, true,
                                     &Body, getAddend<ELFT>(RI)});
 
-    // MIPS has a special rule to create GOTs for local symbols.
-    if (Config->EMachine == EM_MIPS && !Preemptible &&
-        Target->needsGot(Type, Body)) {
-      // FIXME (simon): Do not add so many redundant entries.
-      Out<ELFT>::Got->addMipsLocalEntry();
-      continue;
-    }
-
     // If a symbol in a DSO is referenced directly instead of through GOT,
     // we need to create a copy relocation for the symbol.
     if (auto *B = dyn_cast<SharedSymbol<ELFT>>(&Body)) {
@@ -407,15 +399,13 @@ void Writer<ELFT>::scanRelocs(InputSecti
         continue;
       Out<ELFT>::Got->addEntry(Body);
 
-      if (Config->EMachine == EM_MIPS) {
+      if (Config->EMachine == EM_MIPS)
         // MIPS ABI has special rules to process GOT entries
         // and doesn't require relocation entries for them.
         // See "Global Offset Table" in Chapter 5 in the following document
         // for detailed description:
         // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
-        Body.MustBeInDynSym = true;
         continue;
-      }
 
       bool Dynrel = Config->Pic && !Target->isRelRelative(Type) &&
                     !Target->isSizeRel(Type);




More information about the llvm-commits mailing list