diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 4b7b8f93a1f6..55c46b600c4e 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -1775,21 +1775,18 @@ template void ObjFile::parseLazy() { const ArrayRef eSyms = this->getELFSyms(); numSymbols = eSyms.size(); symbols = std::make_unique(numSymbols); - for (size_t i = firstGlobal, end = eSyms.size(); i != end; ++i) - if (eSyms[i].st_shndx != SHN_UNDEF) - symbols[i] = symtab.insert(CHECK(eSyms[i].getName(stringTable), this)); - // Replace existing symbols with LazyObject symbols. - // // resolve() may trigger this->extract() if an existing symbol is an undefined // symbol. If that happens, this function has served its purpose, and we can // exit from the loop early. - for (Symbol *sym : getGlobalSymbols()) - if (sym) { - sym->resolve(LazyObject{*this}); - if (!lazy) - return; - } + for (size_t i = firstGlobal, end = eSyms.size(); i != end; ++i) { + if (eSyms[i].st_shndx == SHN_UNDEF) + continue; + symbols[i] = symtab.insert(CHECK(eSyms[i].getName(stringTable), this)); + symbols[i]->resolve(LazyObject{*this}); + if (!lazy) + break; + } } bool InputFile::shouldExtractForCommon(StringRef name) {