[PATCH] D43307: Fix an issue that lld drops symbol versions for -r.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 18:44:13 PST 2018


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325204: Fix an issue that lld drops symbol versions for -r. (authored by ruiu, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43307?vs=134274&id=134357#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43307

Files:
  lld/trunk/ELF/Driver.cpp
  lld/trunk/test/ELF/relocatable-versioned.s


Index: lld/trunk/test/ELF/relocatable-versioned.s
===================================================================
--- lld/trunk/test/ELF/relocatable-versioned.s
+++ lld/trunk/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 at VERSION
+
+.global "foo at VERSION"
+"foo at VERSION":
+  ret
Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/ELF/Driver.cpp
@@ -1104,7 +1104,12 @@
   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))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43307.134357.patch
Type: text/x-patch
Size: 1114 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180215/a4406ec3/attachment-0001.bin>


More information about the llvm-commits mailing list