diff mbox

[alpha] : Define TARGET_UNWIND_TABLES_DEFAULT

Message ID CAFULd4bNMtNy56TLeGXoDB2gu=K4wvY88hPzU_noion75eDopw@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak July 24, 2014, 4:40 p.m. UTC
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.
diff mbox

Patch

Index: config/alpha/elf.h
===================================================================
--- config/alpha/elf.h	(revision 212920)
+++ config/alpha/elf.h	(working copy)
@@ -126,6 +126,10 @@ 
   "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
    %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
 
+/* This variable should be set to 'true' if the target ABI requires
+   unwinding tables even when exceptions are not used.  */
+#define TARGET_UNWIND_TABLES_DEFAULT true
+
 /* Select a format to encode pointers in exception handling data.  CODE
    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
    true if the symbol may be affected by dynamic relocations.