From be97c91aca6c88132fcdc0a87002898d8cfe78ed Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Mon, 19 Feb 2018 14:20:30 +0000 Subject: Merging r325204: ------------------------------------------------------------------------ r325204 | ruiu | 2018-02-15 03:40:58 +0100 (Thu, 15 Feb 2018) | 7 lines 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 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/lld/branches/release_60@325502 91177308-0d34-0410-b5e6-96231b3b80d8 --- ELF/Driver.cpp | 7 ++++++- test/ELF/relocatable-versioned.s | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/ELF/relocatable-versioned.s diff --git a/ELF/Driver.cpp b/ELF/Driver.cpp index 6de8ed59e..3f7da67c2 100644 --- a/ELF/Driver.cpp +++ b/ELF/Driver.cpp @@ -1061,7 +1061,12 @@ template void LinkerDriver::link(opt::InputArgList &Args) { addReservedSymbols(); // 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@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)) diff --git a/test/ELF/relocatable-versioned.s b/test/ELF/relocatable-versioned.s new file mode 100644 index 000000000..2b6c49eb5 --- /dev/null +++ b/test/ELF/relocatable-versioned.s @@ -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@VERSION + +.global "foo@VERSION" +"foo@VERSION": + ret -- cgit v1.2.3