summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Relocations.cpp24
-rw-r--r--lld/ELF/Relocations.h3
-rw-r--r--lld/ELF/SymbolTable.cpp4
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()) +
"'");
OpenPOWER on IntegriCloud