PATCH: -fomit-frame-pointer and exceptions or setjmp/longjmp
Denis Zaitsev
zzz@cd-club.ru
Mon Jul 1 16:10:00 GMT 2002
The problem (i386): GCC generates bad DWARF call frame info, when it
works with -fomit-frame-pointer, so it becomes impossible to unwind
the call frame correctly. This makes, for example, any thrown
exception uncatchable. (This problem has already been discussed here.)
The place, where the call frame info goes astray, is loading of the
PIC register. It consists of a call for a "just after the call" point
and then pop pc's value there. The call must be considered just as it
would be push(pc), but instead it asumed to be a usual call, which
leaves the stack pointer the same after return. And it is an error.
The patch below cures the problem. Please, apply it. It is for
3.0.4, but does for 3.1 too.
--- gcc/config/i386/i386.c.orig Fri Nov 30 02:48:41 2001
+++ gcc/config/i386/i386.c Tue Jul 2 03:32:29 2002
@@ -1877,7 +1877,7 @@
void
load_pic_register ()
{
- rtx gotsym, pclab;
+ rtx gotsym, pclab, getpc;
gotsym = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
@@ -1892,7 +1892,15 @@
pclab = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ());
}
- emit_insn (gen_prologue_get_pc (pic_offset_table_rtx, pclab));
+ getpc = emit_insn (gen_prologue_get_pc (pic_offset_table_rtx, pclab));
+ RTX_FRAME_RELATED_P (getpc) = 1;
+ REG_NOTES (getpc) = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
+ gen_rtx_SET (VOIDmode,
+ stack_pointer_rtx,
+ gen_rtx_PLUS (SImode,
+ stack_pointer_rtx,
+ GEN_INT (-UNITS_PER_WORD))),
+ REG_NOTES (getpc));
if (! TARGET_DEEP_BRANCH_PREDICTION)
emit_insn (gen_popsi1 (pic_offset_table_rtx));
More information about the Gcc
mailing list