Revert "[ELF] Optimize parseSymbolVersion"

This reverts commit 2b129dacdde667137b5012d52f1d96e0ab26c749.

parseSymbolVersion can be combined with computeIsPreemptible,
making hasVersionSyms unneeded.
This commit is contained in:
Fangrui Song 2024-12-08 17:17:51 -08:00
parent a00eab6a48
commit 18538e2134
4 changed files with 5 additions and 20 deletions

View File

@ -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;
}
}

View File

@ -241,7 +241,6 @@ public:
StringRef sourceFile;
uint32_t andFeatures = 0;
bool hasCommonSyms = false;
bool hasVersionSyms = false;
ArrayRef<uint8_t> aarch64PauthAbiCoreInfo;
};

View File

@ -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

View File

@ -139,7 +139,8 @@
# W3: error: undefined symbol: __wrap_foo@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@v1 is correctly wrapped.
# RUN: ld.lld -shared --soname=t --version-script=%t/ver --wrap=foo@v1 %t/ref.o %t/ref1.o %t/def1.o %t/wrap1.o -o %t.w4