From 82f734ab4752e95b8fd51cc15ced3ff4fa40b9f0 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sat, 12 Dec 2020 04:53:29 +0000 Subject: [PATCH] sh: makecontext: set up stack pointer in r15 --- arch/sh/defs.h | 1 + arch/sh/makecontext.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/sh/defs.h b/arch/sh/defs.h index 0367560..2090e87 100644 --- a/arch/sh/defs.h +++ b/arch/sh/defs.h @@ -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) diff --git a/arch/sh/makecontext.c b/arch/sh/makecontext.c index dafc1f9..76a0dfd 100644 --- a/arch/sh/makecontext.c +++ b/arch/sh/makecontext.c @@ -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;