Index: ELF/Relocations.cpp =================================================================== --- ELF/Relocations.cpp +++ ELF/Relocations.cpp @@ -1023,15 +1023,18 @@ return CurTS; } +// Add a Thunk that needs to be placed in a ThunkSection that immediately +// precedes its Target. ThunkSection *ThunkCreator::getISThunkSec(InputSection *IS, OutputSection *OS) { 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 *Range = nullptr; - for (BaseCommand *BC : C->Commands) + for (BaseCommand *BC : TOS->Commands) if (auto *ISD = dyn_cast(BC)) { InputSection *first = ISD->Sections.front(); InputSection *last = ISD->Sections.back(); @@ -1041,7 +1044,7 @@ break; } } - TS = addThunkSection(C, Range, IS->OutSecOff); + TS = addThunkSection(TOS, Range, IS->OutSecOff); ThunkedSections[IS] = TS; return TS; }