[lld] r268976 - Print member name in undefined symbol error.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon May 9 14:40:07 PDT 2016


Author: rafael
Date: Mon May  9 16:40:06 2016
New Revision: 268976

URL: http://llvm.org/viewvc/llvm-project?rev=268976&view=rev
Log:
Print member name in undefined symbol error.

Added:
    lld/trunk/test/ELF/Inputs/undef.s
Modified:
    lld/trunk/ELF/InputFiles.cpp
    lld/trunk/ELF/InputFiles.h
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/ELF/Writer.cpp
    lld/trunk/test/ELF/undef.s

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=268976&r1=268975&r2=268976&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Mon May  9 16:40:06 2016
@@ -27,6 +27,15 @@ using namespace llvm::sys::fs;
 using namespace lld;
 using namespace lld::elf;
 
+// Returns "(internal)", "foo.a(bar.o)" or "baz.o".
+std::string elf::getFilename(InputFile *F) {
+  if (!F)
+    return "(internal)";
+  if (!F->ArchiveName.empty())
+    return (F->ArchiveName + "(" + F->getName() + ")").str();
+  return F->getName();
+}
+
 template <class ELFT>
 static ELFFile<ELFT> createELFObj(MemoryBufferRef MB) {
   std::error_code EC;

Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=268976&r1=268975&r2=268976&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Mon May  9 16:40:06 2016
@@ -63,6 +63,9 @@ private:
   const Kind FileKind;
 };
 
+// Returns "(internal)", "foo.a(bar.o)" or "baz.o".
+std::string getFilename(InputFile *F);
+
 template <typename ELFT> class ELFFileBase : public InputFile {
 public:
   typedef typename ELFT::Shdr Elf_Shdr;

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=268976&r1=268975&r2=268976&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Mon May  9 16:40:06 2016
@@ -45,15 +45,6 @@ template <class ELFT> static bool isComp
   return false;
 }
 
-// Returns "(internal)", "foo.a(bar.o)" or "baz.o".
-static std::string getFilename(InputFile *F) {
-  if (!F)
-    return "(internal)";
-  if (!F->ArchiveName.empty())
-    return (F->ArchiveName + "(" + F->getName() + ")").str();
-  return F->getName();
-}
-
 // Add symbols in File to the symbol table.
 template <class ELFT>
 void SymbolTable<ELFT>::addFile(std::unique_ptr<InputFile> File) {

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=268976&r1=268975&r2=268976&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon May  9 16:40:06 2016
@@ -799,7 +799,7 @@ static void reportUndefined(SymbolTable<
 
   std::string Msg = "undefined symbol: " + Sym->getName().str();
   if (InputFile *File = Sym->getSourceFile<ELFT>())
-    Msg += " in " + File->getName().str();
+    Msg += " in " + getFilename(File);
   if (Config->NoinhibitExec)
     warning(Msg);
   else

Added: lld/trunk/test/ELF/Inputs/undef.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/undef.s?rev=268976&view=auto
==============================================================================
--- lld/trunk/test/ELF/Inputs/undef.s (added)
+++ lld/trunk/test/ELF/Inputs/undef.s Mon May  9 16:40:06 2016
@@ -0,0 +1,3 @@
+        .global zed1
+zed1:
+        .quad zed2

Modified: lld/trunk/test/ELF/undef.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/undef.s?rev=268976&r1=268975&r2=268976&view=diff
==============================================================================
--- lld/trunk/test/ELF/undef.s (original)
+++ lld/trunk/test/ELF/undef.s Mon May  9 16:40:06 2016
@@ -1,11 +1,15 @@
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: not ld.lld %t -o %t2 2>&1 | FileCheck %s
-# RUN: not ld.lld -pie %t -o %t2 2>&1 | FileCheck %s
+# 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/undef.s -o %t2.o
+# RUN: llvm-ar rc %t2.a %t2.o
+# RUN: not ld.lld %t.o %t2.a -o %t.exe 2>&1 | FileCheck %s
+# RUN: not ld.lld -pie %t.o %t2.a -o %t.exe 2>&1 | FileCheck %s
 # CHECK: undefined symbol: bar in {{.*}}
 # CHECK: undefined symbol: foo in {{.*}}
-# REQUIRES: x86
+# CHECK: undefined symbol: zed2 in {{.*}}2.a({{.*}}.o)
 
   .globl _start
 _start:
   call foo
   call bar
+  call zed1




More information about the llvm-commits mailing list