Hello. This patch ports stack pointer reading to AArch64 at fork.cc and cygtls.h.
Radek --- >From cc920233d50fe38f22610cb51f219e3c9b566109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Barto=C5=88?= <[email protected]> Date: Fri, 6 Jun 2025 10:21:10 +0200 Subject: [PATCH] Cygwin: obtain stack pointer on AArch64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Radek BartoĊ <[email protected]> --- winsup/cygwin/fork.cc | 4 +++- winsup/cygwin/local_includes/cygtls.h | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index f88acdbbf..4abc52598 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -660,8 +660,10 @@ dofork (void **proc, bool *with_forkables) ischild = !!setjmp (grouped.ch.jmp); volatile char * volatile stackp; -#ifdef __x86_64__ +#if defined(__x86_64__) __asm__ volatile ("movq %%rsp,%0": "=r" (stackp)); +#elif defined(__aarch64__) + __asm__ volatile ("mov %0, sp" : "=r" (stackp)); #else #error unimplemented for this target #endif diff --git a/winsup/cygwin/local_includes/cygtls.h b/winsup/cygwin/local_includes/cygtls.h index 31cadd51a..44bd44e72 100644 --- a/winsup/cygwin/local_includes/cygtls.h +++ b/winsup/cygwin/local_includes/cygtls.h @@ -325,7 +325,13 @@ public: address of the _except block to restore the context correctly. See comment preceeding myfault_altstack_handler in exception.cc. */ ret = (DWORD64) _ret; +#if defined(__x86_64__) __asm__ volatile ("movq %%rsp,%0": "=o" (frame)); +#elif defined(__aarch64__) + __asm__ volatile ("mov %0, sp" : "=r" (frame)); +#else +#error unimplemented for this target +#endif } ~san () __attribute__ ((always_inline)) { -- 2.49.0.vfs.0.4
0001-Cygwin-obtain-stack-pointer-on-AArch64.patch
Description: 0001-Cygwin-obtain-stack-pointer-on-AArch64.patch
