diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 4d2618666ee5..a2ef1cc87d3d 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -318,7 +318,7 @@ void elf::ObjectFile::initializeSections( this->Symtab = &Sec; break; case SHT_SYMTAB_SHNDX: - this->SymtabSHNDX = check(Obj.getSHNDXTable(Sec)); + this->SymtabSHNDX = check(Obj.getSHNDXTable(Sec, ObjSections)); break; case SHT_STRTAB: case SHT_NULL: @@ -575,7 +575,8 @@ template void SharedFile::parseSoName() { const Elf_Shdr *DynamicSec = nullptr; const ELFFile Obj = this->ELFObj; - for (const Elf_Shdr &Sec : check(Obj.sections())) { + ArrayRef Sections = check(Obj.sections()); + for (const Elf_Shdr &Sec : Sections) { switch (Sec.sh_type) { default: continue; @@ -586,7 +587,7 @@ template void SharedFile::parseSoName() { DynamicSec = &Sec; break; case SHT_SYMTAB_SHNDX: - this->SymtabSHNDX = check(Obj.getSHNDXTable(Sec)); + this->SymtabSHNDX = check(Obj.getSHNDXTable(Sec, Sections)); break; case SHT_GNU_versym: this->VersymSec = &Sec;