forked from ariadne/libucontext
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.arm_linker_fix
parent
55168fcb18
commit
8ea5f548b9
|
@ -32,7 +32,7 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
|
||||||
int i;
|
int i;
|
||||||
unsigned int stack_args;
|
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 = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
|
||||||
sp -= stack_args + 2;
|
sp -= stack_args + 2;
|
||||||
|
@ -52,7 +52,7 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
|
||||||
if (i < 8)
|
if (i < 8)
|
||||||
ucp->uc_mcontext.gp_regs[i + 3] = va_arg (va, greg_t);
|
ucp->uc_mcontext.gp_regs[i + 3] = va_arg (va, greg_t);
|
||||||
else
|
else
|
||||||
sp[i-8 + 2] = va_arg (va, greg_t);
|
sp[i + 2] = va_arg (va, greg_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
Loading…
Reference in New Issue