[JITLink][AArch32] Implement ELF::R_ARM_ABS32 after we stopped skipping debug info...
authorStefan Gränitz <stefan.graenitz@gmail.com>
Tue, 4 Apr 2023 17:06:10 +0000 (19:06 +0200)
committerStefan Gränitz <stefan.graenitz@gmail.com>
Wed, 5 Apr 2023 16:02:12 +0000 (18:02 +0200)
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.

llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
llvm/lib/ExecutionEngine/JITLink/aarch32.cpp

index 8488b10..c05c7ab 100644 (file)
@@ -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)
index 8aa5a9f..570e4dc 100644 (file)
@@ -34,6 +34,8 @@ namespace jitlink {
 /// Translate from ELF relocation type to JITLink-internal edge kind.
 Expected<aarch32::EdgeKind_aarch32> 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<uint32_t> getELFRelocationType(Edge::Kind Kind) {
   switch (static_cast<aarch32::EdgeKind_aarch32>(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:
index 28fa0b6..ffc3950 100644 (file)
@@ -200,6 +200,7 @@ Expected<int64_t> 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<JITLinkError>(
@@ -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<JITLinkError>(
         "In graph " + G.getName() + ", section " + B.getSection().getName() +