This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: segfault in sysdep/i386/backtrace.h
- From: "J.C." <jc-nospam at jr-pizarro dot jazztel dot es>
- To: java at gcc dot gnu dot org
- Date: Tue, 20 Feb 2007 07:10:57 +0100
- Subject: Re: segfault in sysdep/i386/backtrace.h
Useful information for you:
main.c:
----------
int f(int x,int y,int z) {
return y;
}
int main(int argc,char *argv[]) {
return f(0,1,2);
}
I use gcc version 3.3.5.
-------------------------------------------------------------
gcc -Os -S main.c:
-------------------------
f:
pushl %ebp
movl %esp, %ebp
movl 12(%ebp), %eax
popl %ebp
ret
main:
pushl %ebp
movl %esp, %ebp
pushl $2
pushl $1
pushl $0
call f
addl $12, %esp
leave
ret
-------------------------------------------------------------
gcc -O3 -S main.c:
-------------------------
f:
pushl %ebp
movl %esp, %ebp
movl 12(%ebp), %eax
popl %ebp
ret
main:
pushl %ebp
movl $1, %eax
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
movl %ebp, %esp
popl %ebp
ret
-------------------------------------------------------------
gcc -O2 -S main.c:
-------------------------
f:
pushl %ebp
movl %esp, %ebp
movl 12(%ebp), %eax
popl %ebp
ret
main:
pushl %ebp
movl $2, %edx
movl %esp, %ebp
subl $24, %esp
movl $1, %eax
andl $-16, %esp
movl %edx, 8(%esp)
movl %eax, 4(%esp)
movl $0, (%esp)
call f
movl %ebp, %esp
popl %ebp
ret
-------------------------------------------------------------
gcc -O1 -S main.c:
-------------------------
f:
pushl %ebp
movl %esp, %ebp
movl 12(%ebp), %eax
popl %ebp
ret
main:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
andl $-16, %esp
movl $2, 8(%esp)
movl $1, 4(%esp)
movl $0, (%esp)
call f
movl %ebp, %esp
popl %ebp
ret
-------------------------------------------------------------
gcc -O0 -S main.c:
-------------------------
f:
pushl %ebp
movl %esp, %ebp
movl 12(%ebp), %eax
popl %ebp
ret
main:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
andl $-16, %esp
movl $0, %eax
subl %eax, %esp
movl $2, 8(%esp)
movl $1, 4(%esp)
movl $0, (%esp)
call f
leave
ret
-------------------------------------------------------------
The pattern "pushl %ebp ; movl %esp, %ebp" doesn't appear with
the -O3 and -O2 options (in other tests, sometimes, -Os too).
It's better don't use -fomit-frame-pointer, use -fno-omit-frame-pointer.
IMHO, the more secure option is -O1 -fno-omit-frame-pointer.
Building a large project (e.g. GCJ from thisiscool) with this secure option
is not possible because of its configure is very complex, there are many
configures of their subpackages!!!.
-------------------------------------------------------------
The "ebp & esp"'s patterns depend of the -O? option.