Missalignment of the stack on solaris x86.

Mathias Froehlich frohlich@na.uni-tuebingen.de
Wed Jul 14 07:25:00 GMT 1999


Hi egcs-Team!

I have read about the new feature of gcc-2.95 that it should now
correctly align doubles on the stack. As far I understand gcc
adjusts the size of the stackframe to be a multiple of 16bytes
(depending on the flag -mpreferred-stack-bound=...). This requires
that on entry to main the stack has o be correctly aligned. Linux
seems to call main with an aligned stack. But Solaris 2.6_x86 does
not! This is illustrated with a short test program:

-----------------------------------------------------------------
#include <stdio.h>

int main(void)
{
  double a;
  printf("Address of double a is: %p\n", &a);
  if ((int)(&a) & 7)
    printf("It is not correctly aligned!\n");
}
-----------------------------------------------------------------

Which gives the following output:

na12:/home/frohlich $ gcc -V2.95 -O3 -malign-double tst.c -o tst
na12:/home/frohlich $ ./tst  
Address of double a is: 80473f8
na12:/home/frohlich $ export SOMETIMES='doubles are not aligned'
na12:/home/frohlich $ ./tst
Address of double a is: 80473d4
It is not correctly aligned!
na12:/home/frohlich $ 

Where you can see that the stack alignment depends on something like
the local environment of a process!

Since gcc has it's own startup files, it will be very easy to align
the stack before main is called. Could you please implement this?

    Regards,

        Mathias Froehlich

-- 
Mathias Fr"ohlich              e-mail: frohlich@na.uni-tuebingen.de
Institut f"ur Mathematik, Universit"at T"ubingen, D-72076 T"ubingen


More information about the Gcc-bugs mailing list