diff options
| author | Rui Ueyama <ruiu@google.com> | 2016-11-08 20:30:19 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2016-11-08 20:30:19 +0000 |
| commit | edc183e4375ab9b5be5487035327ca14ab7c322b (patch) | |
| tree | 5bbb80960be987040747aa6160aa3d736400a4ac | |
| parent | 0811385d24a7b06151a834fe9ccadaa41a85fe6b (diff) | |
| download | bcm5719-llvm-edc183e4375ab9b5be5487035327ca14ab7c322b.tar.gz bcm5719-llvm-edc183e4375ab9b5be5487035327ca14ab7c322b.zip | |
Simplify getLocation() function.
All tests pass without the first parameter, so I guess we don't need it.
Differential Revision: https://reviews.llvm.org/D26411
llvm-svn: 286287
| -rw-r--r-- | lld/ELF/Relocations.cpp | 24 | ||||
| -rw-r--r-- | lld/ELF/Relocations.h | 3 | ||||
| -rw-r--r-- | lld/ELF/SymbolTable.cpp | 4 |
3 files changed, 13 insertions, 18 deletions
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 2df9e9827fb..8ac8f55f816 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -539,8 +539,7 @@ static DefinedRegular<ELFT> *getSymbolAt(InputSectionBase<ELFT> *S, } template <class ELFT> -std::string getLocation(SymbolBody *Sym, InputSectionBase<ELFT> &S, - typename ELFT::uint Offset) { +std::string getLocation(InputSectionBase<ELFT> &S, typename ELFT::uint Offset) { ObjectFile<ELFT> *File = S.getFile(); // First check if we can get desired values from debugging information. @@ -548,11 +547,12 @@ std::string getLocation(SymbolBody *Sym, InputSectionBase<ELFT> &S, 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<ELFT> *Encl = getSymbolAt(&S, Offset); @@ -576,7 +576,7 @@ static void reportUndefined(SymbolBody &Sym, InputSectionBase<ELFT> &S, 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<ELF64LE>(InputSectionBase<ELF64LE> &, template void createThunks<ELF64BE>(InputSectionBase<ELF64BE> &, const ELF64BE::Shdr &); -template std::string getLocation<ELF32LE>(SymbolBody *Sym, - InputSectionBase<ELF32LE> &S, +template std::string getLocation<ELF32LE>(InputSectionBase<ELF32LE> &S, uint32_t Offset); -template std::string getLocation<ELF32BE>(SymbolBody *Sym, - InputSectionBase<ELF32BE> &S, +template std::string getLocation<ELF32BE>(InputSectionBase<ELF32BE> &S, uint32_t Offset); -template std::string getLocation<ELF64LE>(SymbolBody *Sym, - InputSectionBase<ELF64LE> &S, +template std::string getLocation<ELF64LE>(InputSectionBase<ELF64LE> &S, uint64_t Offset); -template std::string getLocation<ELF64BE>(SymbolBody *Sym, - InputSectionBase<ELF64BE> &S, +template std::string getLocation<ELF64BE>(InputSectionBase<ELF64BE> &S, uint64_t Offset); } } diff --git a/lld/ELF/Relocations.h b/lld/ELF/Relocations.h index 27ac1522940..f4b771b8bda 100644 --- a/lld/ELF/Relocations.h +++ b/lld/ELF/Relocations.h @@ -88,8 +88,7 @@ template <class ELFT> void createThunks(InputSectionBase<ELFT> &, const typename ELFT::Shdr &); template <class ELFT> -std::string getLocation(SymbolBody *Sym, InputSectionBase<ELFT> &S, - typename ELFT::uint Offset); +std::string getLocation(InputSectionBase<ELFT> &S, typename ELFT::uint Offset); template <class ELFT> static inline typename ELFT::uint getAddend(const typename ELFT::Rel &Rel) { diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index e124d7b5513..38a29055aeb 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -386,8 +386,8 @@ static void reportDuplicate(SymbolBody *Existing, 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()) + "'"); |

