sh: makecontext: set up stack pointer in r15

pull/23/head
Ariadne Conill 2020-12-12 04:53:29 +00:00
parent da3c8d170f
commit 82f734ab47
2 changed files with 2 additions and 1 deletions

View File

@ -4,6 +4,7 @@
#define REG_SZ (4)
#define MCONTEXT_GREGS (24)
#define REG_SP (15)
#define REG_PC (16)
#define REG_PR (17)
#define REG_SR (18)

View File

@ -34,7 +34,7 @@ libucontext_makecontext(libucontext_ucontext_t *ucp, void (*func)(void), int arg
sp -= argc > 4 ? argc - 4 : 0;
/* set up the context */
ucp->uc_mcontext.sr = (libucontext_greg_t) sp;
ucp->uc_mcontext.gregs[REG_SP] = (libucontext_greg_t) sp;
ucp->uc_mcontext.pr = (libucontext_greg_t) libucontext_trampoline;
ucp->uc_mcontext.pc = (libucontext_greg_t) func;
ucp->uc_mcontext.gregs[8] = (libucontext_greg_t) ucp->uc_link;