[PATCH] D44062: Don't warn if a symbol is assigned to the same version twice, but error if it is assigned to multiple

Rafael Avila de Espindola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 2 17:52:21 PST 2018


espindola created this revision.
espindola added reviewers: ruiu, davide.
Herald added subscribers: arichardson, emaste.

It looks like the problem described in

https://reviews.llvm.org/D21555

Is that we would error if a symbol was assigned to the same version twice. It looks like we can avoid the warning in that case and actually error if a symbol is placed in conflicting versions.

This fixes pr28342.


https://reviews.llvm.org/D44062

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


Index: test/ELF/version-script.s
===================================================================
--- test/ELF/version-script.s
+++ test/ELF/version-script.s
@@ -34,9 +34,9 @@
 
 # RUN: echo "VERSION_1.0 { global: foo1; local: *; };" > %t6.script
 # RUN: echo "VERSION_2.0 { global: foo1; local: *; };" >> %t6.script
-# RUN: ld.lld --version-script %t6.script -shared %t.o %t2.so -o %t6.so 2>&1 | \
-# RUN:   FileCheck -check-prefix=WARN2 %s
-# WARN2: duplicate symbol 'foo1' in version script
+# RUN: not ld.lld --version-script %t6.script -shared %t.o %t2.so -o %t6.so 2>&1 | \
+# RUN:   FileCheck -check-prefix=ERR3 %s
+# ERR3: duplicate symbol 'foo1' in version script
 
 # RUN: echo "{ foo1; foo2; };" > %t.list
 # RUN: ld.lld --version-script %t.script --dynamic-list %t.list %t.o %t2.so -o %t2
@@ -213,6 +213,9 @@
 # ALL-NEXT:  }
 # ALL-NEXT: ]
 
+# RUN: echo "VERSION_1.0 { global: foo1; foo1; local: *; };" > %t8.script
+# RUN: ld.lld --version-script %t8.script -shared %t.o -o %t8.so --fatal-warnings
+
 .globl foo1
 foo1:
   call bar at PLT
Index: ELF/SymbolTable.cpp
===================================================================
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -698,8 +698,8 @@
     if (Sym->getName().contains('@'))
       continue;
 
-    if (Sym->InVersionScript)
-      warn("duplicate symbol '" + Ver.Name + "' in version script");
+    if (Sym->InVersionScript && Sym->VersionId != VersionId)
+      error("duplicate symbol '" + Ver.Name + "' in version script");
     Sym->VersionId = VersionId;
     Sym->InVersionScript = true;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44062.136889.patch
Type: text/x-patch
Size: 1580 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180303/d754b086/attachment.bin>


More information about the llvm-commits mailing list