diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 006c7308c582..fc8b3b19f104 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -278,20 +278,19 @@ Defined *InputSectionBase::getEnclosingFunction(uint64_t offset) { } // Returns an object file location string. Used to construct an error message. -template std::string InputSectionBase::getLocation(uint64_t offset) { std::string secAndOffset = (name + "+0x" + Twine::utohexstr(offset) + ")").str(); // We don't have file for synthetic sections. - if (getFile() == nullptr) + if (file == nullptr) return (config->outputFile + ":(" + secAndOffset).str(); - std::string file = toString(getFile()); + std::string filename = toString(file); if (Defined *d = getEnclosingFunction(offset)) - return file + ":(function " + toString(*d) + ": " + secAndOffset; + return filename + ":(function " + toString(*d) + ": " + secAndOffset; - return file + ":(" + secAndOffset; + return filename + ":(" + secAndOffset; } // This function is intended to be used for constructing an error message. @@ -948,7 +947,7 @@ void InputSection::relocateNonAlloc(uint8_t *buf, ArrayRef rels) { continue; } - std::string msg = getLocation(offset) + ": has non-ABS relocation " + + std::string msg = getLocation(offset) + ": has non-ABS relocation " + toString(type) + " against symbol '" + toString(sym) + "'"; if (expr != R_PC && expr != R_ARM_PCA) { @@ -1473,11 +1472,6 @@ template InputSection::InputSection(ObjFile &, const ELF64LE::Shdr &, template InputSection::InputSection(ObjFile &, const ELF64BE::Shdr &, StringRef); -template std::string InputSectionBase::getLocation(uint64_t); -template std::string InputSectionBase::getLocation(uint64_t); -template std::string InputSectionBase::getLocation(uint64_t); -template std::string InputSectionBase::getLocation(uint64_t); - template void InputSection::writeTo(uint8_t *); template void InputSection::writeTo(uint8_t *); template void InputSection::writeTo(uint8_t *); diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index 87b748fdf99e..d7dea9d2587a 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -184,7 +184,7 @@ public: Defined *getEnclosingFunction(uint64_t offset); // Returns a source location string. Used to construct an error message. - template std::string getLocation(uint64_t offset); + std::string getLocation(uint64_t offset); std::string getSrcMsg(const Symbol &sym, uint64_t offset); std::string getObjMsg(uint64_t offset); diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 88d3006f9a2d..f0e7ebfc64df 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -107,7 +107,7 @@ template static ErrorPlace getErrPlace(const uint8_t *loc) { continue; } if (isecLoc <= loc && loc < isecLoc + isec->getSize()) { - auto objLoc = isec->template getLocation(loc - isecLoc); + std::string objLoc = isec->getLocation(loc - isecLoc); // Return object file location and source file location. // TODO: Refactor getSrcMsg not to take a variable. Undefined dummy(nullptr, "", STB_LOCAL, 0, 0);