[lld] r289284 - Fix a bogus warning.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 9 14:40:50 PST 2016


Author: rafael
Date: Fri Dec  9 16:40:49 2016
New Revision: 289284

URL: http://llvm.org/viewvc/llvm-project?rev=289284&view=rev
Log:
Fix a bogus warning.

We first decide that the symbol is global, than that it should have
version foo. Since it was already not the default version, we were
producing a bogus warning.

Added:
    lld/trunk/test/ELF/version-script-no-warn.s
Modified:
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/ELF/Symbols.h

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=289284&r1=289283&r2=289284&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Fri Dec  9 16:40:49 2016
@@ -192,6 +192,7 @@ std::pair<Symbol *, bool> SymbolTable<EL
   Symbol *Sym;
   if (IsNew) {
     Sym = new (BAlloc) Symbol;
+    Sym->InVersionScript = false;
     Sym->Binding = STB_WEAK;
     Sym->Visibility = STV_DEFAULT;
     Sym->IsUsedInRegularObj = false;
@@ -643,9 +644,11 @@ void SymbolTable<ELFT>::assignExactVersi
       continue;
     }
 
-    if (B->symbol()->VersionId != Config->DefaultSymbolVersion)
+    Symbol *Sym = B->symbol();
+    if (Sym->InVersionScript)
       warn("duplicate symbol '" + Ver.Name + "' in version script");
-    B->symbol()->VersionId = VersionId;
+    Sym->VersionId = VersionId;
+    Sym->InVersionScript = true;
   }
 }
 

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=289284&r1=289283&r2=289284&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Fri Dec  9 16:40:49 2016
@@ -405,6 +405,9 @@ struct Symbol {
   // True if this symbol is specified by --trace-symbol option.
   unsigned Traced : 1;
 
+  // This symbol version was found in a version script.
+  unsigned InVersionScript : 1;
+
   bool includeInDynsym() const;
   bool isWeak() const { return Binding == llvm::ELF::STB_WEAK; }
 

Added: lld/trunk/test/ELF/version-script-no-warn.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/version-script-no-warn.s?rev=289284&view=auto
==============================================================================
--- lld/trunk/test/ELF/version-script-no-warn.s (added)
+++ lld/trunk/test/ELF/version-script-no-warn.s Fri Dec  9 16:40:49 2016
@@ -0,0 +1,12 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/shared.s -o %t2.o
+# RUN: ld.lld -shared %t2.o -soname shared -o %t2.so
+
+# RUN: echo "foo { global: bar;  local: *; };" > %t.script
+# RUN: ld.lld --fatal-warnings --shared --version-script %t.script %t.o %t2.so
+
+.global bar
+bar:
+        nop




More information about the llvm-commits mailing list