[llvm] 8a241cd - [JITLink][ELF][x86-64] Include relocation name in missing relocation errors.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 29 22:19:20 PDT 2021
Author: Lang Hames
Date: 2021-07-30T15:19:11+10:00
New Revision: 8a241cd9c2479fc5c1fa3b31a1348bec11654367
URL: https://github.com/llvm/llvm-project/commit/8a241cd9c2479fc5c1fa3b31a1348bec11654367
DIFF: https://github.com/llvm/llvm-project/commit/8a241cd9c2479fc5c1fa3b31a1348bec11654367.diff
LOG: [JITLink][ELF][x86-64] Include relocation name in missing relocation errors.
This saves a level of manual table lookup for those of us who don't remember
ELF relocation numbers off the top of our heads.
Added:
Modified:
llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
index a5aed6d252007..e137c1d2e5b22 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -221,6 +221,17 @@ static Error optimizeELF_x86_64_GOTAndStubs(LinkGraph &G) {
return Error::success();
}
+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 {
@@ -252,8 +263,9 @@ class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
case ELF::R_X86_64_PLT32:
return ELF_x86_64_Edges::ELFX86RelocationKind::Branch32;
}
- return make_error<JITLinkError>("Unsupported x86-64 relocation:" +
- formatv("{0:d}", Type));
+ return make_error<JITLinkError>("Unsupported x86-64 relocation type " +
+ formatv("{0:d}: ", Type) +
+ getELFX86_64RelocName(Type));
}
Error addRelocations() override {
More information about the llvm-commits
mailing list