[lld] r313015 - [ELF] Rename variables and add comments to getISThunkSec [NFC]

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 02:17:39 PDT 2017


Author: psmith
Date: Tue Sep 12 02:17:39 2017
New Revision: 313015

URL: http://llvm.org/viewvc/llvm-project?rev=313015&view=rev
Log:
[ELF] Rename variables and add comments to getISThunkSec [NFC]

Replace OutputSection *Cmd to OutputSection *OS. The Commands vector was
moved to OutputSection but the names of the variables were not. This patch
changes the names to match.

Differential Revision: https://reviews.llvm.org/D37627


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

Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=313015&r1=313014&r2=313015&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Tue Sep 12 02:17:39 2017
@@ -1014,24 +1014,27 @@ static uint32_t findEndOfFirstNonExec(Ou
   return 0;
 }
 
-ThunkSection *ThunkCreator::getOSThunkSec(OutputSection *Cmd,
+ThunkSection *ThunkCreator::getOSThunkSec(OutputSection *OS,
                                           std::vector<InputSection *> *ISR) {
   if (CurTS == nullptr) {
-    uint32_t Off = findEndOfFirstNonExec(*Cmd);
-    CurTS = addThunkSection(Cmd, ISR, Off);
+    uint32_t Off = findEndOfFirstNonExec(*OS);
+    CurTS = addThunkSection(OS, ISR, Off);
   }
   return CurTS;
 }
 
-ThunkSection *ThunkCreator::getISThunkSec(InputSection *IS, OutputSection *OS) {
+// Add a Thunk that needs to be placed in a ThunkSection that immediately
+// precedes its Target.
+ThunkSection *ThunkCreator::getISThunkSec(InputSection *IS) {
   ThunkSection *TS = ThunkedSections.lookup(IS);
   if (TS)
     return TS;
 
-  // Find InputSectionRange within TOS that IS is in
-  OutputSection *C = IS->getParent();
+  // Find InputSectionRange within Target Output Section (TOS) that the
+  // InputSection (IS) that we need to precede is in.
+  OutputSection *TOS = IS->getParent();
   std::vector<InputSection *> *Range = nullptr;
-  for (BaseCommand *BC : C->Commands)
+  for (BaseCommand *BC : TOS->Commands)
     if (auto *ISD = dyn_cast<InputSectionDescription>(BC)) {
       InputSection *first = ISD->Sections.front();
       InputSection *last = ISD->Sections.back();
@@ -1041,15 +1044,15 @@ ThunkSection *ThunkCreator::getISThunkSe
         break;
       }
     }
-  TS = addThunkSection(C, Range, IS->OutSecOff);
+  TS = addThunkSection(TOS, Range, IS->OutSecOff);
   ThunkedSections[IS] = TS;
   return TS;
 }
 
-ThunkSection *ThunkCreator::addThunkSection(OutputSection *Cmd,
+ThunkSection *ThunkCreator::addThunkSection(OutputSection *OS,
                                             std::vector<InputSection *> *ISR,
                                             uint64_t Off) {
-  auto *TS = make<ThunkSection>(Cmd, Off);
+  auto *TS = make<ThunkSection>(OS, Off);
   ThunkSections[ISR].push_back(TS);
   return TS;
 }
@@ -1108,7 +1111,7 @@ bool ThunkCreator::createThunks(ArrayRef
   // We separate the creation of ThunkSections from the insertion of the
   // ThunkSections back into the OutputSection as ThunkSections are not always
   // inserted into the same OutputSection as the caller.
-  forEachExecInputSection(OutputSections, [&](OutputSection *Cmd,
+  forEachExecInputSection(OutputSections, [&](OutputSection *OS,
                                               std::vector<InputSection *> *ISR,
                                               InputSection *IS) {
     for (Relocation &Rel : IS->Relocations) {
@@ -1123,9 +1126,9 @@ bool ThunkCreator::createThunks(ArrayRef
         // Find or create a ThunkSection for the new Thunk
         ThunkSection *TS;
         if (auto *TIS = T->getTargetInputSection())
-          TS = getISThunkSec(TIS, Cmd);
+          TS = getISThunkSec(TIS);
         else
-          TS = getOSThunkSec(Cmd, ISR);
+          TS = getOSThunkSec(OS, ISR);
         TS->addThunk(T);
         Thunks[T->ThunkSym] = T;
       }

Modified: lld/trunk/ELF/Relocations.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.h?rev=313015&r1=313014&r2=313015&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.h (original)
+++ lld/trunk/ELF/Relocations.h Tue Sep 12 02:17:39 2017
@@ -134,16 +134,16 @@ public:
 
 private:
   void mergeThunks();
-  ThunkSection *getOSThunkSec(OutputSection *Cmd,
+  ThunkSection *getOSThunkSec(OutputSection *OS,
                               std::vector<InputSection *> *ISR);
-  ThunkSection *getISThunkSec(InputSection *IS, OutputSection *OS);
+  ThunkSection *getISThunkSec(InputSection *IS);
   void forEachExecInputSection(
       ArrayRef<OutputSection *> OutputSections,
       std::function<void(OutputSection *, std::vector<InputSection *> *,
                          InputSection *)>
           Fn);
   std::pair<Thunk *, bool> getThunk(SymbolBody &Body, uint32_t Type);
-  ThunkSection *addThunkSection(OutputSection *Cmd,
+  ThunkSection *addThunkSection(OutputSection *OS,
                                 std::vector<InputSection *> *, uint64_t Off);
   // Record all the available Thunks for a Symbol
   llvm::DenseMap<SymbolBody *, std::vector<Thunk *>> ThunkedSymbols;




More information about the llvm-commits mailing list