[JITLink][ELF] Log enum name of unsupported relocation type.

Logs enum name of unsupported relocation type. This also changes elf/x86 to use common util function (getELFRelocationTypeName) inside llvm object module.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D127715
This commit is contained in:
Sunho Kim 2022-06-15 23:24:18 +09:00
parent e180cc5ff1
commit 9fc0aa45e3
3 changed files with 9 additions and 18 deletions

View File

@ -107,8 +107,9 @@ private:
return ELFLd64GOTLo12;
}
return make_error<JITLinkError>("Unsupported aarch64 relocation:" +
formatv("{0:d}", Type));
return make_error<JITLinkError>(
"Unsupported aarch64 relocation:" + formatv("{0:d}: ", Type) +
object::getELFRelocationTypeName(ELF::EM_AARCH64, Type));
}
Error addRelocations() override {

View File

@ -471,8 +471,9 @@ private:
return EdgeKind_riscv::R_RISCV_32_PCREL;
}
return make_error<JITLinkError>("Unsupported riscv relocation:" +
formatv("{0:d}", Type));
return make_error<JITLinkError>(
"Unsupported riscv relocation:" + formatv("{0:d}: ", Type) +
object::getELFRelocationTypeName(ELF::EM_RISCV, Type));
}
Error addRelocations() override {

View File

@ -97,17 +97,6 @@ Error buildTables_ELF_x86_64(LinkGraph &G) {
}
} // namespace
static const char *getELFX86_64RelocName(uint32_t Type) {
switch (Type) {
#define ELF_RELOC(Name, Number) \
case Number: \
return #Name;
#include "llvm/BinaryFormat/ELFRelocs/x86_64.def"
#undef ELF_RELOC
}
return "Unrecognized ELF/x86-64 relocation type";
}
namespace llvm {
namespace jitlink {
@ -146,9 +135,9 @@ private:
case ELF::R_X86_64_TLSGD:
return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32TLV;
}
return make_error<JITLinkError>("Unsupported x86-64 relocation type " +
formatv("{0:d}: ", Type) +
getELFX86_64RelocName(Type));
return make_error<JITLinkError>(
"Unsupported x86-64 relocation type " + formatv("{0:d}: ", Type) +
object::getELFRelocationTypeName(ELF::EM_X86_64, Type));
}
Error addRelocations() override {