[PATCH] D21555: [ELF] - Do not allow mix global symbols version.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 22 02:17:35 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL273396: [ELF] - Do not allow to mix global symbols versions. (authored by grimar).

Changed prior to commit:
  http://reviews.llvm.org/D21555?vs=61362&id=61521#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21555

Files:
  lld/trunk/ELF/SymbolTable.cpp
  lld/trunk/test/ELF/version-script.s

Index: lld/trunk/test/ELF/version-script.s
===================================================================
--- lld/trunk/test/ELF/version-script.s
+++ lld/trunk/test/ELF/version-script.s
@@ -47,6 +47,16 @@
 # RUN: not ld.lld --version-script %t5.script -shared %t.o %t2.so -o %t5.so 2>&1 | \
 # RUN:   FileCheck -check-prefix=ERR %s
 
+# RUN: echo "VERSION_1.0{     \
+# RUN:          global: foo1; \
+# RUN:          local: *; };  \
+# RUN:       VERSION_2.0 {    \
+# RUN:          global: foo1; \
+# RUN:          local: *; }; " > %t6.script
+# RUN: not ld.lld --version-script %t6.script -shared %t.o %t2.so -o %t6.so 2>&1 | \
+# RUN:   FileCheck -check-prefix=ERR2 %s
+# ERR2: duplicate symbol foo1 in version script
+
 # RUN: ld.lld --version-script %t.script --dynamic-list %t.list %t.o %t2.so -o %t2
 # RUN: llvm-readobj %t2 > /dev/null
 
Index: lld/trunk/ELF/SymbolTable.cpp
===================================================================
--- lld/trunk/ELF/SymbolTable.cpp
+++ lld/trunk/ELF/SymbolTable.cpp
@@ -531,8 +531,12 @@
   size_t I = 2;
   for (Version &V : Config->SymbolVersions) {
     for (StringRef Name : V.Globals)
-      if (SymbolBody *B = find(Name))
+      if (SymbolBody *B = find(Name)) {
+        if (B->symbol()->VersionId != VER_NDX_GLOBAL &&
+            B->symbol()->VersionId != VER_NDX_LOCAL)
+          error("duplicate symbol " + Name + " in version script");
         B->symbol()->VersionId = I;
+      }
     ++I;
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21555.61521.patch
Type: text/x-patch
Size: 1471 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160622/7dfe8ddb/attachment.bin>


More information about the llvm-commits mailing list