mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
sim: fix sim runtime err under sanitize check mode.
since gcc sanitize can not stub proper code in nuttx kernel code. Change-Id: Ibceab92011087bd1b0b2b5a64f1f97a049ac213f
This commit is contained in:
@@ -41,6 +41,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#ifdef CONFIG_SIM_SANITIZE
|
||||
#include <sanitizer/asan_interface.h>
|
||||
#endif
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
@@ -75,4 +78,7 @@ void up_initial_state(struct tcb_s *tcb)
|
||||
memset(&tcb->xcp, 0, sizeof(struct xcptcontext));
|
||||
tcb->xcp.regs[JB_SP] = (xcpt_reg_t)tcb->adj_stack_ptr - sizeof(xcpt_reg_t);
|
||||
tcb->xcp.regs[JB_PC] = (xcpt_reg_t)tcb->start;
|
||||
#ifdef CONFIG_SIM_SANITIZE
|
||||
__asan_unpoison_memory_region(tcb->stack_alloc_ptr, tcb->adj_stack_size);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -83,11 +83,16 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SIM_SANITIZE
|
||||
__attribute__((no_sanitize_address))
|
||||
#endif
|
||||
pid_t up_vfork(const xcpt_reg_t *context)
|
||||
{
|
||||
struct tcb_s *parent = this_task();
|
||||
struct task_tcb_s *child;
|
||||
size_t stacksize;
|
||||
unsigned char *pout;
|
||||
unsigned char *pin;
|
||||
unsigned long newsp;
|
||||
unsigned long newfp;
|
||||
unsigned long stackutil;
|
||||
@@ -151,7 +156,9 @@ pid_t up_vfork(const xcpt_reg_t *context)
|
||||
*/
|
||||
|
||||
newsp = (unsigned long)child->cmn.adj_stack_ptr - stackutil;
|
||||
memcpy((void *)newsp, (const void *)context[JB_SP], stackutil);
|
||||
pout = (unsigned char *)newsp;
|
||||
pin = (unsigned char *)context[JB_SP];
|
||||
while (stackutil-- > 0) *pout++ = *pin++;
|
||||
|
||||
/* Was there a frame pointer in place before? */
|
||||
|
||||
@@ -180,7 +187,8 @@ pid_t up_vfork(const xcpt_reg_t *context)
|
||||
* child thread.
|
||||
*/
|
||||
|
||||
memcpy(child->cmn.xcp.regs, context, sizeof(xcpt_reg_t) * XCPTCONTEXT_REGS);
|
||||
memcpy(child->cmn.xcp.regs, context,
|
||||
sizeof(xcpt_reg_t) * XCPTCONTEXT_REGS);
|
||||
child->cmn.xcp.regs[JB_FP] = newfp; /* Frame pointer */
|
||||
child->cmn.xcp.regs[JB_SP] = newsp; /* Stack pointer */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user