ppc64: fix makecontext with more than 8 parameters

The ELFv2 ABI used on PPC64 differs from the ELFv1 ABI used on PPC32 here.
On PPC64, once there are any parameters that need to be passed on the
stack, space needs to be reserved on the stack to pass all parameters.
Parameters 0-7 are still only passed by register, but if the callee needs
to spill them, it can use the stack space reserved for the corresponding
parameter to do so.
master
Bobby Bingham 2019-04-05 14:01:10 -05:00
parent 55168fcb18
commit 8ea5f548b9
1 changed files with 2 additions and 2 deletions

View File

@ -32,7 +32,7 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
int i;
unsigned int stack_args;
stack_args = argc > 8 ? argc - 8 : 0;
stack_args = argc > 8 ? argc : 0;
sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
sp -= stack_args + 2;
@ -52,7 +52,7 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
if (i < 8)
ucp->uc_mcontext.gp_regs[i + 3] = va_arg (va, greg_t);
else
sp[i-8 + 2] = va_arg (va, greg_t);
sp[i + 2] = va_arg (va, greg_t);
}
va_end(va);