[lld] [LLD][COFF] Add support for ARM64EC import call thunks. (PR #107931)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 10 09:35:41 PDT 2024


================
@@ -1093,4 +1093,21 @@ void CHPERedirectionChunk::writeTo(uint8_t *buf) const {
   }
 }
 
+ImportThunkChunkARM64EC::ImportThunkChunkARM64EC(ImportFile *file)
+    : ImportThunkChunk(file->ctx, file->impSym), file(file) {}
+
+void ImportThunkChunkARM64EC::writeTo(uint8_t *buf) const {
+  memcpy(buf, importThunkARM64EC, sizeof(importThunkARM64EC));
+  applyArm64Addr(buf, file->impSym->getRVA(), rva, 12);
+  applyArm64Ldr(buf + 4, file->impSym->getRVA() & 0xfff);
+
+  uint32_t exitThunkRVA = exitThunk ? exitThunk->getRVA() : 0;
+  applyArm64Addr(buf + 8, exitThunkRVA, rva + 8, 12);
+  applyArm64Imm(buf + 12, exitThunkRVA & 0xfff, 0);
+
+  Defined *helper = dyn_cast<Defined>(file->ctx.config.arm64ECIcallHelper);
+  if (helper)
+    applyArm64Branch26(buf + 16, helper->getRVA() - rva - 16);
----------------
mstorsjo wrote:

Same here - if this is undefined, won't the instruction end up quite bogus? But I guess this shouldn't really happen?

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


More information about the llvm-commits mailing list