Print member name in undefined symbol error.

llvm-svn: 268976
This commit is contained in:
Rafael Espindola 2016-05-09 21:40:06 +00:00
parent 58919cc6f8
commit 78db5a9dca
6 changed files with 24 additions and 14 deletions

View File

@ -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;

View File

@ -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;

View File

@ -45,15 +45,6 @@ template <class ELFT> static bool isCompatible(InputFile *FileP) {
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) {

View File

@ -799,7 +799,7 @@ static void reportUndefined(SymbolTable<ELFT> &Symtab, SymbolBody *Sym) {
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

View File

@ -0,0 +1,3 @@
.global zed1
zed1:
.quad zed2

View File

@ -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