Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -228,11 +228,12 @@ template void elf::ObjectFile::initializeSections( DenseSet &ComdatGroups) { - uint64_t Size = this->ELFObj.getNumSections(); - Sections.resize(Size); - unsigned I = -1; const ELFFile &Obj = this->ELFObj; - for (const Elf_Shdr &Sec : Obj.sections()) { + typename ELFT::ShdrRange R = Obj.sections(); + + Sections.resize(R.size()); + unsigned I = -1; + for (const Elf_Shdr &Sec : R) { ++I; if (Sections[I] == &InputSection::Discarded) continue; @@ -251,7 +252,7 @@ if (ComdatGroups.insert(getShtGroupSignature(Sec)).second) continue; for (uint32_t SecIndex : getShtGroupEntries(Sec)) { - if (SecIndex >= Size) + if (SecIndex >= R.size()) fatal(getFilename(this) + ": invalid section index in group: " + Twine(SecIndex)); Sections[SecIndex] = &InputSection::Discarded;