From: Lang Hames Date: Thu, 1 Sep 2022 19:26:47 +0000 (-0700) Subject: [JITLink] Sink ELFX86RelocationKind into implementation file (ELF_x86_64.cpp). X-Git-Tag: upstream/17.0.6~34677 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=06c46344838858623e17e64dde57a2edce05bbac;p=platform%2Fupstream%2Fllvm.git [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. --- diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h index f5fa9e9..fbe5765 100644 --- a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h +++ b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h @@ -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 G, std::unique_ptr 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 diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp index 8f21274..60d44d5 100644 --- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp @@ -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 { private: using ELFT = object::ELF64LE; - static Expected - 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 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( "Unsupported x86-64 relocation type " + formatv("{0:d}: ", Type) + @@ -399,32 +412,5 @@ void link_ELF_x86_64(std::unique_ptr 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(R)); -} } // end namespace jitlink } // end namespace llvm