diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index e416c8d84199..60169b51b80e 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -1004,7 +1004,7 @@ std::vector LinkerScript::createPhdrs() { break; // Assign headers specified by linker script - for (size_t Id : getPhdrIndices(Sec->Name)) { + for (size_t Id : getPhdrIndices(Sec)) { Ret[Id].add(Sec); if (Opt.PhdrsCommands[Id].Flags == UINT_MAX) Ret[Id].p_flags |= Sec->getPhdrFlags(); @@ -1084,13 +1084,12 @@ ExprValue LinkerScript::getSymbolValue(const Twine &Loc, StringRef S) { bool LinkerScript::isDefined(StringRef S) { return findSymbol(S) != nullptr; } -// Returns indices of ELF headers containing specific section, identified -// by Name. Each index is a zero based number of ELF header listed within -// PHDRS {} script block. -std::vector LinkerScript::getPhdrIndices(StringRef SectionName) { +// Returns indices of ELF headers containing specific section. Each index is a +// zero based number of ELF header listed within PHDRS {} script block. +std::vector LinkerScript::getPhdrIndices(OutputSection *Sec) { for (BaseCommand *Base : Opt.Commands) { auto *Cmd = dyn_cast(Base); - if (!Cmd || Cmd->Name != SectionName) + if (!Cmd || Cmd->Sec != Sec) continue; std::vector Ret; diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index 75783fc748c5..262f04d7d90e 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -222,7 +222,7 @@ protected: std::vector createInputSectionList(OutputSectionCommand &Cmd); - std::vector getPhdrIndices(StringRef SectionName); + std::vector getPhdrIndices(OutputSection *Sec); size_t getPhdrIndex(const Twine &Loc, StringRef PhdrName); MemoryRegion *findMemoryRegion(OutputSectionCommand *Cmd);