aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2017-07-18 00:33:14 +0000
committerRui Ueyama <ruiu@google.com>2017-07-18 00:33:14 +0000
commite4d7d7f16b9f39ef8e27868dc96984deffc98ff6 (patch)
treeae6cd52be45e05e632e21f557292bf032557b226
parent87bf93202828f2d7dcc315d7eaba78e429e81134 (diff)
Revert r307364: [ELF] - Handle symbols with default version early.
This reverts commit r307364 because that change is likely to have caused https://bugs.llvm.org/show_bug.cgi?id=33820. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@308239 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--ELF/SymbolTable.cpp31
-rw-r--r--test/ELF/Inputs/symver-archive1.s6
-rw-r--r--test/ELF/Inputs/symver-archive2.s1
-rw-r--r--test/ELF/symver-archive.s15
4 files changed, 23 insertions, 30 deletions
diff --git a/ELF/SymbolTable.cpp b/ELF/SymbolTable.cpp
index c802d74b8..bf5498c02 100644
--- a/ELF/SymbolTable.cpp
+++ b/ELF/SymbolTable.cpp
@@ -211,13 +211,6 @@ static uint8_t getMinVisibility(uint8_t VA, uint8_t VB) {
// Find an existing symbol or create and insert a new one.
template <class ELFT>
std::pair<Symbol *, bool> SymbolTable<ELFT>::insert(StringRef Name) {
- // <name>@@<version> means the symbol is the default version. In that
- // case symbol <name> must exist and <name>@@<version> will be used to
- // resolve references to <name>.
- size_t Pos = Name.find("@@");
- if (Pos != StringRef::npos)
- Name = Name.take_front(Pos);
-
auto P = Symtab.insert(
{CachedHashStringRef(Name), SymIndex((int)SymVector.size(), false)});
SymIndex &V = P.first->second;
@@ -724,13 +717,35 @@ void SymbolTable<ELFT>::assignWildcardVersion(SymbolVersion Ver,
B->symbol()->VersionId = VersionId;
}
+static bool isDefaultVersion(SymbolBody *B) {
+ return B->isInCurrentDSO() && B->getName().find("@@") != StringRef::npos;
+}
+
// This function processes version scripts by updating VersionId
// member of symbols.
template <class ELFT> void SymbolTable<ELFT>::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 (Symbol *Sym : SymVector) {
+ SymbolBody *Body = Sym->body();
+ bool IsDefault = isDefaultVersion(Body);
+ Body->parseSymbolVersion();
+
+ if (!IsDefault)
+ continue;
+
+ // <name>@@<version> means the symbol is the default version. If that's the
+ // case, the symbol is not used only to resolve <name> of version <version>
+ // but also undefined unversioned symbols with name <name>.
+ SymbolBody *S = find(Body->getName());
+ if (S && S->isUndefined())
+ S->copy(Body);
+ }
+
// Handle edge cases first.
handleAnonymousVersion();
-
// Now we have version definitions, so we need to set version ids to symbols.
// Each version definition has a glob pattern, and all symbols that match
// with the pattern get that version.
diff --git a/test/ELF/Inputs/symver-archive1.s b/test/ELF/Inputs/symver-archive1.s
deleted file mode 100644
index be7c64494..000000000
--- a/test/ELF/Inputs/symver-archive1.s
+++ /dev/null
@@ -1,6 +0,0 @@
-.text
-.globl x
-.type x, @function
-x:
-
-.symver x, xx@@VER
diff --git a/test/ELF/Inputs/symver-archive2.s b/test/ELF/Inputs/symver-archive2.s
deleted file mode 100644
index a9b9d0b0a..000000000
--- a/test/ELF/Inputs/symver-archive2.s
+++ /dev/null
@@ -1 +0,0 @@
-call xx@PLT
diff --git a/test/ELF/symver-archive.s b/test/ELF/symver-archive.s
deleted file mode 100644
index be50503a3..000000000
--- a/test/ELF/symver-archive.s
+++ /dev/null
@@ -1,15 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1
-# RUN: rm -f %t.a
-# RUN: llvm-ar rcs %t.a %t1
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/symver-archive1.s -o %t2.o
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/symver-archive2.s -o %t3.o
-# RUN: ld.lld -o %t.out %t2.o %t3.o %t.a
-
-.text
-.globl x
-.type x, @function
-x:
-
-.globl xx
-xx = x