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

[PATCH, alpha]: Define TARGET_UNWIND_TABLES_DEFAULT


Hello!

Adding -g to compile flags breaks unwinding on alpha due to
non-existent FDE entries. This is illustrated by compiling a hello.c
program:

w/o -g:

$gcc -O2 -c hello.c

$ objdump --dwarf=frames-interp hello.o

hello.o:     file format elf64-alpha

Contents of the .eh_frame section:

00000000 0000000000000010 00000000 CIE "zR" cf=4 df=-8 ra=26
   LOC           CFA
0000000000000000 r30+0

00000014 0000000000000018 00000018 FDE cie=00000000
pc=0000000000000000..000000000000003c
   LOC           CFA      ra
0000000000000000 r30+0    u
000000000000001c r30+16   c-16

w/ -g:

$gcc -O2 -g -c hello.c

$ objdump --dwarf=frames-interp hello.o

hello.o:     file format elf64-alpha

Contents of the .debug_frame section:

00000000 000000000000000c ffffffff CIE "" cf=4 df=-8 ra=26
   LOC           CFA
0000000000000000 r30+0

00000010 0000000000000024 00000000 FDE cie=00000000
pc=0000000000000000..000000000000003c
   LOC           CFA      ra
0000000000000000 r30+0    u
000000000000000c r30+16   u
000000000000001c r30+16   c-16
0000000000000038 r30+0    u

Please note that FDE moved from .eh_frame section to .debug_frame.

The assembler generates .eh_frame data by itself (please see
gas/config/tc-alpha.c, alpha_elf_md_end), unless there is existing
unwind info, or there are .cfi directives:

--cut here--
  /* If someone has generated the unwind info themselves, great.  */
  if (bfd_get_section_by_name (stdoutput, ".eh_frame") != NULL)
    return;

  /* ??? In theory we could look for functions for which we have
     generated unwind info via CFI directives, and those we have not.
     Those we have not could still get their unwind info from here.
     For now, do nothing if we've seen any CFI directives.  Note that
     the above test will not trigger, as we've not emitted data yet.  */
  if (all_fde_data != NULL)
    return;
--cut here--

However, when -g is in effect, .cfi_sections switches to .debug_frame.
Emitted .cfi directives go to .debug_frame, and nobody generates
.eh_frame in this case.

This problem can be solved by defining TARGET_UNWIND_TABLES_DEFAULT to
true. This way, the compiler will always generate precise unwind info
by itself, with and without -g. Since the assembler always emits
unwind data, setting TARGET_UNWIND_TABLES_DEFAULT also seems correct.

The patch also fixes following go testsuite failure:

FAIL: go.test/test/nilptr2.go execution,  -O2 -g

where missing FDE in libc's  _wordcopy_fwd_aligned at wordcopy.c broke
unwinding.

2014-07-24  Uros Bizjak  <ubizjak@gmail.com>

    * config/alpha/elf.h: Define TARGET_UNWIND_TABLES_DEFAULT.

Patch was bootstrapped and regression tested on alphaev68-pc-linux-gnu.

Patch was committed to mainline SVN and will be backported to release branches.

Uros.

Attachment: a.diff.txt
Description: Text document


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