Date: 1 Dec 1999 11:48:59 -0000 From: Ville-Pertti Keinonen <will@iki.fi> To: dillon@apollo.backplane.com Cc: bde@zeta.org.au, marcel@scc.nl, current@FreeBSD.ORG Subject: Re: kernel: -mpreferred-stack-boundary=2 ?? Message-ID: <19991201114859.29382.qmail@ns.demophon.com> In-Reply-To: <199912010220.SAA28903@apollo.backplane.com> (message from Matthew Dillon on Tue, 30 Nov 1999 18:20:24 -0800 (PST))
next in thread | previous in thread | raw e-mail | index | archive | help
> It would be better for GCC to force alignment only within those > procedures that need it rather then force all procedures to guarentee > alignment. Then we could have the best of both worlds. Determining whether it is necessary is non-trivial, you would have to go through all local variables after stack slots have been allocated. I'm not certain whether the current code for alignment is useful at all, since it depends on the alignment being set properly before the first compiled function is called. If the exec code in the kernel or the library startup code does not ensure this, it is useless to maintain relative alignment in userland programs. In fact, as far as I can tell, this *is* currently broken (I didn't look too carefully, though, and am too far from my -current box to test it right now). Fixing this in the kernel would be a bit messy as it may vary depending on the sysentvec. Perhaps crt1.c should call main like this (I can't immediately figure out whether the stack pointer should be correctly aligned before the return address is pushed or after the previous stack frame is pushed, this is assuming the former, s/subl/addl/ would change it). asm volatile("andl $~15,%%esp;" "subl $4,%%esp;" "pushl %3;" "pushl %2;" "pushl %1;" "call main;" "movl %%eax,(%%esp);" "call exit" : "rm" (argc), "rm" (argv), "rm" (env)); Possibly followed by something to indicate to gcc that it shouldn't generate code to clean up the stack frame (e.g. for (;;) ; ). 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?19991201114859.29382.qmail>