diff options
author | deischen <deischen@FreeBSD.org> | 2004-12-05 21:22:08 +0000 |
---|---|---|
committer | deischen <deischen@FreeBSD.org> | 2004-12-05 21:22:08 +0000 |
commit | 5a270f5b3cb862cbfa3621d83d2738b6b11366d2 (patch) | |
tree | 5d074d824ca292c1fc73f768288a5a169e494580 /lib/libc | |
parent | 70d525536e5db056decb50c63951f53f5a698d52 (diff) | |
download | FreeBSD-src-5a270f5b3cb862cbfa3621d83d2738b6b11366d2.zip FreeBSD-src-5a270f5b3cb862cbfa3621d83d2738b6b11366d2.tar.gz |
Make sure the first argument to the user function is 16-byte aligned.
Submitted by: tegge
Diffstat (limited to 'lib/libc')
-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 1154459..167cb12 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; /* |