From owner-freebsd-current Wed Dec 1 3:50:42 1999 Delivered-To: freebsd-current@freebsd.org Received: from ns.demophon.com (ns.demophon.com [193.65.70.13]) by hub.freebsd.org (Postfix) with SMTP id 8016314E80 for ; Wed, 1 Dec 1999 03:50:39 -0800 (PST) (envelope-from will@ns.demophon.com) Received: (qmail 29385 invoked by uid 1003); 1 Dec 1999 11:48:59 -0000 Date: 1 Dec 1999 11:48:59 -0000 Message-ID: <19991201114859.29382.qmail@ns.demophon.com> From: Ville-Pertti Keinonen To: dillon@apollo.backplane.com Cc: bde@zeta.org.au, marcel@scc.nl, current@FreeBSD.ORG In-reply-to: <199912010220.SAA28903@apollo.backplane.com> (message from Matthew Dillon on Tue, 30 Nov 1999 18:20:24 -0800 (PST)) Subject: Re: kernel: -mpreferred-stack-boundary=2 ?? Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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