[OpenWrt-Devel] [PATCH 1/2] brcm63xx/lzma-loader: fix O32 ABI conformance

Álvaro Fernández Rojas noltari at gmail.com
Sat Feb 27 07:37:50 EST 2016


According to the calling convention of the o32 ABI the caller
function must reserve stack space for $a0-$a3 registers in case
the callee needs to save its arguments.

The assembly code of the loader does not reserve stack space for
these registers thus when the 'loader_main' function needs to save
its arguments, those will be stored in the 'workspace' area instead
of the stack.

Because the workspace area is also used by other part of the code, the
saved register values gets overwritten and this often leads to failed
kernel boots.

Fix the code to reserve stack space for the registers to avoid this
error.

Signed-off-by: Gabor Juhos <juhosg at openwrt.org>
[noltari: apply the fix for brcm63xx too]
Signed-off-by: Álvaro Fernández Rojas <noltari at gmail.com>
---
 target/linux/brcm63xx/image/lzma-loader/src/head.S | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/target/linux/brcm63xx/image/lzma-loader/src/head.S b/target/linux/brcm63xx/image/lzma-loader/src/head.S
index 543996a..47a7c9b 100644
--- a/target/linux/brcm63xx/image/lzma-loader/src/head.S
+++ b/target/linux/brcm63xx/image/lzma-loader/src/head.S
@@ -109,6 +109,9 @@ __bss_check:
 	/* Setup new "C" stack */
 	la	sp, _stack
 
+	/* reserve stack space for a0-a3 registers */
+	subu	sp, 16
+
 	/* jump to the decompressor routine */
 	la	t0, loader_main
 	jr	t0
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list