Minimal FDE
Yaakov Yaari
YAARI@il.ibm.com
Wed Sep 1 06:51:00 GMT 2004
Alan Modra <amodra@bigpond.net.au> wrote on 01/09/2004 07:22:03:
> On Mon, Aug 30, 2004 at 01:52:58PM -0700, Richard Henderson wrote:
> > On Mon, Aug 30, 2004 at 09:38:10PM +0300, Yaakov Yaari wrote:
> > > How critical are these instructions to the unwinding process?
> >
> > Very.
> >
> > > Is there some minimal/simplified set of instructions that will allow
> > > exceptions to be properly caught?
> >
> > No.
>
> Depending on exactly where you split the function, you probably just
> need to copy the existing FDE, removing the address advances. So, if
> you only split after the prologue, and given a typical existing FDE
> like:
>
> DW_CFA_advance_loc: 4
> DW_CFA_def_cfa_offset: 48
> DW_CFA_advance_loc: 12
> DW_CFA_offset: r30 at cfa-8
> DW_CFA_advance_loc: 16
> DW_CFA_offset: r25 at cfa-28
> DW_CFA_offset_extended_sf: r65 at cfa+4
> DW_CFA_offset: r24 at cfa-32
> DW_CFA_advance_loc: 12
> DW_CFA_offset: r26 at cfa-24
> DW_CFA_advance_loc: 12
> DW_CFA_offset: r27 at cfa-20
> DW_CFA_advance_loc: 16
> DW_CFA_offset: r29 at cfa-12
> DW_CFA_offset: r28 at cfa-16
> DW_CFA_advance_loc: 8
> DW_CFA_offset: r31 at cfa-4
>
> Then, for the piece of function you split out, you'd write
>
> DW_CFA_def_cfa_offset: 48
> DW_CFA_offset: r30 at cfa-8
> DW_CFA_offset: r25 at cfa-28
> DW_CFA_offset_extended_sf: r65 at cfa+4
> DW_CFA_offset: r24 at cfa-32
> DW_CFA_offset: r26 at cfa-24
> DW_CFA_offset: r27 at cfa-20
> DW_CFA_offset: r29 at cfa-12
> DW_CFA_offset: r28 at cfa-16
> DW_CFA_offset: r31 at cfa-4
>
> The tedious side of this is writing a DWARF2 interpreter to parse the
> existing FDE, but I guess you can find a working example in the gcc
> sources. ;-) It's probably not a good idea to try to write an
> interpreter that just handles the minimal set of DWARF2 opcodes used by
> a particular gcc target; I've had one request from someone inside IBM
> for help writing .eh_frame info for some assembler code. The required
> .eh_frame info looked quite different to that generated by gcc.
>
> --
> Alan Modra
> IBM OzLabs - Linux Technology Centre
I also thought about replicating the original FDE for each disjoint chunk
of the function. However I assumed that the specified nonvolatile registers
are restored by accessing the stack directly, without going through the
prolog, essentially, ignoring the advance instructions.
If advance instructions can be removed, as you suggest, it means the
interpreter does not need the actual prolog instructions in order to have a
proper restore. In this case why can't we just leave them and get the same
effect?
Yaakov Yaari
IBM HRL
More information about the Gcc
mailing list