[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

llvm-svn: 313015
This commit is contained in:
Peter Smith 2017-09-12 09:17:39 +00:00
parent 8f738ac6d4
commit 38029d3c89
2 changed files with 19 additions and 16 deletions

View File

@ -1014,24 +1014,27 @@ static uint32_t findEndOfFirstNonExec(OutputSection &Cmd) {
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::getISThunkSec(InputSection *IS, OutputSection *OS) {
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<OutputSection *> OutputSections) {
// 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<OutputSection *> OutputSections) {
// 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;
}

View File

@ -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;