"Fix" makecontext() so that the C code begins execution with its

ABI-required stack alignment.  C code expects that the push of the
return address disturbed the 16 byte alignment and it will take corrective
measures to fix it before making another call.  Of course, if its wrong
to start with, then all hell breaks loose.  Essentially we "fix" this
by making the stack alignment odd to start with.

This was one of the things that broke on libkse with apps that use
floating point/varargs/etc.

Approved by:  re (scottl)
This commit is contained in:
peter 2003-12-05 01:36:44 +00:00
parent b138b33b62
commit 78cbf332e8

View File

@ -70,8 +70,12 @@ __makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...)
/* Allocate space for a maximum of 6 arguments on the stack. */
args = sp - 6;
/* Account for arguments on stack and align to 16 bytes. */
sp -= 8;
/*
* Account for arguments on stack and do the funky C entry alignment.
* This means that we need an 8-byte-odd alignment since the ABI expects
* the return address to be pushed, thus breaking the 16 byte alignment.
*/
sp -= 7;
/* Add the arguments: */
va_start(ap, argc);