summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2011-08-19 07:59:49 +0000
committerkettenis <kettenis@openbsd.org>2011-08-19 07:59:49 +0000
commit40e3d44f37812158b1a619108f978b053becf12b (patch)
tree40a6bdfc0df78630a85e80c27997a84c0ba6016c
parentremove error in previous; (diff)
downloadwireguard-openbsd-40e3d44f37812158b1a619108f978b053becf12b.tar.xz
wireguard-openbsd-40e3d44f37812158b1a619108f978b053becf12b.zip
Make sure the stack is properly aligned for using SSE instructions. While
our in-tree compiler will emit code to do this at the start of main(), other compilers might not do that. ok miod@
-rw-r--r--lib/csu/i386/crt0.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/csu/i386/crt0.c b/lib/csu/i386/crt0.c
index d500079e0ef..1fc2de931e7 100644
--- a/lib/csu/i386/crt0.c
+++ b/lib/csu/i386/crt0.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crt0.c,v 1.13 2005/08/04 16:33:05 espie Exp $ */
+/* $OpenBSD: crt0.c,v 1.14 2011/08/19 07:59:49 kettenis Exp $ */
/* $NetBSD: crt0.c,v 1.20 1995/06/03 13:16:08 pk Exp $ */
/*
@@ -56,15 +56,20 @@ __asm(".text\n"
" .globl _start\n"
"_start:\n"
"__start:\n"
-" pushl %ebx #ps_strings\n"
+" movl %esp,%ebp\n"
+" subl $12,%esp # align stack\n"
+" andl $~15,%esp\n"
+" addl $12,%esp\n"
+" pushl %ebx # ps_strings\n"
" pushl %ecx # obj\n"
" pushl %edx # cleanup\n"
-" movl 12(%esp),%eax\n"
-" leal 20(%esp,%eax,4),%ecx\n"
-" leal 16(%esp),%edx\n"
+" movl 0(%ebp),%eax\n"
+" leal 8(%ebp,%eax,4),%ecx\n"
+" leal 4(%ebp),%edx\n"
" pushl %ecx\n"
" pushl %edx\n"
" pushl %eax\n"
+" xorl %ebp,%ebp # mark deepest stack frame\n"
" call ___start ");
void