On Wed, 18 Jun 2025, Radek Barton via Cygwin-patches wrote:

> Hello.
>
> This patch ports stack base initialization at dcrt0.cc to AArch64.
>
> Radek
>
> ---
> From 5d470261d9b865bf709f9f4d8da350e3536e6251 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Radek=20Barto=C5=88?= <radek.bar...@microsoft.com>
> Date: Thu, 5 Jun 2025 13:15:22 +0200
> Subject: [PATCH] Cygwin: stack base initialization for AArch64
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> Signed-off-by: Radek BartoĊˆ <radek.bar...@microsoft.com>
> ---
>  winsup/cygwin/dcrt0.cc | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
> index f4c09befd..15b3479d3 100644
> --- a/winsup/cygwin/dcrt0.cc
> +++ b/winsup/cygwin/dcrt0.cc
> @@ -1030,14 +1030,20 @@ _dll_crt0 ()
>         PVOID stackaddr = create_new_main_thread_stack (allocationbase);
>         if (stackaddr)
>           {
> -#ifdef __x86_64__
>             /* Set stack pointer to new address.  Set frame pointer to
>                stack pointer and subtract 32 bytes for shadow space. */
> +#if defined(__x86_64__)
>             __asm__ ("\n\
>                      movq %[ADDR], %%rsp \n\
>                      movq  %%rsp, %%rbp  \n\
>                      subq  $32,%%rsp     \n"
>                      : : [ADDR] "r" (stackaddr));
> +#elif defined(__aarch64__)
> +           __asm__ ("\n\
> +                    mov fp, %[ADDR] \n\
> +                    sub sp, fp, #32 \n"

Is the 32-byte shadow space part of the aarch64 calling convention spec,
or is this just copying what x86_64 was doing?  My impression is that this
space was part of the x86_64 calling convention.


> +                    : : [ADDR] "r" (stackaddr)
> +                    : "memory");
>  #else
>  #error unimplemented for this target
>  #endif
> --
> 2.49.0.vfs.0.4

Reply via email to