[lld] 132553b - [ELF] --exclude-libs: skip local symbols for ET_REL. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 15 17:03:02 PST 2022
Author: Fangrui Song
Date: 2022-02-15T17:02:56-08:00
New Revision: 132553b8c7afcacdc6928e71d77b904ce653c463
URL: https://github.com/llvm/llvm-project/commit/132553b8c7afcacdc6928e71d77b904ce653c463
DIFF: https://github.com/llvm/llvm-project/commit/132553b8c7afcacdc6928e71d77b904ce653c463.diff
LOG: [ELF] --exclude-libs: skip local symbols for ET_REL. NFC
Beside the optimization, this will avoid accessing nullptr entries with my
planned change to parallelize initializeLocalSymbols.
Added:
Modified:
lld/ELF/Driver.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index cb8e6d60b0290..4f5f58dadbd06 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<Symbol *> symbols = file->getSymbols();
+ if (isa<ELFFileBase>(file))
+ symbols = cast<ELFFileBase>(file)->getGlobalSymbols();
+ for (Symbol *sym : symbols)
+ if (!sym->isUndefined() && sym->file == file)
+ sym->versionId = VER_NDX_LOCAL;
};
for (ELFFileBase *file : objectFiles)
More information about the llvm-commits
mailing list