diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 8d04025888ed..5519d1617b6f 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -1813,12 +1813,13 @@ static GdbIndexChunk readDwarf(DWARFContext &Dwarf, InputSection *Sec) { } template GdbIndexSection *elf::createGdbIndex() { - std::vector Chunks; - for (InputSection *Sec : getDebugInfoSections()) { - ObjFile *F = Sec->getFile(); + std::vector Sections = getDebugInfoSections(); + std::vector Chunks(Sections.size()); + parallelForEachN(0, Chunks.size(), [&](size_t I) { + ObjFile *F = Sections[I]->getFile(); DWARFContext Dwarf(make_unique>(F)); - Chunks.push_back(readDwarf(Dwarf, Sec)); - } + Chunks[I] = readDwarf(Dwarf, Sections[I]); + }); return make(std::move(Chunks)); }