From 0f05376ca242587dc100811b28cd64bdc01cb300 Mon Sep 17 00:00:00 2001 From: John-Mark Bell Date: Thu, 2 Jun 2022 02:01:04 +0100 Subject: Fix initial stack allocation for EABI and soft FP. In this case, there are no VFP registers to reserve space for at the top of the application stack. Thus, the stack pointer points at the top of the stack when we ask ARMEABISupport to give us the stack handle. Unfortunately, despite the top address being given to us by ARMEABISupport in the first place, it does not consider the top of the stack to be part of the stack's storage space and thus we fail to obtain our stack handle and the application aborts. Work around this by discarding the top N bytes of the stack when EABI and soft FP are active. The resulting stack pointer will be aligned to a multiple of 8 bytes in the usual way for AAPCS. Additionally, resolve another stack imbalance in an error path that was spotted while working through this. --- .../recipes/patches/gccsdk/unixlib-initial-sp.p | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 arm-riscos-gnueabihf/recipes/patches/gccsdk/unixlib-initial-sp.p diff --git a/arm-riscos-gnueabihf/recipes/patches/gccsdk/unixlib-initial-sp.p b/arm-riscos-gnueabihf/recipes/patches/gccsdk/unixlib-initial-sp.p new file mode 100644 index 0000000..f3309c2 --- /dev/null +++ b/arm-riscos-gnueabihf/recipes/patches/gccsdk/unixlib-initial-sp.p @@ -0,0 +1,31 @@ +Index: libunixlib/sys/_syslib.s +=================================================================== +--- libunixlib/sys/_syslib.s (revision 7698) ++++ libunixlib/sys/_syslib.s (working copy) +@@ -396,8 +396,9 @@ + SWI XOS_ReadVarVal @ Read value of progname$HeapMax + BVS t08 + TEQ v1, #1 @ Should be a number variable +- LDREQ v2, [sp], #4 ++ LDREQ v2, [sp] + MOVEQ v2, v2, LSL#20 @ Convert MB into bytes ++ ADD sp, sp, #4 + + @ v2 = size of DA area + t08: +@@ -512,7 +513,15 @@ + MOVCC a1, #ERR_NO_FPE + BCC __exit_with_error_num + #endif ++#else ++#ifdef __ARM_EABI__ ++ @ EABI with software FP. Burn the top of the stack to appease ++ @ ARMEABISupport (which does not consider the stack top address ++ @ as part of the stack). ++ SUB sp, sp, #4 ++ BIC sp, sp, #7 @ AAPCS wants 8 byte alignment + #endif ++#endif + + @ We need to create this now so that we have its address to give to + @ the callback handler, but we can initialise it later. -- cgit v1.2.3