Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 02 Dec 1999 12:28:39 +0100
From:      Marcel Moolenaar <marcel@scc.nl>
To:        Ville-Pertti Keinonen <will@iki.fi>
Cc:        current@freebsd.org, dillon@apollo.backplane.com, bde@zeta.org.au
Subject:   Re: kernel: -mpreferred-stack-boundary=2 ??
Message-ID:  <384657E7.B3E461D5@scc.nl>
References:  <19991202094037.4079.qmail@ns.demophon.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Ville-Pertti Keinonen wrote:

> +++ crt1.c      1999/12/02 09:02:05
> @@ -92,7 +92,17 @@
>      monstartup(&eprol, &etext);
>  #endif
>      _init();
> -    exit( main(argc, argv, env) );
> +    asm volatile("andl $~15,%%esp;"
> +                "addl $4,%%esp;"
> +                "pushl %2;"
> +                "pushl %1;"
> +                "pushl %0;"
> +                "call main;"
> +                "movl %%eax,(%%esp);"
> +                "call exit"
> +                : : "rm" (argc), "rm" (argv), "rm" (env));

AFAICT, it's enough to just align the stack before doing anything else.
In this case it means aligning the stack somewhere before
(exit(main(...)). gcc maintains proper alignment on an aligned stack.
Maybe alignment can even be done in the kernel...

-- 
Marcel Moolenaar                        mailto:marcel@scc.nl
SCC Internetworking & Databases           http://www.scc.nl/
The FreeBSD project                mailto:marcel@FreeBSD.org


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?384657E7.B3E461D5>