[llvm] 9fc0aa4 - [JITLink][ELF] Log enum name of unsupported relocation type.
Sunho Kim via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 15 07:26:41 PDT 2022
Author: Sunho Kim
Date: 2022-06-15T23:26:29+09:00
New Revision: 9fc0aa45e3312944431ba7e1ca0cec99c613992b
URL: https://github.com/llvm/llvm-project/commit/9fc0aa45e3312944431ba7e1ca0cec99c613992b
DIFF: https://github.com/llvm/llvm-project/commit/9fc0aa45e3312944431ba7e1ca0cec99c613992b.diff
LOG: [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
Added:
Modified:
llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
index 4d3e966f7f503..652ad2a0736e4 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
@@ -107,8 +107,9 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
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 {
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
index e772ae834e29b..197ab71f52741 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
@@ -471,8 +471,9 @@ class ELFLinkGraphBuilder_riscv : public ELFLinkGraphBuilder<ELFT> {
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 {
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
index ca9a2964ff146..8f21274bd1a3c 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -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 @@ class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
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 {
More information about the llvm-commits
mailing list