From d6b7a390d809b2b12cc7f9fe49f6930f0fccfe9f Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 27 Oct 2017 03:13:54 +0000 Subject: [PATCH] De-template elf::getObjMsg. NFC. llvm-svn: 316732 --- lld/ELF/EhFrame.cpp | 2 +- lld/ELF/InputSection.cpp | 10 ++-------- lld/ELF/InputSection.h | 2 +- lld/ELF/Relocations.cpp | 4 ++-- lld/ELF/SymbolTable.cpp | 4 ++-- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/lld/ELF/EhFrame.cpp b/lld/ELF/EhFrame.cpp index ed18f63..23ebd2b 100644 --- a/lld/ELF/EhFrame.cpp +++ b/lld/ELF/EhFrame.cpp @@ -45,7 +45,7 @@ public: private: template void failOn(const P *Loc, const Twine &Msg) { fatal("corrupted .eh_frame: " + Msg + "\n>>> defined in " + - IS->getObjMsg((const uint8_t *)Loc - IS->Data.data())); + IS->getObjMsg((const uint8_t *)Loc - IS->Data.data())); } uint8_t readByte(); diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index c870d8c..2a24b01 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -297,9 +297,8 @@ template std::string InputSectionBase::getSrcMsg(uint64_t Offset) { // or // // path/to/foo.o:(function bar) in archive path/to/bar.a -template std::string InputSectionBase::getObjMsg(uint64_t Off) { +std::string InputSectionBase::getObjMsg(uint64_t Off) { // Synthetic sections don't have input files. - ObjFile *File = getFile(); if (!File) return ("(internal):(" + Name + "+0x" + utohexstr(Off) + ")").str(); std::string Filename = File->getName(); @@ -309,7 +308,7 @@ template std::string InputSectionBase::getObjMsg(uint64_t Off) { Archive = (" in archive " + File->ArchiveName).str(); // Find a symbol that encloses a given location. - for (SymbolBody *B : getFile()->getSymbols()) + for (SymbolBody *B : File->getSymbols()) if (auto *D = dyn_cast(B)) if (D->Section == this && D->Value <= Off && Off < D->Value + D->Size) return Filename + ":(" + toString(*D) + ")" + Archive; @@ -988,11 +987,6 @@ template std::string InputSectionBase::getSrcMsg(uint64_t); template std::string InputSectionBase::getSrcMsg(uint64_t); template std::string InputSectionBase::getSrcMsg(uint64_t); -template std::string InputSectionBase::getObjMsg(uint64_t); -template std::string InputSectionBase::getObjMsg(uint64_t); -template std::string InputSectionBase::getObjMsg(uint64_t); -template std::string InputSectionBase::getObjMsg(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 fc7fa6c7..d863883 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -183,7 +183,7 @@ public: // Returns a source location string. Used to construct an error message. template std::string getLocation(uint64_t Offset); template std::string getSrcMsg(uint64_t Offset); - template std::string getObjMsg(uint64_t Offset); + std::string getObjMsg(uint64_t Offset); // Each section knows how to relocate itself. These functions apply // relocations, assuming that Buf points to this section's copy in diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 429d2fc..3d5d3e7 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -77,7 +77,7 @@ static std::string getLocation(InputSectionBase &S, const SymbolBody &Sym, std::string Src = S.getSrcMsg(Off); if (!Src.empty()) Msg += Src + "\n>>> "; - return Msg + S.getObjMsg(Off); + return Msg + S.getObjMsg(Off); } // This is a MIPS-specific rule. @@ -733,7 +733,7 @@ static bool maybeReportUndefined(SymbolBody &Sym, InputSectionBase &Sec, std::string Src = Sec.getSrcMsg(Offset); if (!Src.empty()) Msg += Src + "\n>>> "; - Msg += Sec.getObjMsg(Offset); + Msg += Sec.getObjMsg(Offset); if ((Config->UnresolvedSymbols == UnresolvedPolicy::Warn && CanBeExternal) || Config->NoinhibitExec) { diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 65220ff2..e0952f8 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -463,9 +463,9 @@ static void reportDuplicate(SymbolBody *Sym, InputSectionBase *ErrSec, // >>> baz.o in archive libbaz.a auto *Sec1 = cast(D->Section); std::string Src1 = Sec1->getSrcMsg(D->Value); - std::string Obj1 = Sec1->getObjMsg(D->Value); + std::string Obj1 = Sec1->getObjMsg(D->Value); std::string Src2 = ErrSec->getSrcMsg(ErrOffset); - std::string Obj2 = ErrSec->getObjMsg(ErrOffset); + std::string Obj2 = ErrSec->getObjMsg(ErrOffset); std::string Msg = "duplicate symbol: " + toString(*Sym) + "\n>>> defined at "; if (!Src1.empty()) -- 2.7.4