Skip to content

Commit 1c57743

Browse files
committed
Implement stack base initialization (#25)
1 parent aac6b24 commit 1c57743

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

winsup/cygwin/dcrt0.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,6 @@ _dll_crt0 ()
10201020
anyway, we now always move the main thread stack to the stack area
10211021
reserved for pthread stacks. This allows a reproducible stack space
10221022
under our own control and avoids collision with the OS. */
1023-
#if !defined(__aarch64__)
10241023
if (!dynamically_loaded)
10251024
{
10261025
if (__in_forkee != FORKING)
@@ -1031,14 +1030,20 @@ _dll_crt0 ()
10311030
PVOID stackaddr = create_new_main_thread_stack (allocationbase);
10321031
if (stackaddr)
10331032
{
1034-
#if defined(__x86_64__)
10351033
/* Set stack pointer to new address. Set frame pointer to
10361034
stack pointer and subtract 32 bytes for shadow space. */
1035+
#if defined(__x86_64__)
10371036
__asm__ ("\n\
10381037
movq %[ADDR], %%rsp \n\
10391038
movq %%rsp, %%rbp \n\
10401039
subq $32,%%rsp \n"
10411040
: : [ADDR] "r" (stackaddr));
1041+
#elif defined(__aarch64__)
1042+
__asm__ ("\n\
1043+
mov fp, %[ADDR] \n\
1044+
sub sp, fp, #32 \n"
1045+
: : [ADDR] "r" (stackaddr)
1046+
: "memory");
10421047
#else
10431048
#error unimplemented for this target
10441049
#endif
@@ -1051,7 +1056,6 @@ _dll_crt0 ()
10511056
else
10521057
fork_info->alloc_stack ();
10531058
}
1054-
#endif
10551059

10561060
fesetenv (FE_DFL_ENV);
10571061
_main_tls = &_my_tls;

0 commit comments

Comments
 (0)