This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Stack alignment in gcc-ss-20000828
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Stack alignment in gcc-ss-20000828
- From: David Ronis <ronis at ronispc dot chem dot mcgill dot ca>
- Date: Wed, 30 Aug 2000 10:24:46 -0400
- Reply-to: ronis at onsager dot chem dot mcgill dot ca
This bug was pointed out by Steven Johnson some time ago. It's still
seems to be present in gcc-ss-20000828, compiled on an i686-linux-gnu.
I'm running linux-2.2.16 and glibc-2.1.3 and Binutils (2.9.1.0.7) GNU
ld version 2.10.90 (with BFD 2.10.90).
The compiler was built with:
configure flags: --host=i686-pc-linux --prefix=/usr --with-gnu-as
--enable-shared --with-gnu-ld
CFLAGS=CXXFLAGS=BOOT_CFLAGS=-O3 -march=i686 -funroll-loops -ffast-math
-fomit-frame-pointer -fforce-mem
-fforce-addr -malign-jumps=3
-malign-functions=3 -malign-loops=3
(for testsuite results, see
http://gcc.gnu.org/ml/gcc-testresults/2000-08/msg00246.html)
The test code is:
----------------------------stack2.c-----------------------------------
int one(int count)
{
double foobar;
if ((((long) &foobar) & 0x7L)) {
printf("one %d\n", count);
abort();
}
return 1;
}
void blah(int foo)
{
double foobar;
if ((((long) &foobar) & 0x7L)) {
printf("blah\n");
abort();
}
}
int main(void)
{
one(1);
blah(one(2));
return 0;
}
---------------------------------------------------------------------------
Which when compiled as,
/usr/bin/gcc -malign-functions=3 -malign-jumps=3
-mpreferred-stack-boundary=3 -save-temps stack2.c
and run gives:
a.out
one 1
Abort
Here's the .s file (there are no #includes, so the .i file is
essentially the same as the .c):
.file "stack2.c"
.version "01.01"
gcc2_compiled.:
.section .rodata
.LC0:
.string "one %d\n"
.text
.align 8
.globl one
.type one,@function
one:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
leal -8(%ebp), %eax
andl $7, %eax
testl %eax, %eax
je .L3
pushl 8(%ebp)
pushl $.LC0
call printf
addl $8, %esp
call abort
.p2align 3
.L3:
movl $1, %eax
movl %ebp, %esp
popl %ebp
ret
.Lfe1:
.size one,.Lfe1-one
.section .rodata
.LC1:
.string "blah\n"
.text
.align 8
.globl blah
.type blah,@function
blah:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
leal -8(%ebp), %eax
andl $7, %eax
testl %eax, %eax
je .L5
subl $4, %esp
pushl $.LC1
call printf
addl $8, %esp
call abort
.p2align 3
.L5:
movl %ebp, %esp
popl %ebp
ret
.Lfe2:
.size blah,.Lfe2-blah
.align 8
.globl main
.type main,@function
main:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
subl $4, %esp
pushl $1
call one
addl $8, %esp
subl $4, %esp
pushl $2
call one
addl $4, %esp
movl %eax, -4(%ebp)
pushl -4(%ebp)
call blah
addl $8, %esp
movl $0, %eax
movl %ebp, %esp
popl %ebp
ret
.Lfe3:
.size main,.Lfe3-main
.ident "GCC: (GNU) 2.96 20000828 (experimental)"