[lld] r268060 - Fix producing undefined reference to __progname.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 09:23:32 PDT 2016


Author: rafael
Date: Fri Apr 29 11:23:31 2016
New Revision: 268060

URL: http://llvm.org/viewvc/llvm-project?rev=268060&view=rev
Log:
Fix producing undefined reference to __progname.

We were not producing them if the library had version info.

Added:
    lld/trunk/test/ELF/Inputs/progname-ver.so   (with props)
Modified:
    lld/trunk/ELF/InputFiles.cpp
    lld/trunk/test/ELF/progname.s

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=268060&r1=268059&r2=268060&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Fri Apr 29 11:23:31 2016
@@ -490,6 +490,12 @@ template <class ELFT> void SharedFile<EL
   uint32_t NumSymbols = std::distance(Syms.begin(), Syms.end());
   SymbolBodies.reserve(NumSymbols);
   for (const Elf_Sym &Sym : Syms) {
+    StringRef Name = check(Sym.getName(this->StringTable));
+    if (Sym.isUndefined()) {
+      Undefs.push_back(Name);
+      continue;
+    }
+
     unsigned VersymIndex = 0;
     if (Versym) {
       VersymIndex = Versym->vs_index;
@@ -498,11 +504,7 @@ template <class ELFT> void SharedFile<EL
       if (VersymIndex == 0 || (VersymIndex & VERSYM_HIDDEN))
         continue;
     }
-    StringRef Name = check(Sym.getName(this->StringTable));
-    if (Sym.isUndefined())
-      Undefs.push_back(Name);
-    else
-      SymbolBodies.emplace_back(this, Name, Sym, Verdefs[VersymIndex]);
+    SymbolBodies.emplace_back(this, Name, Sym, Verdefs[VersymIndex]);
   }
 }
 

Added: lld/trunk/test/ELF/Inputs/progname-ver.so
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/progname-ver.so?rev=268060&view=auto
==============================================================================
Binary files lld/trunk/test/ELF/Inputs/progname-ver.so (added) and lld/trunk/test/ELF/Inputs/progname-ver.so Fri Apr 29 11:23:31 2016 differ

Propchange: lld/trunk/test/ELF/Inputs/progname-ver.so
------------------------------------------------------------------------------
    svn:executable = *

Modified: lld/trunk/test/ELF/progname.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/progname.s?rev=268060&r1=268059&r2=268060&view=diff
==============================================================================
--- lld/trunk/test/ELF/progname.s (original)
+++ lld/trunk/test/ELF/progname.s Fri Apr 29 11:23:31 2016
@@ -5,6 +5,9 @@
 // RUN: ld.lld -o %t %t.o %t2.so
 // RUN: llvm-readobj -dyn-symbols %t | FileCheck %s
 
+// RUN: ld.lld -o %t %t.o %p/Inputs/progname-ver.so
+// RUN: llvm-readobj -dyn-symbols %t | FileCheck %s
+
 // CHECK:      Name:     __progname@
 // CHECK-NEXT: Value:    0x11000
 // CHECK-NEXT: Size:     0




More information about the llvm-commits mailing list