diff options
author | peter <peter@FreeBSD.org> | 2003-12-05 01:36:44 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2003-12-05 01:36:44 +0000 |
commit | b339dae7c21edaa29991d8155aea2eae2979820c (patch) | |
tree | ead4c3d249a6ae029feb046a2af69191e974848f /lib/libc/amd64 | |
parent | a6ef4bf45a2916ba87eaefa05d9bf34139c360c2 (diff) | |
download | FreeBSD-src-b339dae7c21edaa29991d8155aea2eae2979820c.zip FreeBSD-src-b339dae7c21edaa29991d8155aea2eae2979820c.tar.gz |
"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)
Diffstat (limited to 'lib/libc/amd64')
-rw-r--r-- | lib/libc/amd64/gen/makecontext.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/amd64/gen/makecontext.c b/lib/libc/amd64/gen/makecontext.c index 87cf7bf..74eb68a 100644 --- a/lib/libc/amd64/gen/makecontext.c +++ b/lib/libc/amd64/gen/makecontext.c @@ -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); |