summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2022-06-02 02:01:04 +0100
committerJohn-Mark Bell <jmb@netsurf-browser.org>2022-11-01 20:24:06 +0000
commit5614c157989873efdb53cb5633ee9eb461ec814c (patch)
tree2a62035f82926b6083f2f74435ace54f44550d5d
parent702073888df04286767540c3159c2c6e385a761d (diff)
downloadtoolchains-5614c157989873efdb53cb5633ee9eb461ec814c.tar.gz
toolchains-5614c157989873efdb53cb5633ee9eb461ec814c.tar.bz2
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.
-rw-r--r--arm-riscos-gnueabihf/recipes/patches/gccsdk/unixlib-initial-sp.p31
1 files changed, 31 insertions, 0 deletions
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.