[Git][ghc/ghc][wip/T23680] rts: Implement set_initial_registers for AArch64
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Mon Apr 8 20:02:11 UTC 2024
Ben Gamari pushed to branch wip/T23680 at Glasgow Haskell Compiler / GHC
Commits:
04815d38 by Ben Gamari at 2024-04-08T16:02:02-04:00
rts: Implement set_initial_registers for AArch64
Fixes #23680.
- - - - -
1 changed file:
- rts/Libdw.c
Changes:
=====================================
rts/Libdw.c
=====================================
@@ -285,6 +285,9 @@ static bool memory_read(Dwfl *dwfl STG_UNUSED, Dwarf_Addr addr,
return true;
}
+// This function should persist the current machine state and call
+// dwfl_thread_state_registers. The register numbering should match
+// that defined by the platform's DWARF specification.
static bool set_initial_registers(Dwfl_Thread *thread, void *arg);
#if defined(x86_64_HOST_ARCH)
@@ -315,6 +318,53 @@ static bool set_initial_registers(Dwfl_Thread *thread,
);
return dwfl_thread_state_registers(thread, 0, 17, regs);
}
+#elif defined(aarch64_HOST_ARCH)
+// See https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst
+static bool set_initial_registers(Dwfl_Thread *thread,
+ void *arg STG_UNUSED) {
+ Dwarf_Word regs[33] = {};
+ __asm__ ("str x0, [%0, 0x000]\n\t"
+ "str x1, [%0, 0x008]\n\t"
+ "str x2, [%0, 0x010]\n\t"
+ "str x3, [%0, 0x018]\n\t"
+ "str x4, [%0, 0x020]\n\t"
+ "str x5, [%0, 0x028]\n\t"
+ "str x6, [%0, 0x030]\n\t"
+ "str x7, [%0, 0x038]\n\t"
+ "str x8, [%0, 0x040]\n\t"
+ "str x9, [%0, 0x048]\n\t"
+ "str x10, [%0, 0x050]\n\t"
+ "str x11, [%0, 0x058]\n\t"
+ "str x12, [%0, 0x060]\n\t"
+ "str x13, [%0, 0x068]\n\t"
+ "str x14, [%0, 0x070]\n\t"
+ "str x15, [%0, 0x078]\n\t"
+ "str x16, [%0, 0x080]\n\t"
+ "str x17, [%0, 0x088]\n\t"
+ "str x18, [%0, 0x090]\n\t"
+ "str x19, [%0, 0x098]\n\t"
+ "str x20, [%0, 0x100]\n\t"
+ "str x21, [%0, 0x108]\n\t"
+ "str x22, [%0, 0x110]\n\t"
+ "str x23, [%0, 0x118]\n\t"
+ "str x24, [%0, 0x120]\n\t"
+ "str x25, [%0, 0x128]\n\t"
+ "str x26, [%0, 0x130]\n\t"
+ "str x27, [%0, 0x138]\n\t"
+ "str x28, [%0, 0x140]\n\t"
+ "str x29, [%0, 0x148]\n\t"
+ "str x30, [%0, 0x150]\n\t"
+ "mov x1, sp\n\t"
+ "str x1, [%0, 0x158]\n\t"
+ ".here:\n\t"
+ "adr x1, .here\n\t"
+ "str x1, [%0, 0x160]\n\t"
+ : /* no output */
+ :"r" (®s[0]) /* input */
+ :"x1" /* clobbered */
+ );
+ return dwfl_thread_state_registers(thread, 0, 33, regs);
+}
#elif defined(i386_HOST_ARCH)
static bool set_initial_registers(Dwfl_Thread *thread,
void *arg STG_UNUSED) {
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04815d382dfb7a68af2e05d59197ae0fda0c6a9b
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04815d382dfb7a68af2e05d59197ae0fda0c6a9b
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240408/32ec01ba/attachment-0001.html>
More information about the ghc-commits
mailing list