Skip to content

Commit 18538e2

Browse files
committed
Revert "[ELF] Optimize parseSymbolVersion"
This reverts commit 2b129da. parseSymbolVersion can be combined with computeIsPreemptible, making hasVersionSyms unneeded.
1 parent a00eab6 commit 18538e2

File tree

4 files changed

+5
-20
lines changed

4 files changed

+5
-20
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,6 @@ template <class ELFT> void ObjFile<ELFT>::postParse() {
12151215
Err(ctx) << "TLS attribute mismatch: " << &sym << "\n>>> in " << sym.file
12161216
<< "\n>>> in " << this;
12171217

1218-
hasVersionSyms |= sym.hasVersionSuffix;
12191218
// Handle non-COMMON defined symbol below. !sym.file allows a symbol
12201219
// assignment to redefine a symbol without an error.
12211220
if (!sym.isDefined() || secIdx == SHN_UNDEF)
@@ -1591,8 +1590,6 @@ template <class ELFT> void SharedFile::parse() {
15911590
s->dsoDefined = true;
15921591
if (s->file == this)
15931592
s->versionId = idx;
1594-
symbols[firstGlobal + i] = s;
1595-
hasVersionSyms = true;
15961593
}
15971594
}
15981595

lld/ELF/InputFiles.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ class ELFFileBase : public InputFile {
241241
StringRef sourceFile;
242242
uint32_t andFeatures = 0;
243243
bool hasCommonSyms = false;
244-
bool hasVersionSyms = false;
245244
ArrayRef<uint8_t> aarch64PauthAbiCoreInfo;
246245
};
247246

lld/ELF/SymbolTable.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -353,21 +353,9 @@ void SymbolTable::scanVersionScript() {
353353
// Symbol themselves might know their versions because symbols
354354
// can contain versions in the form of <name>@<version>.
355355
// Let them parse and update their names to exclude version suffix.
356-
for (ELFFileBase *file : ctx.objectFiles) {
357-
if (!file->hasVersionSyms)
358-
continue;
359-
for (Symbol *sym : file->getGlobalSymbols())
360-
if (sym->hasVersionSuffix)
361-
sym->parseSymbolVersion(ctx);
362-
}
363-
// Only used for undefined symbol suggestion.
364-
for (ELFFileBase *file : ctx.sharedFiles) {
365-
if (!file->hasVersionSyms)
366-
continue;
367-
for (Symbol *sym : file->getGlobalSymbols())
368-
if (sym && sym->hasVersionSuffix)
369-
sym->parseSymbolVersion(ctx);
370-
}
356+
for (Symbol *sym : symVector)
357+
if (sym->hasVersionSuffix)
358+
sym->parseSymbolVersion(ctx);
371359

372360
// isPreemptible is false at this point. To correctly compute the binding of a
373361
// Defined (which is used by includeInDynsym(ctx)), we need to know if it is

lld/test/ELF/symver.s

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@
139139

140140
# W3: error: undefined symbol: __wrap_foo@v1
141141
# W3-NEXT: >>> referenced by {{.*}}ref1.o:(.text+0x1)
142-
# W3-NOT: {{.}}
142+
# W3-NEXT: >>> did you mean: __wrap_foo{{$}}
143+
# W3-NEXT: >>> defined in: {{.*}}wrap.o
143144

144145
## foo@v1 is correctly wrapped.
145146
# 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

0 commit comments

Comments
 (0)