rt: Zero the bottom frame's return address and base pointer

My reading of libunwind leads me to believe this is expected.

Closes #1322
This commit is contained in:
Brian Anderson 2011-12-19 18:36:09 -08:00
parent 586281e2d6
commit edf6e1ec0e
2 changed files with 10 additions and 2 deletions

View file

@ -31,10 +31,14 @@ void context::call(void *f, void *arg, void *stack) {
// Shift the stack pointer so the alignment works out right.
sp = align_down(sp) - 3;
*--sp = (uint32_t)arg;
*--sp = 0xdeadbeef;
// The final return address. 0 indicates the bottom of the stack
*--sp = 0;
regs.esp = (uint32_t)sp;
regs.eip = (uint32_t)f;
// Last base pointer on the stack should be 0
regs.ebp = 0;
}
#if 0

View file

@ -28,9 +28,13 @@ void context::call(void *f, void *arg, void *stack) {
// set up the stack
uint64_t *sp = (uint64_t *)stack;
sp = align_down(sp);
*--sp = 0xdeadbeef; // takes place of ret. addr.
// The final return address. 0 indicates the bottom of the stack
*--sp = 0;
regs.data[RUSTRT_ARG0] = (uint64_t)arg;
regs.data[RUSTRT_RSP] = (uint64_t)sp;
regs.data[RUSTRT_IP] = (uint64_t)f;
// Last base pointer on the stack should be 0
regs.data[RUSTRT_RBP] = 0;
}