Index: lld/trunk/ELF/Relocations.h =================================================================== --- lld/trunk/ELF/Relocations.h +++ lld/trunk/ELF/Relocations.h @@ -88,8 +88,7 @@ void createThunks(InputSectionBase &, const typename ELFT::Shdr &); template -std::string getLocation(SymbolBody *Sym, InputSectionBase &S, - typename ELFT::uint Offset); +std::string getLocation(InputSectionBase &S, typename ELFT::uint Offset); template static inline typename ELFT::uint getAddend(const typename ELFT::Rel &Rel) { Index: lld/trunk/ELF/Relocations.cpp =================================================================== --- lld/trunk/ELF/Relocations.cpp +++ lld/trunk/ELF/Relocations.cpp @@ -539,8 +539,7 @@ } template -std::string getLocation(SymbolBody *Sym, InputSectionBase &S, - typename ELFT::uint Offset) { +std::string getLocation(InputSectionBase &S, typename ELFT::uint Offset) { ObjectFile *File = S.getFile(); // First check if we can get desired values from debugging information. @@ -548,11 +547,12 @@ if (!LineInfo.empty()) return LineInfo; - // If don't have STT_FILE typed symbol in object file then - // use object file name. + // File->SourceFile contains STT_FILE symbol contents which is a + // filename. Compilers usually create STT_FILE symbols. If it's + // missing, we use an actual filename. std::string SrcFile = File->SourceFile; if (SrcFile.empty()) - SrcFile = Sym && Sym->File ? getFilename(Sym->File) : getFilename(File); + SrcFile = getFilename(File); // Find a symbol at a given location. DefinedRegular *Encl = getSymbolAt(&S, Offset); @@ -576,7 +576,7 @@ Config->UnresolvedSymbols != UnresolvedPolicy::NoUndef) return; - std::string Msg = getLocation(&Sym, S, Offset) + ": undefined symbol '" + + std::string Msg = getLocation(S, Offset) + ": undefined symbol '" + maybeDemangle(Sym.getName()) + "'"; if (Config->UnresolvedSymbols == UnresolvedPolicy::Warn) @@ -854,17 +854,13 @@ template void createThunks(InputSectionBase &, const ELF64BE::Shdr &); -template std::string getLocation(SymbolBody *Sym, - InputSectionBase &S, +template std::string getLocation(InputSectionBase &S, uint32_t Offset); -template std::string getLocation(SymbolBody *Sym, - InputSectionBase &S, +template std::string getLocation(InputSectionBase &S, uint32_t Offset); -template std::string getLocation(SymbolBody *Sym, - InputSectionBase &S, +template std::string getLocation(InputSectionBase &S, uint64_t Offset); -template std::string getLocation(SymbolBody *Sym, - InputSectionBase &S, +template std::string getLocation(InputSectionBase &S, uint64_t Offset); } } Index: lld/trunk/ELF/SymbolTable.cpp =================================================================== --- lld/trunk/ELF/SymbolTable.cpp +++ lld/trunk/ELF/SymbolTable.cpp @@ -386,8 +386,8 @@ return; } - std::string OldLoc = getLocation(Existing, *D->Section, D->Value); - std::string NewLoc = getLocation(nullptr, *ErrSec, ErrOffset); + std::string OldLoc = getLocation(*D->Section, D->Value); + std::string NewLoc = getLocation(*ErrSec, ErrOffset); print(NewLoc + ": duplicate symbol '" + maybeDemangle(Existing->getName()) + "'");