From 62ea1842373fd5b03db3bd28625af29bff02e4a5 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 15 Jan 2022 18:00:49 +0000 Subject: [PATCH] Fixed initial stack setup. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15361 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/sb/host/sbhost.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/os/sb/host/sbhost.c b/os/sb/host/sbhost.c index c33ea62e6..854084186 100644 --- a/os/sb/host/sbhost.c +++ b/os/sb/host/sbhost.c @@ -263,10 +263,10 @@ thread_t *sbStartThread(sb_class_t *sbp, const char *name, /* Allocating space for parameters.*/ if (MEM_IS_ALIGNED(usp, PORT_STACK_ALIGN)) { - parsize = sizeof (int) + sizeof (const char **) + sizeof (const char **) + sizeof (int); + parsize = sizeof (uint32_t) * 4; } else { - parsize = sizeof (const char **) + sizeof (const char **) + sizeof (int); + parsize = sizeof (uint32_t) * 5; } PUSHSPACE(usp, parsize); @@ -279,6 +279,7 @@ thread_t *sbStartThread(sb_class_t *sbp, const char *name, /* Initializing stack.*/ sb_strv_copy(envp, uenvp, uenvc); sb_strv_copy(argv, uargv, uargc); + *((uint32_t *)usp + 4) = (uint32_t)0x55555555; *((uint32_t *)usp + 2) = (uint32_t)uenvp; *((uint32_t *)usp + 1) = (uint32_t)uargv; *((uint32_t *)usp + 0) = (uint32_t)uargc; @@ -364,10 +365,10 @@ msg_t sbExec(sb_class_t *sbp, const char *pathname, /* Allocating space for parameters.*/ if (MEM_IS_ALIGNED(usp, PORT_STACK_ALIGN)) { - parsize = sizeof (int) + sizeof (const char **) + sizeof (const char **) + sizeof (int); + parsize = sizeof (uint32_t) * 4; } else { - parsize = sizeof (const char **) + sizeof (const char **) + sizeof (int); + parsize = sizeof (uint32_t) * 5; } PUSHSPACE(usp, parsize); @@ -384,6 +385,7 @@ msg_t sbExec(sb_class_t *sbp, const char *pathname, /* Initializing stack.*/ sb_strv_copy(envp, uenvp, uenvc); sb_strv_copy(argv, uargv, uargc); + *((uint32_t *)usp + 4) = (uint32_t)0x55555555; *((uint32_t *)usp + 2) = (uint32_t)uenvp; *((uint32_t *)usp + 1) = (uint32_t)uargv; *((uint32_t *)usp + 0) = (uint32_t)uargc;