diff options
| author | Rui Ueyama <ruiu@google.com> | 2016-02-02 08:22:41 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2016-02-02 08:22:41 +0000 |
| commit | 71c066d8cfd12a696454377c0592f3697ef207f3 (patch) | |
| tree | 3f609a8276736cdb7b39c5bba884b29f91713918 /lld/ELF/SymbolTable.cpp | |
| parent | 82b4288b1a32a781af50760ad12698b64da233e2 (diff) | |
| download | bcm5719-llvm-71c066d8cfd12a696454377c0592f3697ef207f3.tar.gz bcm5719-llvm-71c066d8cfd12a696454377c0592f3697ef207f3.zip | |
ELF: Include archive names in error messages.
If object files are drawn from archive files, the error message should
be something like "conflict symbols in foo.a(bar.o) and baz.o" instead
of "conflict symbols in bar.o and baz.o". This patch implements that.
llvm-svn: 259475
Diffstat (limited to 'lld/ELF/SymbolTable.cpp')
| -rw-r--r-- | lld/ELF/SymbolTable.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 1e1c8aad589..b5b902d3c5f 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -149,17 +149,23 @@ ELFFileBase<ELFT> *SymbolTable<ELFT>::findFile(SymbolBody *B) { return nullptr; } +// Returns "(internal)", "foo.a(bar.o)" or "baz.o". +template <class ELFT> static std::string getFilename(ELFFileBase<ELFT> *F) { + if (!F) + return "(internal)"; + if (!F->ArchiveName.empty()) + return (F->ArchiveName + "(" + F->getName() + ")").str(); + return F->getName(); +} + // Construct a string in the form of "Sym in File1 and File2". // Used to construct an error message. template <class ELFT> std::string SymbolTable<ELFT>::conflictMsg(SymbolBody *Old, SymbolBody *New) { - ELFFileBase<ELFT> *OldFile = findFile(Old); - ELFFileBase<ELFT> *NewFile = findFile(New); - + ELFFileBase<ELFT> *F1 = findFile(Old); + ELFFileBase<ELFT> *F2 = findFile(New); StringRef Sym = Old->getName(); - StringRef F1 = OldFile ? OldFile->getName() : "(internal)"; - StringRef F2 = NewFile ? NewFile->getName() : "(internal)"; - return (demangle(Sym) + " in " + F1 + " and " + F2).str(); + return demangle(Sym) + " in " + getFilename(F1) + " and " + getFilename(F2); } // This function resolves conflicts if there's an existing symbol with |

