[JITLink] Sink ELFX86RelocationKind into implementation file (ELF_x86_64.cpp).

The ELF/x86-64 backend uses the generic x86_64 edges now, so the
ELFX86RelocationKind is just an implementation detail.
This commit is contained in:
Lang Hames 2022-09-01 12:26:47 -07:00
parent c29c6170fd
commit 06c4634483
2 changed files with 28 additions and 62 deletions

View File

@ -18,24 +18,6 @@
namespace llvm {
namespace jitlink {
namespace ELF_x86_64_Edges {
enum ELFX86RelocationKind : Edge::Kind {
Branch32 = Edge::FirstRelocation,
Pointer32Signed,
Pointer64,
PCRel32,
PCRel32GOTLoad,
PCRel32GOTLoadRelaxable,
PCRel32REXGOTLoadRelaxable,
PCRel32TLV,
PCRel64GOT,
GOTOFF64,
GOT64,
Delta64,
};
} // end namespace ELF_x86_64_Edges
/// Create a LinkGraph from an ELF/x86-64 relocatable object.
///
/// Note: The graph does not take ownership of the underlying buffer, nor copy
@ -48,8 +30,6 @@ createLinkGraphFromELFObject_x86_64(MemoryBufferRef ObjectBuffer);
void link_ELF_x86_64(std::unique_ptr<LinkGraph> G,
std::unique_ptr<JITLinkContext> Ctx);
/// Return the string name of the given ELF x86-64 edge kind.
const char *getELFX86RelocationKindName(Edge::Kind R);
} // end namespace jitlink
} // end namespace llvm

View File

@ -27,7 +27,6 @@
using namespace llvm;
using namespace llvm::jitlink;
using namespace llvm::jitlink::ELF_x86_64_Edges;
namespace {
@ -106,34 +105,48 @@ class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
private:
using ELFT = object::ELF64LE;
static Expected<ELF_x86_64_Edges::ELFX86RelocationKind>
getRelocationKind(const uint32_t Type) {
enum ELFX86RelocationKind : Edge::Kind {
Branch32 = Edge::FirstRelocation,
Pointer32Signed,
Pointer64,
PCRel32,
PCRel32GOTLoad,
PCRel32GOTLoadRelaxable,
PCRel32REXGOTLoadRelaxable,
PCRel32TLV,
PCRel64GOT,
GOTOFF64,
GOT64,
Delta64,
};
static Expected<ELFX86RelocationKind> getRelocationKind(const uint32_t Type) {
switch (Type) {
case ELF::R_X86_64_32S:
return ELF_x86_64_Edges::ELFX86RelocationKind::Pointer32Signed;
return ELFX86RelocationKind::Pointer32Signed;
case ELF::R_X86_64_PC32:
return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32;
return ELFX86RelocationKind::PCRel32;
case ELF::R_X86_64_PC64:
case ELF::R_X86_64_GOTPC64:
return ELF_x86_64_Edges::ELFX86RelocationKind::Delta64;
return ELFX86RelocationKind::Delta64;
case ELF::R_X86_64_64:
return ELF_x86_64_Edges::ELFX86RelocationKind::Pointer64;
return ELFX86RelocationKind::Pointer64;
case ELF::R_X86_64_GOTPCREL:
return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32GOTLoad;
return ELFX86RelocationKind::PCRel32GOTLoad;
case ELF::R_X86_64_GOTPCRELX:
return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32GOTLoadRelaxable;
return ELFX86RelocationKind::PCRel32GOTLoadRelaxable;
case ELF::R_X86_64_REX_GOTPCRELX:
return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32REXGOTLoadRelaxable;
return ELFX86RelocationKind::PCRel32REXGOTLoadRelaxable;
case ELF::R_X86_64_GOTPCREL64:
return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel64GOT;
return ELFX86RelocationKind::PCRel64GOT;
case ELF::R_X86_64_GOT64:
return ELF_x86_64_Edges::ELFX86RelocationKind::GOT64;
return ELFX86RelocationKind::GOT64;
case ELF::R_X86_64_GOTOFF64:
return ELF_x86_64_Edges::ELFX86RelocationKind::GOTOFF64;
return ELFX86RelocationKind::GOTOFF64;
case ELF::R_X86_64_PLT32:
return ELF_x86_64_Edges::ELFX86RelocationKind::Branch32;
return ELFX86RelocationKind::Branch32;
case ELF::R_X86_64_TLSGD:
return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32TLV;
return ELFX86RelocationKind::PCRel32TLV;
}
return make_error<JITLinkError>(
"Unsupported x86-64 relocation type " + formatv("{0:d}: ", Type) +
@ -399,32 +412,5 @@ void link_ELF_x86_64(std::unique_ptr<LinkGraph> G,
ELFJITLinker_x86_64::link(std::move(Ctx), std::move(G), std::move(Config));
}
const char *getELFX86RelocationKindName(Edge::Kind R) {
switch (R) {
case Branch32:
return "Branch32";
case Pointer32Signed:
return "Pointer32Signed";
case Pointer64:
return "Pointer64";
case PCRel32:
return "PCRel32";
case PCRel32GOTLoad:
return "PCRel32GOTLoad";
case PCRel32GOTLoadRelaxable:
return "PCRel32GOTLoadRelaxable";
case PCRel32REXGOTLoadRelaxable:
return "PCRel32REXGOTLoad";
case PCRel64GOT:
return "PCRel64GOT";
case Delta64:
return "Delta64";
case GOT64:
return "GOT64";
case GOTOFF64:
return "GOTOFF64";
}
return getGenericEdgeKindName(static_cast<Edge::Kind>(R));
}
} // end namespace jitlink
} // end namespace llvm