[lld] [LLD][COFF] Add support for ARM64X same-address thunks (PR #151255)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 30 05:03:25 PDT 2025


================
@@ -875,6 +875,18 @@ void RangeExtensionThunkARM64::writeTo(uint8_t *buf) const {
   applyArm64Imm(buf + 4, target->getRVA() & 0xfff, 0);
 }
 
+void SameAddressThunkARM64EC::setDynamicRelocs(COFFLinkerContext &ctx) const {
+  // Add ARM64X relocations replacing adrp/add instructions with a version using
+  // the hybrid target.
+  RangeExtensionThunkARM64 hybridView(ARM64EC, hybridTarget);
+  uint8_t buf[sizeof(arm64Thunk)];
+  hybridView.setRVA(rva);
+  hybridView.writeTo(buf);
+  ctx.dynamicRelocs->set(this, *reinterpret_cast<uint32_t *>(buf));
+  ctx.dynamicRelocs->set(Arm64XRelocVal(this, sizeof(uint32_t)),
+                         *reinterpret_cast<uint32_t *>(buf + sizeof(uint32_t)));
----------------
mstorsjo wrote:

Does this work correctly on big endian, or would we need to use some sort of `ulittle32_t` here? (I have access to big endian systems through the GCC compile farm, so if you want to, I can try to compile and test this on such a system.)

https://github.com/llvm/llvm-project/pull/151255


More information about the llvm-commits mailing list