This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Minimal FDE


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]