diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-07-14 22:26:16 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-07-14 22:26:16 +0000 |
commit | 693b9a47cad4857b2b82d79e6d7c645ed592f41b (patch) | |
tree | 84de5985df87eb7606af849f55276a7a26605ce4 | |
parent | 3187356fdcf6595b32e070a742d501e0462514d4 (diff) |
Avoid using OutputSections::Sections.
This code runs after clearOutputSections.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@308066 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | ELF/Relocations.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ELF/Relocations.cpp b/ELF/Relocations.cpp index d624d0f2a..59a6a2484 100644 --- a/ELF/Relocations.cpp +++ b/ELF/Relocations.cpp @@ -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; |