From: Stefan Gränitz Date: Tue, 4 Apr 2023 17:06:10 +0000 (+0200) Subject: [JITLink][AArch32] Implement ELF::R_ARM_ABS32 after we stopped skipping debug info... X-Git-Tag: upstream/17.0.6~12566 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a05a98a230196f43f8f33f16feeae78167e18e11;p=platform%2Fupstream%2Fllvm.git [JITLink][AArch32] Implement ELF::R_ARM_ABS32 after we stopped skipping debug info sections We create LinkGraph sections with NoAlloc lifetime now since f05ac803ffe76c7f4299a4e1288cc6bb8b098410 This means we do process debug info sections now with all their relocations. That's ok for the moment. --- diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h b/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h index 8488b10..c05c7ab 100644 --- a/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h +++ b/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h @@ -27,14 +27,18 @@ namespace aarch32 { enum EdgeKind_aarch32 : Edge::Kind { /// - /// Relocations of class Data + /// Relocations of class Data respect target endianness (unless otherwise + /// specified) /// FirstDataRelocation = Edge::FirstRelocation, - /// Plain 32-bit value relocation in target endianness + /// Relative 32-bit value relocation Data_Delta32 = FirstDataRelocation, - LastDataRelocation = Data_Delta32, + /// Absolute 32-bit value relocation + Data_Pointer32, + + LastDataRelocation = Data_Pointer32, /// /// Relocations of class Arm (covers fixed-width 4-byte instruction subset) diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp index 8aa5a9f..570e4dc 100644 --- a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp @@ -34,6 +34,8 @@ namespace jitlink { /// Translate from ELF relocation type to JITLink-internal edge kind. Expected getJITLinkEdgeKind(uint32_t ELFType) { switch (ELFType) { + case ELF::R_ARM_ABS32: + return aarch32::Data_Pointer32; case ELF::R_ARM_REL32: return aarch32::Data_Delta32; case ELF::R_ARM_CALL: @@ -58,6 +60,8 @@ Expected getELFRelocationType(Edge::Kind Kind) { switch (static_cast(Kind)) { case aarch32::Data_Delta32: return ELF::R_ARM_REL32; + case aarch32::Data_Pointer32: + return ELF::R_ARM_ABS32; case aarch32::Arm_Call: return ELF::R_ARM_CALL; case aarch32::Thumb_Call: diff --git a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp index 28fa0b6..ffc3950 100644 --- a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp @@ -200,6 +200,7 @@ Expected readAddendData(LinkGraph &G, Block &B, const Edge &E) { switch (Kind) { case Data_Delta32: + case Data_Pointer32: return SignExtend64<32>(support::endian::read32(FixupPtr, Endian)); default: return make_error( @@ -303,6 +304,13 @@ Error applyFixupData(LinkGraph &G, Block &B, const Edge &E) { Write32(Value); return Error::success(); } + case Data_Pointer32: { + int64_t Value = TargetAddress + Addend; + if (!isInt<32>(Value)) + return makeTargetOutOfRangeError(G, B, E); + Write32(Value); + return Error::success(); + } default: return make_error( "In graph " + G.getName() + ", section " + B.getSection().getName() +