[Git][ghc/ghc][wip/T23680] rts: Implement set_initial_registers for AArch64

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Mon Apr 8 20:28:12 UTC 2024



Ben Gamari pushed to branch wip/T23680 at Glasgow Haskell Compiler / GHC


Commits:
de154045 by Ben Gamari at 2024-04-08T16:28:06-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, 0x0a0]\n\t"
+             "str x21, [%0, 0x0a8]\n\t"
+             "str x22, [%0, 0x0b0]\n\t"
+             "str x23, [%0, 0x0b8]\n\t"
+             "str x24, [%0, 0x0c0]\n\t"
+             "str x25, [%0, 0x0c8]\n\t"
+             "str x26, [%0, 0x0d0]\n\t"
+             "str x27, [%0, 0x0d8]\n\t"
+             "str x28, [%0, 0x0e0]\n\t"
+             "str x29, [%0, 0x0e8]\n\t"
+             "str x30, [%0, 0x0f0]\n\t"
+             "mov x1,  sp\n\t"
+             "str x1,  [%0, 0x0f8]\n\t"
+             ".here:\n\t"
+             "adr x1,  .here\n\t"
+             "str x1,  [%0, 0x100]\n\t"
+             :                            /* no output */
+             :"r" (&regs[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/de1540458866d0398a348feee11f08229195a3c1

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de1540458866d0398a348feee11f08229195a3c1
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/7c31eeb0/attachment-0001.html>


More information about the ghc-commits mailing list