Skip to content

Commit

Permalink
Consistent use of <internal> when displaying internal symbol names
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D40510

llvm-svn: 319108
  • Loading branch information
sbc100 committed Nov 27, 2017
1 parent a08d65d commit e2ed092
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lld/COFF/InputFiles.cpp
Expand Up @@ -411,7 +411,7 @@ static StringRef getBasename(StringRef Path) {
// Returns a string in the format of "foo.obj" or "foo.obj(bar.lib)".
std::string lld::toString(coff::InputFile *File) {
if (!File)
return "(internal)";
return "<internal>";
if (File->ParentName.empty())
return File->getName().lower();

Expand Down
3 changes: 1 addition & 2 deletions lld/COFF/SymbolTable.cpp
Expand Up @@ -200,8 +200,7 @@ void SymbolTable::addLazy(ArchiveFile *F, const Archive::Symbol Sym) {

void SymbolTable::reportDuplicate(Symbol *Existing, InputFile *NewFile) {
error("duplicate symbol: " + toString(*Existing) + " in " +
toString(Existing->getFile()) + " and in " +
(NewFile ? toString(NewFile) : "(internal)"));
toString(Existing->getFile()) + " and in " + toString(NewFile));
}

Symbol *SymbolTable::addAbsolute(StringRef N, COFFSymbolRef Sym) {
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/InputFiles.h
Expand Up @@ -42,7 +42,7 @@ namespace elf {
class InputFile;
}

// Returns "(internal)", "foo.a(bar.o)" or "baz.o".
// Returns "<internal>", "foo.a(bar.o)" or "baz.o".
std::string toString(const elf::InputFile *F);

namespace elf {
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/InputSection.cpp
Expand Up @@ -308,7 +308,7 @@ std::string InputSectionBase::getSrcMsg(const Symbol &Sym, uint64_t Offset) {
std::string InputSectionBase::getObjMsg(uint64_t Off) {
// Synthetic sections don't have input files.
if (!File)
return ("(internal):(" + Name + "+0x" + utohexstr(Off) + ")").str();
return ("<internal>:(" + Name + "+0x" + utohexstr(Off) + ")").str();
std::string Filename = File->getName();

std::string Archive;
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/duplicated-synthetic-sym.s
Expand Up @@ -4,7 +4,7 @@
// RUN: not ld.lld %t.o --format binary duplicated-synthetic-sym.s -o %t.elf 2>&1 | FileCheck %s

// CHECK: duplicate symbol: _binary_duplicated_synthetic_sym_s_start
// CHECK: defined at (internal):(.data+0x0)
// CHECK: defined at <internal>:(.data+0x0)

.globl _binary_duplicated_synthetic_sym_s_start
_binary_duplicated_synthetic_sym_s_start:
Expand Down
11 changes: 4 additions & 7 deletions lld/wasm/SymbolTable.cpp
Expand Up @@ -73,7 +73,7 @@ std::pair<Symbol *, bool> SymbolTable::insert(StringRef Name) {
void SymbolTable::reportDuplicate(Symbol *Existing, InputFile *NewFile) {
error("duplicate symbol: " + toString(*Existing) + "\n>>> defined in " +
toString(Existing->getFile()) + "\n>>> defined in " +
(NewFile ? toString(NewFile) : "<internal>"));
toString(NewFile));
}

static void checkSymbolTypes(Symbol *Existing, InputFile *F,
Expand All @@ -86,13 +86,10 @@ static void checkSymbolTypes(Symbol *Existing, InputFile *F,
if (Existing->isFunction() == NewIsFunction)
return;

std::string Filename = "<builtin>";
if (Existing->getFile())
Filename = toString(Existing->getFile());
error("symbol type mismatch: " + New->Name + "\n>>> defined as " +
(Existing->isFunction() ? "Function" : "Global") + " in " + Filename +
"\n>>> defined as " + (NewIsFunction ? "Function" : "Global") + " in " +
F->getName());
(Existing->isFunction() ? "Function" : "Global") + " in " +
toString(Existing->getFile()) + "\n>>> defined as " +
(NewIsFunction ? "Function" : "Global") + " in " + F->getName());
}

Symbol *SymbolTable::addDefinedGlobal(StringRef Name) {
Expand Down

0 comments on commit e2ed092

Please sign in to comment.