[lld] eda973b - [ELF][test] Add a test about --exclude-libs applying to version symbols

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 22 18:47:03 PST 2021


Author: Fangrui Song
Date: 2021-01-22T18:46:56-08:00
New Revision: eda973bbc7ae5327ee8451ba798dec63c550843e

URL: https://github.com/llvm/llvm-project/commit/eda973bbc7ae5327ee8451ba798dec63c550843e
DIFF: https://github.com/llvm/llvm-project/commit/eda973bbc7ae5327ee8451ba798dec63c550843e.diff

LOG: [ELF][test] Add a test about --exclude-libs applying to version symbols

D94280 also fixed PR48702.

Added: 
    lld/test/ELF/exclude-libs-versym.s

Modified: 
    lld/ELF/Driver.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index e0ef61d39ac1..3b2a8ba19293 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -2192,7 +2192,8 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
   compileBitcodeFiles<ELFT>();
 
   // Handle --exclude-libs again because lto.tmp may reference additional
-  // libcalls symbols defined in an excluded archive.
+  // libcalls symbols defined in an excluded archive. This may override
+  // versionId set by scanVersionScript().
   if (args.hasArg(OPT_exclude_libs))
     excludeLibs(args);
 

diff  --git a/lld/test/ELF/exclude-libs-versym.s b/lld/test/ELF/exclude-libs-versym.s
new file mode 100644
index 000000000000..1c0bd0af0d64
--- /dev/null
+++ b/lld/test/ELF/exclude-libs-versym.s
@@ -0,0 +1,32 @@
+# REQUIRES: x86
+## --exclude-libs can hide version symbols.
+
+# RUN: rm -rf %t && split-file %s %t
+# RUN: llvm-mc -filetype=obj %t/a.s -o %t/a.o
+# RUN: llvm-mc -filetype=obj %t/b.s -o %t/b.o
+# RUN: llvm-ar rc %t/b.a %t/b.o
+# RUN: ld.lld -shared %t/a.o %t/b.a --version-script=%t/ver -o %t.so
+# RUN: llvm-readelf --dyn-syms %t.so | FileCheck %s
+# RUN: ld.lld -shared %t/a.o %t/b.a --exclude-libs=b.a --version-script=%t/ver -o %t.so
+# RUN: llvm-readelf --dyn-syms %t.so | FileCheck %s --check-prefix=NO
+
+# CHECK: foo@@v2
+# CHECK: bar at v1
+# NO-NOT: foo@@v2
+# NO-NOT: bar at v1
+
+#--- a.s
+.globl _start
+_start:
+  call foo
+
+#--- b.s
+.symver bar_v1, bar at v1
+.globl foo, bar_v1
+foo:
+bar_v1:
+  ret
+
+#--- ver
+v1 {};
+v2 { foo; };


        


More information about the llvm-commits mailing list