Sequel to PR40521 -- -g causes GCC to generate .eh_frame
Daniel Jacobowitz
dan@codesourcery.com
Tue Mar 30 15:33:00 GMT 2010
On Thu, Mar 25, 2010 at 02:34:26PM +0100, Thomas Schwinge wrote:
> Hello!
>
> Here is a sequel to PR40521 -- -g causes GCC to generate .eh_frame.
>
> On arm-none-linux-gnueabi, if -fexceptions /
> -fasynchronous-unwind-tables / -funwind-tables is in effect, GCC will
> now *always* emit CFI statements -- and .cfi_sections .debug_frame
> additionally *only* if -g is specified.
This is IMO a serious problem; it generates a lot of extra data for
C++ on ARM (a primary platform).
I couldn't figure out the existing logic, so I've simplified it and
attached another possible solution (untested). It does have some
related changes in behavior, because the existing checks are
inconsistent; some are:
flag_unwind_tables || (flag_exceptions && ! USING_SJLJ_EXCEPTIONS),
Others are:
! USING_SJLJ_EXCEPTIONS && (flag_unwind_tables || flag_exceptions)
> Defining gcc/config/arm/arm.h:DWARF2_UNWIND_INFO to 0 instead of 1 has
> the desired effect, but I'm not really sure that is correct to do?
By comparison with IA64, I think this is (surprisingly, to me) the
right solution. In fact, delete the definition. Then non-EABI ARM
configurations will allow DWARF2_UNWIND_INFO via defaults.h.
Thomas, want to give this a spin?
--
Daniel Jacobowitz
CodeSourcery
2010-03-30 Daniel Jacobowitz <dan@codesourcery.com>
* dwarf2out.c (NEED_UNWIND_TABLES): Define.
(dwarf2out_do_frame, dwarf2out_do_cfi_asm, dwarf2out_begin_prologue)
(dwarf2out_frame_finish): Use NEED_UNWIND_TABLES.
(dwarf2out_assembly_start): Likewise. Assert if we are generating
DWARF2 unwind tables when TARGET_UNWIND_INFO is defined.
* config/arm/arm.h (DWARF2_UNWIND_INFO): Delete definition.
Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 157825)
+++ dwarf2out.c (working copy)
@@ -124,6 +124,9 @@ int vms_file_stats_name (const char *, l
# endif
#endif
+#define NEED_UNWIND_TABLES \
+ (flag_unwind_tables || (flag_exceptions && ! USING_SJLJ_EXCEPTIONS))
+
/* Map register numbers held in the call frame info that gcc has
collected using DWARF_FRAME_REGNUM to those that should be output in
.debug_frame and .eh_frame. */
@@ -147,9 +150,7 @@ dwarf2out_do_frame (void)
|| write_symbols == VMS_AND_DWARF2_DEBUG
|| DWARF2_FRAME_INFO || saved_do_cfi_asm
#ifdef DWARF2_UNWIND_INFO
- || (DWARF2_UNWIND_INFO
- && (flag_unwind_tables
- || (flag_exceptions && ! USING_SJLJ_EXCEPTIONS)))
+ || (DWARF2_UNWIND_INFO && NEED_UNWIND_TABLES)
#endif
);
}
@@ -185,7 +186,7 @@ dwarf2out_do_cfi_asm (void)
#ifdef TARGET_UNWIND_INFO
return false;
#else
- if (USING_SJLJ_EXCEPTIONS || (!flag_unwind_tables && !flag_exceptions))
+ if (!NEED_UNWIND_TABLES)
return false;
#endif
}
@@ -3905,8 +3906,7 @@ dwarf2out_begin_prologue (unsigned int l
/* ??? current_function_func_begin_label is also used by except.c
for call-site information. We must emit this label if it might
be used. */
- if ((! flag_exceptions || USING_SJLJ_EXCEPTIONS)
- && ! dwarf2out_do_frame ())
+ if (! NEED_UNWIND_TABLES && ! dwarf2out_do_frame ())
return;
#else
if (! dwarf2out_do_frame ())
@@ -4066,7 +4066,7 @@ dwarf2out_frame_finish (void)
#ifndef TARGET_UNWIND_INFO
/* Output another copy for the unwinder. */
- if (! USING_SJLJ_EXCEPTIONS && (flag_unwind_tables || flag_exceptions))
+ if (NEED_UNWIND_TABLES)
output_call_frame_info (1);
#endif
}
@@ -20644,9 +20644,11 @@ dwarf2out_assembly_start (void)
{
if (HAVE_GAS_CFI_SECTIONS_DIRECTIVE && dwarf2out_do_cfi_asm ())
{
-#ifndef TARGET_UNWIND_INFO
- if (USING_SJLJ_EXCEPTIONS || (!flag_unwind_tables && !flag_exceptions))
+#ifdef TARGET_UNWIND_INFO
+ /* We should only be generating .debug_frame. */
+ gcc_assert (!NEED_UNWIND_TABLES);
#endif
+ if (!NEED_UNWIND_TABLES)
fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n");
}
}
Index: config/arm/arm.h
===================================================================
--- config/arm/arm.h (revision 157391)
+++ config/arm/arm.h (working copy)
@@ -918,9 +918,6 @@ extern int arm_structure_size_boundary;
#define MUST_USE_SJLJ_EXCEPTIONS 1
#endif
-/* We can generate DWARF2 Unwind info, even though we don't use it. */
-#define DWARF2_UNWIND_INFO 1
-
/* Use r0 and r1 to pass exception handling information. */
#define EH_RETURN_DATA_REGNO(N) (((N) < 2) ? N : INVALID_REGNUM)
More information about the Gcc-patches
mailing list