mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 09:18:00 +08:00
sim: fix color running stack crash when use -Os
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
@@ -35,6 +35,12 @@
|
||||
|
||||
#include "sim_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define STACK_MARGIN_WORDS 32
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -171,7 +177,7 @@ void nostackprotect_function sim_stack_color(void *stackbase,
|
||||
if (nbytes == 0) /* 0: colorize the running stack */
|
||||
{
|
||||
stkend = up_getsp();
|
||||
if (stkend > (uintptr_t)&sp)
|
||||
if (stkend < (uintptr_t)&sp)
|
||||
{
|
||||
stkend = (uintptr_t)&sp;
|
||||
}
|
||||
@@ -183,6 +189,7 @@ void nostackprotect_function sim_stack_color(void *stackbase,
|
||||
|
||||
stkend = STACK_ALIGN_DOWN(stkend);
|
||||
nwords = (stkend - (uintptr_t)stackbase) >> 2;
|
||||
nwords = nwords > STACK_MARGIN_WORDS ? nwords - STACK_MARGIN_WORDS : 0;
|
||||
|
||||
/* Set the entire stack to the coloration value */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user