[PATCH] D35059: [ELF] - Handle symbols with default version early.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 7 01:30:25 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307364: [ELF] - Handle symbols with default version early. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D35059?vs=105433&id=105596#toc
Repository:
rL LLVM
https://reviews.llvm.org/D35059
Files:
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/test/ELF/Inputs/symver-archive1.s
lld/trunk/test/ELF/Inputs/symver-archive2.s
lld/trunk/test/ELF/symver-archive.s
Index: lld/trunk/test/ELF/Inputs/symver-archive2.s
===================================================================
--- lld/trunk/test/ELF/Inputs/symver-archive2.s
+++ lld/trunk/test/ELF/Inputs/symver-archive2.s
@@ -0,0 +1 @@
+call xx at PLT
Index: lld/trunk/test/ELF/Inputs/symver-archive1.s
===================================================================
--- lld/trunk/test/ELF/Inputs/symver-archive1.s
+++ lld/trunk/test/ELF/Inputs/symver-archive1.s
@@ -0,0 +1,6 @@
+.text
+.globl x
+.type x, @function
+x:
+
+.symver x, xx@@VER
Index: lld/trunk/test/ELF/symver-archive.s
===================================================================
--- lld/trunk/test/ELF/symver-archive.s
+++ lld/trunk/test/ELF/symver-archive.s
@@ -0,0 +1,15 @@
+# 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
Index: lld/trunk/ELF/SymbolTable.cpp
===================================================================
--- lld/trunk/ELF/SymbolTable.cpp
+++ lld/trunk/ELF/SymbolTable.cpp
@@ -211,6 +211,13 @@
// 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;
@@ -712,31 +719,14 @@
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);
- }
+ for (Symbol *Sym : SymVector)
+ Sym->body()->parseSymbolVersion();
// Handle edge cases first.
handleAnonymousVersion();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35059.105596.patch
Type: text/x-patch
Size: 3142 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170707/c6826374/attachment.bin>
More information about the llvm-commits
mailing list