Skip to content

Commit 8a241cd

Browse files
committed
[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.
1 parent 7a797b2 commit 8a241cd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,17 @@ static Error optimizeELF_x86_64_GOTAndStubs(LinkGraph &G) {
221221
return Error::success();
222222
}
223223

224+
static const char *getELFX86_64RelocName(uint32_t Type) {
225+
switch (Type) {
226+
#define ELF_RELOC(Name, Number) \
227+
case Number: \
228+
return #Name;
229+
#include "llvm/BinaryFormat/ELFRelocs/x86_64.def"
230+
#undef ELF_RELOC
231+
}
232+
return "Unrecognized ELF/x86-64 relocation type";
233+
}
234+
224235
namespace llvm {
225236
namespace jitlink {
226237

@@ -252,8 +263,9 @@ class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
252263
case ELF::R_X86_64_PLT32:
253264
return ELF_x86_64_Edges::ELFX86RelocationKind::Branch32;
254265
}
255-
return make_error<JITLinkError>("Unsupported x86-64 relocation:" +
256-
formatv("{0:d}", Type));
266+
return make_error<JITLinkError>("Unsupported x86-64 relocation type " +
267+
formatv("{0:d}: ", Type) +
268+
getELFX86_64RelocName(Type));
257269
}
258270

259271
Error addRelocations() override {

0 commit comments

Comments
 (0)