Avoid using OutputSections::Sections.

This code runs after clearOutputSections.

llvm-svn: 308066
This commit is contained in:
Rafael Espindola 2017-07-14 22:26:16 +00:00
parent 23497b4758
commit 3eb2bb1a28
1 changed files with 10 additions and 6 deletions

View File

@ -1000,15 +1000,19 @@ void ThunkCreator::mergeThunks() {
}
}
static uint32_t findEndOfFirstNonExec(OutputSectionCommand &Cmd) {
for (BaseCommand *Base : Cmd.Commands)
if (auto *ISD = dyn_cast<InputSectionDescription>(Base))
for (auto *IS : ISD->Sections)
if ((IS->Flags & SHF_EXECINSTR) == 0)
return IS->OutSecOff + IS->getSize();
return 0;
}
ThunkSection *ThunkCreator::getOSThunkSec(OutputSectionCommand *Cmd,
std::vector<InputSection *> *ISR) {
if (CurTS == nullptr) {
uint32_t Off = 0;
for (auto *IS : Cmd->Sec->Sections) {
Off = IS->OutSecOff + IS->getSize();
if ((IS->Flags & SHF_EXECINSTR) == 0)
break;
}
uint32_t Off = findEndOfFirstNonExec(*Cmd);
CurTS = addThunkSection(Cmd->Sec, ISR, Off);
}
return CurTS;