diff options
-rw-r--r-- | lld/ELF/Target.cpp | 29 | ||||
-rw-r--r-- | lld/ELF/Writer.cpp | 28 | ||||
-rw-r--r-- | lld/ELF/Writer.h | 1 |
3 files changed, 29 insertions, 29 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 9e292dc0b3d..d50bd4e76e5 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -29,6 +29,7 @@ #include "InputFiles.h" #include "Memory.h" #include "OutputSections.h" +#include "SymbolTable.h" #include "Symbols.h" #include "SyntheticSections.h" #include "Thunks.h" @@ -55,6 +56,34 @@ std::string toString(uint32_t Type) { return getELFRelocationTypeName(Config->EMachine, Type); } +template <class ELFT> static std::string getErrorLoc(uint8_t *Loc) { + for (InputSectionData *D : Symtab<ELFT>::X->Sections) { + auto *IS = dyn_cast_or_null<InputSection<ELFT>>(D); + if (!IS || !IS->OutSec) + continue; + + uint8_t *ISLoc = cast<OutputSection<ELFT>>(IS->OutSec)->Loc + IS->OutSecOff; + if (ISLoc <= Loc && Loc < ISLoc + IS->getSize()) + return IS->getLocation(Loc - ISLoc) + ": "; + } + return ""; +} + +static std::string getErrorLocation(uint8_t *Loc) { + switch (Config->EKind) { + case ELF32LEKind: + return getErrorLoc<ELF32LE>(Loc); + case ELF32BEKind: + return getErrorLoc<ELF32BE>(Loc); + case ELF64LEKind: + return getErrorLoc<ELF64LE>(Loc); + case ELF64BEKind: + return getErrorLoc<ELF64BE>(Loc); + default: + llvm_unreachable("unknown ELF type"); + } +} + template <unsigned N> static void checkInt(uint8_t *Loc, int64_t V, uint32_t Type) { if (!isInt<N>(V)) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index f0563c43bcd..491f4f7bcbe 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1697,34 +1697,6 @@ template <class ELFT> void Writer<ELFT>::writeBuildId() { In<ELFT>::BuildId->writeBuildId({Start, End}); } -template <class ELFT> static std::string getErrorLoc(uint8_t *Loc) { - for (InputSectionData *D : Symtab<ELFT>::X->Sections) { - auto *IS = dyn_cast_or_null<InputSection<ELFT>>(D); - if (!IS || !IS->OutSec) - continue; - - uint8_t *ISLoc = cast<OutputSection<ELFT>>(IS->OutSec)->Loc + IS->OutSecOff; - if (ISLoc <= Loc && ISLoc + IS->getSize() > Loc) - return IS->getLocation(Loc - ISLoc) + ": "; - } - return ""; -} - -std::string elf::getErrorLocation(uint8_t *Loc) { - switch (Config->EKind) { - case ELF32LEKind: - return getErrorLoc<ELF32LE>(Loc); - case ELF32BEKind: - return getErrorLoc<ELF32BE>(Loc); - case ELF64LEKind: - return getErrorLoc<ELF64LE>(Loc); - case ELF64BEKind: - return getErrorLoc<ELF64BE>(Loc); - default: - llvm_unreachable("unknown ELF type"); - } -} - template void elf::writeResult<ELF32LE>(); template void elf::writeResult<ELF32BE>(); template void elf::writeResult<ELF64LE>(); diff --git a/lld/ELF/Writer.h b/lld/ELF/Writer.h index 96dd70b109d..718e3139a80 100644 --- a/lld/ELF/Writer.h +++ b/lld/ELF/Writer.h @@ -60,7 +60,6 @@ uint8_t getMipsFpAbiFlag(uint8_t OldFlag, uint8_t NewFlag, llvm::StringRef FileName); bool isMipsN32Abi(const InputFile *F); -std::string getErrorLocation(uint8_t *Loc); } } |