[lld] r325016 - Add a simpler version of addReloc. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 08:03:53 PST 2018


Author: rafael
Date: Tue Feb 13 08:03:52 2018
New Revision: 325016

URL: http://llvm.org/viewvc/llvm-project?rev=325016&view=rev
Log:
Add a simpler version of addReloc. NFC.

Extracted from a patch by Alexander Richardson!

Modified:
    lld/trunk/ELF/Relocations.cpp
    lld/trunk/ELF/SyntheticSections.cpp
    lld/trunk/ELF/SyntheticSections.h

Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=325016&r1=325015&r2=325016&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Tue Feb 13 08:03:52 2018
@@ -92,9 +92,8 @@ static unsigned handleMipsTlsRelocation(
                                         int64_t Addend, RelExpr Expr) {
   if (Expr == R_MIPS_TLSLD) {
     if (InX::MipsGot->addTlsIndex() && Config->Pic)
-      InX::RelaDyn->addReloc({Target->TlsModuleIndexRel, InX::MipsGot,
-                              InX::MipsGot->getTlsIndexOff(), false, nullptr,
-                              0});
+      InX::RelaDyn->addReloc(Target->TlsModuleIndexRel, InX::MipsGot,
+                             InX::MipsGot->getTlsIndexOff(), nullptr);
     C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym});
     return 1;
   }
@@ -102,11 +101,11 @@ static unsigned handleMipsTlsRelocation(
   if (Expr == R_MIPS_TLSGD) {
     if (InX::MipsGot->addDynTlsEntry(Sym) && Sym.IsPreemptible) {
       uint64_t Off = InX::MipsGot->getGlobalDynOffset(Sym);
-      InX::RelaDyn->addReloc(
-          {Target->TlsModuleIndexRel, InX::MipsGot, Off, false, &Sym, 0});
+      InX::RelaDyn->addReloc(Target->TlsModuleIndexRel, InX::MipsGot, Off,
+                             &Sym);
       if (Sym.IsPreemptible)
-        InX::RelaDyn->addReloc({Target->TlsOffsetRel, InX::MipsGot,
-                                Off + Config->Wordsize, false, &Sym, 0});
+        InX::RelaDyn->addReloc(Target->TlsOffsetRel, InX::MipsGot,
+                               Off + Config->Wordsize, &Sym);
     }
     C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym});
     return 1;
@@ -140,7 +139,7 @@ static unsigned handleARMTlsRelocation(R
 
   auto AddTlsReloc = [&](uint64_t Off, RelType Type, Symbol *Dest, bool Dyn) {
     if (Dyn)
-      InX::RelaDyn->addReloc({Type, InX::Got, Off, false, Dest, 0});
+      InX::RelaDyn->addReloc(Type, InX::Got, Off, Dest);
     else
       InX::Got->Relocations.push_back({R_ABS, Type, Off, 0, Dest});
   };
@@ -208,8 +207,8 @@ handleTlsRelocation(RelType Type, Symbol
       return 2;
     }
     if (InX::Got->addTlsIndex())
-      InX::RelaDyn->addReloc({Target->TlsModuleIndexRel, InX::Got,
-                              InX::Got->getTlsIndexOff(), false, nullptr, 0});
+      InX::RelaDyn->addReloc(Target->TlsModuleIndexRel, InX::Got,
+                             InX::Got->getTlsIndexOff(), nullptr);
     C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym});
     return 1;
   }
@@ -225,15 +224,14 @@ handleTlsRelocation(RelType Type, Symbol
     if (Config->Shared) {
       if (InX::Got->addDynTlsEntry(Sym)) {
         uint64_t Off = InX::Got->getGlobalDynOffset(Sym);
-        InX::RelaDyn->addReloc(
-            {Target->TlsModuleIndexRel, InX::Got, Off, false, &Sym, 0});
+        InX::RelaDyn->addReloc(Target->TlsModuleIndexRel, InX::Got, Off, &Sym);
 
         // If the symbol is preemptible we need the dynamic linker to write
         // the offset too.
         uint64_t OffsetOff = Off + Config->Wordsize;
         if (Sym.IsPreemptible)
-          InX::RelaDyn->addReloc(
-              {Target->TlsOffsetRel, InX::Got, OffsetOff, false, &Sym, 0});
+          InX::RelaDyn->addReloc(Target->TlsOffsetRel, InX::Got, OffsetOff,
+                                 &Sym);
         else
           InX::Got->Relocations.push_back(
               {R_ABS, Target->TlsOffsetRel, OffsetOff, 0, &Sym});
@@ -250,8 +248,8 @@ handleTlsRelocation(RelType Type, Symbol
            Offset, Addend, &Sym});
       if (!Sym.isInGot()) {
         InX::Got->addEntry(Sym);
-        InX::RelaDyn->addReloc(
-            {Target->TlsGotRel, InX::Got, Sym.getGotOffset(), false, &Sym, 0});
+        InX::RelaDyn->addReloc(Target->TlsGotRel, InX::Got, Sym.getGotOffset(),
+                               &Sym);
       }
     } else {
       C.Relocations.push_back(
@@ -531,7 +529,7 @@ template <class ELFT> static void addCop
     Sym->Used = true;
   }
 
-  InX::RelaDyn->addReloc({Target->CopyRel, Sec, 0, false, &SS, 0});
+  InX::RelaDyn->addReloc(Target->CopyRel, Sec, 0, &SS);
 }
 
 // MIPS has an odd notion of "paired" relocations to calculate addends.
@@ -978,8 +976,8 @@ static void scanReloc(InputSectionBase &
       // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
       InX::MipsGot->addEntry(Sym, Addend, Expr);
       if (Sym.isTls() && Sym.IsPreemptible)
-        InX::RelaDyn->addReloc({Target->TlsGotRel, InX::MipsGot,
-                                Sym.getGotOffset(), false, &Sym, 0});
+        InX::RelaDyn->addReloc(Target->TlsGotRel, InX::MipsGot,
+                               Sym.getGotOffset(), &Sym);
     } else if (!Sym.isInGot()) {
       addGotEntry<ELFT>(Sym);
     }

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=325016&r1=325015&r2=325016&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Tue Feb 13 08:03:52 2018
@@ -1202,6 +1202,11 @@ RelocationBaseSection::RelocationBaseSec
     : SyntheticSection(SHF_ALLOC, Type, Config->Wordsize, Name),
       DynamicTag(DynamicTag), SizeDynamicTag(SizeDynamicTag) {}
 
+void RelocationBaseSection::addReloc(uint32_t DynType, InputSectionBase *IS,
+                                     uint64_t OffsetInSec, Symbol *Sym) {
+  addReloc({DynType, IS, OffsetInSec, false, Sym, 0});
+}
+
 void RelocationBaseSection::addReloc(uint32_t DynType,
                                      InputSectionBase *InputSec,
                                      uint64_t OffsetInSec, bool UseSymVA,

Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=325016&r1=325015&r2=325016&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Tue Feb 13 08:03:52 2018
@@ -361,6 +361,8 @@ class RelocationBaseSection : public Syn
 public:
   RelocationBaseSection(StringRef Name, uint32_t Type, int32_t DynamicTag,
                         int32_t SizeDynamicTag);
+  void addReloc(uint32_t DynType, InputSectionBase *IS, uint64_t OffsetInSec,
+                Symbol *Sym);
   void addReloc(uint32_t DynType, InputSectionBase *InputSec,
                 uint64_t OffsetInSec, bool UseSymVA, Symbol *Sym,
                 int64_t Addend, RelExpr Expr, RelType Type);




More information about the llvm-commits mailing list