This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Question about -mpreferred-stack-boundary
- To: "Geert Bosch" <bosch at gnat dot com>
- Subject: Re: Question about -mpreferred-stack-boundary
- From: Andreas Jaeger <aj at suse dot de>
- Date: 03 Feb 2001 20:18:46 +0100
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>,"Jens Wallner" <wallner at ims dot uni-hannover dot de>,"Ulrich Drepper" <drepper at cygnus dot com>
- References: <20010203150216.AE57B34D82@nile.gnat.com>
"Geert Bosch" <bosch@gnat.com> writes:
> On 03 Feb 2001 14:56:06 +0100, Andreas Jaeger wrote:
>
> I should have descripted the problem in more detail: glibc's startup
> code aligns the stack to 32 bytes - and then calls a function. Now,
> if you tell me that the stack has to be aligned (e.g. to 32 bytes)
> *after* the push of the return address, then glibc is wrong - but if
> it has to be aligned *before* the push of the return address, we might
> have a bug in GCC.
>
> I was going to raise this issue, but decided not to make my previous
> mail more confusing than necessary :-) As I described, the main reason
> for using the preferred stack boundary is to (try to) have arguments
> that are passed by value on the stack properly aligned.
>
> Consider a function f that takes two long float values as arguments
> x and y. Long floats are passed by value and reading them from addresses
> that are not 8-byte aligned is costly. The i386 ABI requires the stack
> to look as follows when control is transferred to f:
>
> ....
> 16(%esp) y (hi)
> 12(%esp) y (lo)
> 8(%esp) x (hi)
> 4(%esp) x (lo)
> 0(%esp) [return address]
>
> So you'd like 4(%esp) to be 8-byte aligned. So %esp should be 8-byte
> aligned before calling the function.
Ok, then glibc is correct and it seems we've found a bug in GCC. I'm
currently bootstrapping GCC with a patch that might solve this.
Btw. glibc only aligns the code to 8 bytes, I'll propose to change
this.
Thanks,
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj