The unwind info is wrong for any instruction-pointer (IP) in the epilog after
the point at which the stack-pointer has been popped.  For example:

0000000000400758 <func>:
  400758:       48 89 5c 24 d8          mov    %rbx,0xffffffffffffffd8(%rsp)
  40075d:       48 89 6c 24 e0          mov    %rbp,0xffffffffffffffe0(%rsp)
  400762:       4c 89 64 24 e8          mov    %r12,0xffffffffffffffe8(%rsp)
  400767:       4c 89 6c 24 f0          mov    %r13,0xfffffffffffffff0(%rsp)
  40076c:       4c 89 74 24 f8          mov    %r14,0xfffffffffffffff8(%rsp)
  400771:       48 81 ec 28 10 00 00    sub    $0x1028,%rsp
     :
  40081c:       48 81 c4 28 10 00 00    add    $0x1028,%rsp
  400823:       c3                      retq

The unwind-info for this function looks like this:

00000018 00000024 0000001c FDE cie=00000000 pc=00400758..00400824
  DW_CFA_advance_loc: 32 to 00400778
  DW_CFA_def_cfa_offset: 4144
  DW_CFA_offset: r14 at cfa-16
  DW_CFA_offset: r13 at cfa-24
  DW_CFA_offset: r12 at cfa-32
  DW_CFA_offset: r6 at cfa-40
  DW_CFA_offset: r3 at cfa-48

Note that there is no indication that the stack gets restored in the second-last
instruction, hence it is impossible to unwind when IP = 0x400823.

-- 
           Summary: GCC fails to mark stack-popping instruction in unwind-
                    info
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: davidm at hpl dot hp dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-suse-linux
  GCC host triplet: x86_64-suse-linux
GCC target triplet: x86_64-suse-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18749

Reply via email to