diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index b856fe5d131f..5385d2e2292b 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -110,7 +110,7 @@ template void elf2::ObjectFile::initializeSymbols() { if (FirstNonLocal > NumSymbols) error("Invalid sh_info in symbol table"); Syms = llvm::make_range(Syms.begin() + FirstNonLocal, Syms.end()); - SymbolBodies.reserve(NumSymbols); + SymbolBodies.reserve(NumSymbols - FirstNonLocal); for (const Elf_Sym &Sym : Syms) SymbolBodies.push_back(createSymbolBody(StringTable, &Sym)); }