Skip to content

Commit

Permalink
[JITLink][ELF][x86-64] Include relocation name in missing relocation …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
lhames committed Jul 30, 2021
1 parent 7a797b2 commit 8a241cd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8a241cd

Please sign in to comment.