[lld] 18538e2 - Revert "[ELF] Optimize parseSymbolVersion"
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 8 17:50:21 PST 2024
Author: Fangrui Song
Date: 2024-12-08T17:50:16-08:00
New Revision: 18538e213498281653fca5baefa2dec4ae51bf91
URL: https://github.com/llvm/llvm-project/commit/18538e213498281653fca5baefa2dec4ae51bf91
DIFF: https://github.com/llvm/llvm-project/commit/18538e213498281653fca5baefa2dec4ae51bf91.diff
LOG: Revert "[ELF] Optimize parseSymbolVersion"
This reverts commit 2b129dacdde667137b5012d52f1d96e0ab26c749.
parseSymbolVersion can be combined with computeIsPreemptible,
making hasVersionSyms unneeded.
Added:
Modified:
lld/ELF/InputFiles.cpp
lld/ELF/InputFiles.h
lld/ELF/SymbolTable.cpp
lld/test/ELF/symver.s
Removed:
################################################################################
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 0714c8ce6c16bc..2084fcfd4d651a 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -1215,7 +1215,6 @@ template <class ELFT> void ObjFile<ELFT>::postParse() {
Err(ctx) << "TLS attribute mismatch: " << &sym << "\n>>> in " << sym.file
<< "\n>>> in " << this;
- hasVersionSyms |= sym.hasVersionSuffix;
// Handle non-COMMON defined symbol below. !sym.file allows a symbol
// assignment to redefine a symbol without an error.
if (!sym.isDefined() || secIdx == SHN_UNDEF)
@@ -1591,8 +1590,6 @@ template <class ELFT> void SharedFile::parse() {
s->dsoDefined = true;
if (s->file == this)
s->versionId = idx;
- symbols[firstGlobal + i] = s;
- hasVersionSyms = true;
}
}
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index b00e7a4286991c..0b186db1ba0d1d 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -241,7 +241,6 @@ class ELFFileBase : public InputFile {
StringRef sourceFile;
uint32_t andFeatures = 0;
bool hasCommonSyms = false;
- bool hasVersionSyms = false;
ArrayRef<uint8_t> aarch64PauthAbiCoreInfo;
};
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index 758ca882740e8d..648da94989d7a4 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -353,21 +353,9 @@ void SymbolTable::scanVersionScript() {
// Symbol themselves might know their versions because symbols
// can contain versions in the form of <name>@<version>.
// Let them parse and update their names to exclude version suffix.
- for (ELFFileBase *file : ctx.objectFiles) {
- if (!file->hasVersionSyms)
- continue;
- for (Symbol *sym : file->getGlobalSymbols())
- if (sym->hasVersionSuffix)
- sym->parseSymbolVersion(ctx);
- }
- // Only used for undefined symbol suggestion.
- for (ELFFileBase *file : ctx.sharedFiles) {
- if (!file->hasVersionSyms)
- continue;
- for (Symbol *sym : file->getGlobalSymbols())
- if (sym && sym->hasVersionSuffix)
- sym->parseSymbolVersion(ctx);
- }
+ for (Symbol *sym : symVector)
+ if (sym->hasVersionSuffix)
+ sym->parseSymbolVersion(ctx);
// isPreemptible is false at this point. To correctly compute the binding of a
// Defined (which is used by includeInDynsym(ctx)), we need to know if it is
diff --git a/lld/test/ELF/symver.s b/lld/test/ELF/symver.s
index 526fd2f2915948..d05fcc2a55d362 100644
--- a/lld/test/ELF/symver.s
+++ b/lld/test/ELF/symver.s
@@ -139,7 +139,8 @@
# W3: error: undefined symbol: __wrap_foo at v1
# W3-NEXT: >>> referenced by {{.*}}ref1.o:(.text+0x1)
-# W3-NOT: {{.}}
+# W3-NEXT: >>> did you mean: __wrap_foo{{$}}
+# W3-NEXT: >>> defined in: {{.*}}wrap.o
## foo at v1 is correctly wrapped.
# RUN: ld.lld -shared --soname=t --version-script=%t/ver --wrap=foo at v1 %t/ref.o %t/ref1.o %t/def1.o %t/wrap1.o -o %t.w4
More information about the llvm-commits
mailing list