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

Jacek Caban via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 30 08:58:14 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)));
----------------
cjacek wrote:

Good point, I changed it to use `ulittle32_t`. I don't have access to such system, so I'd appreciate checking it.

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


More information about the llvm-commits mailing list