[lld] r325204 - Fix an issue that lld drops symbol versions for -r.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 14 18:40:58 PST 2018
Author: ruiu
Date: Wed Feb 14 18:40:58 2018
New Revision: 325204
URL: http://llvm.org/viewvc/llvm-project?rev=325204&view=rev
Log:
Fix an issue that lld drops symbol versions for -r.
When we are emitting a relocatable output, we should keep the original
symbol name including "@" part. Previously, we drop that part unconditionally
which resulted in dropping versions from symbols.
Differential Revision: https://reviews.llvm.org/D43307
Added:
lld/trunk/test/ELF/relocatable-versioned.s
Modified:
lld/trunk/ELF/Driver.cpp
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=325204&r1=325203&r2=325204&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Wed Feb 14 18:40:58 2018
@@ -1104,7 +1104,12 @@ template <class ELFT> void LinkerDriver:
Script->declareSymbols();
// Apply version scripts.
- Symtab->scanVersionScript();
+ //
+ // For a relocatable output, version scripts don't make sense, and
+ // parsing a symbol version string (e.g. dropping "@ver1" from a symbol
+ // name "foo at ver1") rather do harm, so we don't call this if -r is given.
+ if (!Config->Relocatable)
+ Symtab->scanVersionScript();
// Create wrapped symbols for -wrap option.
for (auto *Arg : Args.filtered(OPT_wrap))
Added: lld/trunk/test/ELF/relocatable-versioned.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocatable-versioned.s?rev=325204&view=auto
==============================================================================
--- lld/trunk/test/ELF/relocatable-versioned.s (added)
+++ lld/trunk/test/ELF/relocatable-versioned.s Wed Feb 14 18:40:58 2018
@@ -0,0 +1,9 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
+# RUN: ld.lld -o %t2.o -r %t1.o
+# RUN: llvm-nm %t2.o | FileCheck %s
+# CHECK: foo at VERSION
+
+.global "foo at VERSION"
+"foo at VERSION":
+ ret
More information about the llvm-commits
mailing list