diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index cb8e6d60b02905..4f5f58dadbd062 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -1668,11 +1668,15 @@ static void excludeLibs(opt::InputArgList &args) { bool all = libs.count("ALL"); auto visit = [&](InputFile *file) { - if (!file->archiveName.empty()) - if (all || libs.count(path::filename(file->archiveName))) - for (Symbol *sym : file->getSymbols()) - if (!sym->isUndefined() && !sym->isLocal() && sym->file == file) - sym->versionId = VER_NDX_LOCAL; + if (file->archiveName.empty() || + !(all || libs.count(path::filename(file->archiveName)))) + return; + ArrayRef symbols = file->getSymbols(); + if (isa(file)) + symbols = cast(file)->getGlobalSymbols(); + for (Symbol *sym : symbols) + if (!sym->isUndefined() && sym->file == file) + sym->versionId = VER_NDX_LOCAL; }; for (ELFFileBase *file : objectFiles)