This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Omit frame pointer and fix %ebp by default on x86 (take 3)
On Mon, Aug 16, 2004 at 07:26:20PM +0100, Andrew Haley wrote:
> > The simple patch below tweaks the i386 backend, such that we now
> > default to the equivalent of "-fomit-frame-pointer -ffixed-ebp" on
> > 32-bit targets, when optimizing and the user hasn't explicitly
> > specified a frame pointer option, either -fomit-frame-pointer,
> > -fno-omit-frame-pointer or -momit-leaf-frame-pointer.
>
> I don't understand this. What will backtrace() do if there is no
> frame pointer? Will it provide a full call stack trace or not?
Neither do I understand this.
void bar (void);
int foo (void)
{
bar ();
return 0;
}
gcc35 -O2 -m32 -ffixed-ebp -fomit-frame-pointer creates:
foo:
subl $12, %esp
call bar
xorl %eax, %eax
addl $12, %esp
ret
If you call backtrace () in bar (but aren't using
-fasynchronous-unwind-tables so that you can use unwind info
for the backtrace), then assuming if say bar is -fno-omit-frame-pointer,
backtrace will likely segfault (nothing stored the original stack pointer
value on the stack, so there is garbage where backtrace () which uses
the backchain expects stored ebp).
Jakub