Skip to content

Commit 132553b

Browse files
committed
[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.
1 parent 43bc1e5 commit 132553b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lld/ELF/Driver.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,11 +1668,15 @@ static void excludeLibs(opt::InputArgList &args) {
16681668
bool all = libs.count("ALL");
16691669

16701670
auto visit = [&](InputFile *file) {
1671-
if (!file->archiveName.empty())
1672-
if (all || libs.count(path::filename(file->archiveName)))
1673-
for (Symbol *sym : file->getSymbols())
1674-
if (!sym->isUndefined() && !sym->isLocal() && sym->file == file)
1675-
sym->versionId = VER_NDX_LOCAL;
1671+
if (file->archiveName.empty() ||
1672+
!(all || libs.count(path::filename(file->archiveName))))
1673+
return;
1674+
ArrayRef<Symbol *> symbols = file->getSymbols();
1675+
if (isa<ELFFileBase>(file))
1676+
symbols = cast<ELFFileBase>(file)->getGlobalSymbols();
1677+
for (Symbol *sym : symbols)
1678+
if (!sym->isUndefined() && sym->file == file)
1679+
sym->versionId = VER_NDX_LOCAL;
16761680
};
16771681

16781682
for (ELFFileBase *file : objectFiles)

0 commit comments

Comments
 (0)