[PATCH] Omit frame pointer and fix %ebp by default on x86 (take 3)
Mon Aug 16 18:45:00 GMT 2004
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)
gcc35 -O2 -m32 -ffixed-ebp -fomit-frame-pointer creates:
subl $12, %esp
xorl %eax, %eax
addl $12, %esp
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).
More information about the Gcc-patches