summaryrefslogblamecommitdiff
path: root/bootstrap/llvm16/dyld-elf-ppc32.patch
blob: 42f0abb5325691b62ab9ec8cc44df1a6211b75b0 (plain) (tree)























                                                                                                                   
Author: A. Wilcox <awilfox@adelielinux.org>
Upstream-Status: Pending

This implements the R_PPC_REL32 relocation type, which is needed for the
OrcJIT to work properly on 32-bit PowerPC.

Needs more tests before submitting upstream, but seems to DTRT.

--- llvm-14.0.6.src/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp.old	2022-06-22 16:46:24.000000000 +0000
+++ llvm-14.0.6.src/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp	2022-11-28 06:33:12.239921624 +0000
@@ -825,6 +825,13 @@
   case ELF::R_PPC_ADDR16_HA:
     writeInt16BE(LocalAddress, applyPPCha(Value + Addend));
     break;
+  case ELF::R_PPC_REL32:
+    uint32_t FinalAddress = Section.getLoadAddressWithOffset(Offset);
+    int64_t delta = static_cast<int64_t>(Value - FinalAddress + Addend);
+    if (SignExtend64<32>(delta) != delta)
+      llvm_unreachable("Relocation R_PPC_REL32 overflow");
+    writeInt32BE(LocalAddress, delta);
+    break;
   }
 }