https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91763

--- Comment #1 from Ian Lance Taylor <ian at airs dot com> ---
I can recreate this on sparc-sun-solaris2.11 using gas.2.30.  It works using
the native assembler.  I'm using the native linker.

It works if I #ifdef out these lines in lto-opts.c:

#if 0
  /* If debug info is enabled append -g.  */
  if (debug_info_level > DINFO_LEVEL_NONE)
    append_to_collect_gcc_options (&temporary_obstack, &first_p, "-g");
#endif

The failure is that the stack unwinder is unable to find any exception frame
information.

Working executable:

> readelf -S --wide foo | grep eh
  [ 2] .eh_frame_hdr     PROGBITS        00010108 000108 000174 00   A  0   0 
4
  [61] .eh_frame         PROGBITS        00025120 005120 000460 00  WA  0   0 
4

Failing executable:

  [ 2] .eh_frame_hdr     PROGBITS        00010108 000108 00001c 00   A  0   0 
4
  [61] .eh_frame         PROGBITS        00024fc8 004fc8 000044 00  WA  0   0 
4

Looking at foo.ltrans0.ltrans.o; working case:

  [113] .eh_frame         PROGBITS        00000000 0016f4 00041c 00  WA  0   0 
4
  [114] .rela.eh_frame    RELA            00000000 004198 000204 0c   I 115 113
 4


Failing case has no eh sections at all in foo.ltrans0.ltrans.o.

The failing case has 10 .debug and .rela.debug sections.  The working case has
no such sections.

So somehow in the failing case we are getting debug sections and no eh
sections.  In the working case we are getting eh sections and no debug
sections.

Looking at foo.ltrans0.s, the only change in .cfi directives is that in the
failing case there is a ".cfi_sections .debug_frame" directive.  That directive
tells gas to emit frame information into .debug_frame but not .eh_frame.

So the problem is from these lines in dwarf2out_assembly_start:

  if (HAVE_GAS_CFI_SECTIONS_DIRECTIVE
      && dwarf2out_do_cfi_asm ()
      && !dwarf2out_do_eh_frame ())
    fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n");

The fix may be to also pass -fexceptions/-funwind-tables/-fnon-call-exceptions
to lto.  I'll give that a try.

Reply via email to