diff options
author | Daniel Eischen <deischen@FreeBSD.org> | 2004-12-05 21:22:08 +0000 |
---|---|---|
committer | Daniel Eischen <deischen@FreeBSD.org> | 2004-12-05 21:22:08 +0000 |
commit | 6c68cb596e4f7f9988961d03ace576f6596a5708 (patch) | |
tree | 5d074d824ca292c1fc73f768288a5a169e494580 /lib | |
parent | 405a104ec0a799dac97be911be4fb822f365a467 (diff) | |
download | src-6c68cb596e4f7f9988961d03ace576f6596a5708.tar.gz src-6c68cb596e4f7f9988961d03ace576f6596a5708.zip |
Make sure the first argument to the user function is 16-byte aligned.
Submitted by: tegge
Notes
Notes:
svn path=/head/; revision=138403
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/i386/gen/makecontext.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libc/i386/gen/makecontext.c b/lib/libc/i386/gen/makecontext.c index 1154459470d2..167cb12893dc 100644 --- a/lib/libc/i386/gen/makecontext.c +++ b/lib/libc/i386/gen/makecontext.c @@ -93,7 +93,7 @@ __makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...) * * _ctx_start() - context start wrapper * start() - user start routine - * arg1 + * arg1 - first argument, aligned(16) * ... * argn * ucp - this context, %ebp points here @@ -110,15 +110,17 @@ __makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...) * (uc_link != 0) or exit the program (uc_link == 0). */ stack_top = (char *)(ucp->uc_stack.ss_sp + - ucp->uc_stack.ss_size - sizeof(double)); - stack_top = (char *)ALIGN(stack_top); + ucp->uc_stack.ss_size - sizeof(intptr_t)); /* * Adjust top of stack to allow for 3 pointers (return * address, _ctx_start, and ucp) and argc arguments. - * We allow the arguments to be pointers also. + * We allow the arguments to be pointers also. The first + * argument to the user function must be properly aligned. */ - stack_top = stack_top - (sizeof(intptr_t) * (3 + argc)); + stack_top = stack_top - (sizeof(intptr_t) * (1 + argc)); + stack_top = (char *)((unsigned)stack_top & ~15); + stack_top = stack_top - (2 * sizeof(intptr_t)); argp = (intptr_t *)stack_top; /* |