This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, _eh, dawin] Allow targets to suppress epilogues in _eh frames.
- From: IainS <developer at sandoe-acoustics dot co dot uk>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Richard Henderson <rth at redhat dot com>, mrs at gcc dot gnu dot org
- Date: Fri, 13 Aug 2010 20:50:29 +0100
- Subject: [Patch, _eh, dawin] Allow targets to suppress epilogues in _eh frames.
As discussed off list and in IRC with Richard,
=----=
Some (if not most) targets do not require the function epilogue in
their _eh unwind frames.
In fact, it breaks the darwin unwinder (PR41991) my original
motivation for looking at this.
However, as we went through the discussion it became apparent that
this might have wider application than fixing a darwin bug, in saving
some space in the eh.
What this does is to use the existing DW_CFA_save/restore_state and a
new DW_CFA_GNU_start_epilogue marker to suppress the emitting of
function epilogues - when (a) we're emitting _eh and (b) the target
requests suppression via a hook.
The hook is a bool function to permit targets to choose whether to
emit this data or not at run time rather than config time (the default
hook does nothing).
----
The DW_CFA_GNU_start_epilogue marker is inserted under the
circumstance that an epilogue is detected at the end of a function.
The save/restore markers are not touched and deal with the case that
we are mid-function.
There is a debug print of # DW_CFA_GNU_start_epilogue to show where
we are intercepting in the eh frames and not curtailing the
debug_frames.
I'd particularly welcome someone's eye over what's happening in the
case of section switches (it seems to me that the skipping of mid-
function save/restore is handled OK, but I'm not familiar with that
code - and my main target(s) don't use that facility).
====
This has only been lightly tested on i686/powerpc-darwin9 (regtested
on i686) - but it appears to restore Unwind functionality to the
platform :)
[gcj works again, Yay!]
====
so we get this in the _eh frame:
LECIE1:
.globl _main.eh
_main.eh:
LSFDE1:
.set L$set$1,LEFDE1-LASFDE1
.long L$set$1 # FDE Length
LASFDE1:
.long LASFDE1-EH_frame1 # FDE CIE offset
.long LFB1-. # FDE initial location
.set L$set$2,LFE1-LFB1
<SNIP>
.set L$set$5,LCFI4-LCFI1
.long L$set$5
.byte 0x83 # DW_CFA_offset, column 0x3
.byte 0x3 # uleb128 0x3
.byte 0x4 # DW_CFA_advance_loc4
.set L$set$6,LCFI6-LCFI4
.long L$set$6
# # DW_CFA_GNU_start_epilogue
.align 2
and this in the _debug_frame:
.section __DWARF,__debug_frame,regular,debug
Lsection__debug_frame:
Lframe0:
.set L$set$7,LECIE0-LSCIE0
.long L$set$7 # Length of Common Information Entry
LSCIE0:
<SNIP>
.byte 0x83 # DW_CFA_offset, column 0x3
.byte 0x3 # uleb128 0x3
.byte 0x4 # DW_CFA_advance_loc4
.set L$set$14,LCFI6-LCFI4
.long L$set$14
# # DW_CFA_GNU_start_epilogue
.byte 0xc3 # DW_CFA_restore, column 0x3
.byte 0x4 # DW_CFA_advance_loc4
.set L$set$15,LCFI7-LCFI6
.long L$set$15
.byte 0xc # DW_CFA_def_cfa
.byte 0x4 # uleb128 0x4
.byte 0x4 # uleb128 0x4
.byte 0xc5 # DW_CFA_restore, column 0x5
.align 2
LEFDE2:
=====
thoughts?
Iain
Change notes (not a proper changelog, at this juncture)
include/dwarf2.h : DW_CFA_GNU_start_epilogue new enum.
dwarf2out.c: dwarf_cfi_name() recognize DW_CFA_GNU_start_epilogue
static scope emit_cfa_start_epilogue new var.
add_fde_cfi() : emit a marker for the epilogue start;
dwarf2out_cfi_begin_epilogue (): note that we need to emit the
epilogue start marker when the epilogue is at the end.
dw_cfi_oprnd1_desc (): recognize DW_CFA_GNU_start_epilogue as a no-op.
output_cfi(): print debug message for DW_CFA_GNU_start_epilogue
emit_cfi_or_skip_epilogue (): New.
output_fde () : use emit_cfi_or_skip_epilogue ();
target.def: suppress_eh_epilogue_p (): New ASM Hook.
=== the remainder are the implementation on the darwin side:
gcc/config/darwin.h (TARGET_ASM_SUPPRESS_EH_EPILOGUE_P): New
gcc/config/darwin.c (darwin_asm_suppress_eh_epilogue_p): New.
gcc/config/darwin-protos.h: Declare darwin_asm_suppress_eh_epilogue_p.
========== - ===========
Attachment:
163221-eh-epilogue.txt
Description: Text document