sim: Fix stack alignment

The recent x86-64 convention requires 16-byte alignment before
(not after) calling a function.

This fixes snprintf crash I observed on macOS while saving XMM registers.
This commit is contained in:
YAMAMOTO Takashi 2020-01-29 03:26:43 +09:00 committed by Alin Jerpelea
parent 39bd9ff670
commit 298c2e5e4f
2 changed files with 2 additions and 2 deletions

View File

@ -67,6 +67,6 @@
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;
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;
}

View File

@ -124,7 +124,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Reset the initial state */
tcb->xcp.regs[JB_SP] = (xcpt_reg_t)tcb->adj_stack_ptr;
tcb->xcp.regs[JB_SP] = (xcpt_reg_t)tcb->adj_stack_ptr - sizeof(xcpt_reg_t);
/* And return a pointer to the allocated memory */