This is the mail archive of the 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]

Sequel to PR40521 -- -g causes GCC to generate .eh_frame


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 mean that (unless -g is given) no .cfi_sections .debug_frame will
be emitted, and thus GAS will default to generating .eh_frame, which is
wrong on ARM.

This problem didn't show up until recently: before GCC trunk's r157575,
flag_dwarf2_cfi_asm has always been set to zero for TARGET_AAPCS_BASED.

I'm confused by the DWARF2_UNWIND_INFO / TARGET_UNWIND_INFO macros (and
their use), plus what exactly is meant to be done in
dwarf2out_do_cfi_asm, thus I'm seeking your help.

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?

Here is another try, but it's not perfect either, see the TODO.

Index: gcc/dwarf2out.c
--- gcc/dwarf2out.c	(revision 157575)
+++ gcc/dwarf2out.c	(working copy)
@@ -180,15 +180,14 @@ dwarf2out_do_cfi_asm (void)
   if ((enc & 0x70) != 0 && (enc & 0x70) != DW_EH_PE_pcrel)
     return false;
-    {
-      return false;
+  if (debug_info_level <= DINFO_LEVEL_TERSE)
+    return false;
-      if (USING_SJLJ_EXCEPTIONS || (!flag_unwind_tables && !flag_exceptions))
-	return false;
+      && (USING_SJLJ_EXCEPTIONS || (!flag_unwind_tables && !flag_exceptions)))
+    return false;
-    }
   saved_do_cfi_asm = true;
   return true;
@@ -772,6 +771,8 @@ dwarf2out_cfi_label (bool force)
   static char label[20];
+  /* TODO: dwarf2out_do_cfi_asm will now return false ifdef TARGET_UNWIND_INFO
+     and no -g specified.  */
   if (!force && dwarf2out_do_cfi_asm ())
       /* In this case, we will be emitting the asm directive instead of

Do we need separate functions, say dwarf2out_do_cfi_asm, and
dwarf2out_emit_unwind -- but isn't that what the DWARF2_UNWIND_INFO /
TARGET_UNWIND_INFO macros are meant for?

Also, I think the documenatation of the latter ones is a bit out of sync
with the code, here is a patch -- is that OK, for starters?

Index: gcc/doc/tm.texi
--- gcc/doc/tm.texi	(revision 157575)
+++ gcc/doc/tm.texi	(working copy)
@@ -8643,13 +8643,9 @@ that it does not contain any extraneous set bits i
 Define this macro to 0 if your target supports DWARF 2 frame unwind
 information, but it does not yet work with exception handling.
 Otherwise, if your target supports this information (if it defines
-or @samp{OBJECT_FORMAT_ELF}), GCC will provide a default definition of 1.
+@samp{INCOMING_RETURN_ADDR_RTX}) and @code{TARGET_UNWIND_INFO} is not defined,
+GCC will provide a default definition of 1.
-If @code{TARGET_UNWIND_INFO} is defined, the target specific unwinder
-will be used in all cases.  Defining this macro will enable the generation
-of DWARF 2 frame debugging information.
 If @code{TARGET_UNWIND_INFO} is not defined, and this macro is defined to 1,
 the DWARF 2 unwinder will be the default exception handling mechanism;
 otherwise, the @code{setjmp}/@code{longjmp}-based scheme will be used by
@@ -8659,6 +8655,9 @@ default.
 Define this macro if your target has ABI specified unwind tables.  Usually
 these will be output by @code{TARGET_UNWIND_EMIT}.
+Defining this macro will inhibit the default of generating DWARF 2 frame
+debugging information, see @code{DWARF2_UNWIND_INFO}.
 @end defmac
 @deftypevr {Target Hook} bool TARGET_UNWIND_TABLES_DEFAULT


Attachment: pgp00000.pgp
Description: PGP signature

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