diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 1a1072ff5e6cf..ab4be24ff82b5 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -1049,7 +1049,9 @@ template void ObjFile::initializeSymbols() { ArrayRef eSyms = this->getELFSyms(); this->symbols.resize(eSyms.size()); SymbolUnion *locals = - getSpecificAllocSingleton().Allocate(firstGlobal); + firstGlobal == 0 + ? nullptr + : getSpecificAllocSingleton().Allocate(firstGlobal); for (size_t i = 0; i != firstGlobal; ++i) { const Elf_Sym &eSym = eSyms[i];