This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: alignment bug in gcc i386 crtfastmath.c


On Sat, Mar 18, 2006 at 11:58:17AM -0500, Andrew Pinski wrote:
> > 
> > On Sat, Mar 18, 2006 at 11:45:49AM -0500, Andrew Pinski wrote:
> > > 
> > > On Mar 18, 2006, at 11:43 AM, Lu, Hongjiu wrote:
> > > 
> > > >Can you try this patch?
> > > >
> > > >Since __attribute__ ((aligned (XX))) doesn't work for stack variables,
> > > >is there a gcc option to warn it?
> > > 
> > > Actually that is not true, it does work in general except when the stack
> > > is required only to be not 16byte aligned.
> > > I know on powerpc-darwin, it works for sure since there it is required 
> > > to
> > > be 16byte aligned.
> > 
> > I seem to remember that gcc doesn't do stack alignment adjustment and
> > assumes the OS to set it up correctly. I can get segfault on Linux/ia32
> > with -Os in crtfastmath.c.
> 
> Let me correct what I had meant, aligned does work on stack variables
> when the aligned is smaller or equal to the required stack alignment
> that the compiler can guaranteed.  So don't say it does not work in
> general because that is not true.
> 

Here is an example with gcc 4.2:

[hjl@gnu-13 align-3]$ make
/usr/gcc-4.2/bin/gcc -m32 -msse2 -march=i386 -mtune=generic -o foo.o -O
-Wall -c foo.c
/usr/gcc-4.2/bin/gcc -m32 -msse2 -march=i386 -mtune=generic -o y.o -Os
-c y.c
/usr/gcc-4.2/bin/gcc -m32 -msse2 -march=i386 -mtune=generic   foo.o y.o
-o foo
./foo
Is 16 bytes aligned: 512, 0xffffd6bc, 0
make: *** [all] Segmentation fault
[hjl@gnu-13 align-3]$

What is the the required stack alignment that the compiler can
guaranteed when not all files are compiled at the same time with
the same option by the same person? Basically, compiler doesn't
really know for sure what the stack alignment at the function
entry point is.


H.J.

Attachment: bug.tar.gz
Description: GNU Zip compressed data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]