1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-24 16:27:37 +01:00
libunwind-eh_elf/src
Ulrich Weigand c56fb8f99e ppc64: Fix serious regression (many crashes in test suite)
A recent commit added code to override the unwind location for the
TOC pointer register r2:

    unsigned int *inst = (unw_word_t*)c->dwarf.ip;
    if (*inst == (0xE8410000 + 24)) {
      // @plt call, restoring R2 from CFA+24
      c->dwarf.loc[UNW_PPC64_R2] = DWARF_LOC(c->dwarf.cfa + 24, 0);
    }

It is correct that such code is needed, since DWARF CFI does not
describe the unwind location for r2 on PowerPC.  However, this
particular bit of code has a number of issues, which are fixed
in this patch.

First of all, the location CFA+24 is correct only for the ELFv2
ABI.  In the ELFv1 ABI, the TOC location is actually CFA+40.

More problematically, attempting to read the current instruction
by just dereferencing the address in c->dwarf.ip is wrong, and
may often lead to crashes.  In particular:

- During remote unwinding, this is always wrong since we're in
  the wrong address space.  I've used the fetch32 helper from
  remote.h to use the proper access_mem under the covers.

- c->dwarf.ip may be NULL if we've reached the end-of-stack.
  I've fixed this by moving the c->dwarf.ip == 0 check down
  to after unwinding (instead of before), just like all other
  platforms do.

- Even so, c->dwarf.ip may point to some random location if
  we've gotten confused during unwinding earlier.  One likely
  cause for such confusion is that we did not find DWARF CFI
  for some earlier frame and attempted to use the stack
  backchain.  The problem is that this code currently claims
  all registers remain unchanges in such a frame, which is
  generally wrong.  In particular if the function actually
  saves and modifies r31, and this is used as frame pointer
  by a later frame, things will likely go quite wrong.  While
  it is not really possibly to completely fix this, I've at
  least marked all registers as unavailable after unwinding
  a frame via stack backchain.

Tested on powerpc64-linux and powerpc64le-linux.  The patch fixes
about a dozen test cases that were crashing before.

Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2015-12-06 11:10:10 -08:00
..
aarch64 aarch64: fix wrong big_endian flag in aarch64_be case 2014-12-03 23:28:07 -08:00
arm arm: Validate memory before access 2015-06-07 12:17:40 -07:00
coredump One time whitespace fixup. 2014-09-27 09:47:23 -07:00
dwarf Add an option to have start_ip_offset be relative to start_ip 2015-09-15 12:18:30 -07:00
hppa One time whitespace fixup. 2014-09-27 09:47:23 -07:00
ia64 One time whitespace fixup. 2014-09-27 09:47:23 -07:00
mi Add an option to have start_ip_offset be relative to start_ip 2015-09-15 12:18:30 -07:00
mips Stack-unwinding through signal frames on mips 2015-04-02 11:20:33 -07:00
ppc powerpc64 implementation 2015-09-07 18:08:26 -07:00
ppc32 One time whitespace fixup. 2014-09-27 09:47:23 -07:00
ppc64 ppc64: Fix serious regression (many crashes in test suite) 2015-12-06 11:10:10 -08:00
ptrace One time whitespace fixup. 2014-09-27 09:47:23 -07:00
setjmp One time whitespace fixup. 2014-09-27 09:47:23 -07:00
sh One time whitespace fixup. 2014-09-27 09:47:23 -07:00
tilegx Add TileGx platform support to libunwind. 2014-09-08 16:21:53 -04:00
unwind One time whitespace fixup. 2014-09-27 09:47:23 -07:00
x86 One time whitespace fixup. 2014-09-27 09:47:23 -07:00
x86_64 Add an option to have start_ip_offset be relative to start_ip 2015-09-15 12:18:30 -07:00
elf32.c Do nothing of UNW_REMOTE_ONLY is defined. 2003-02-15 03:10:30 +00:00
elf32.h One time whitespace fixup. 2014-09-27 09:47:23 -07:00
elf64.c Do nothing of UNW_REMOTE_ONLY is defined. 2003-02-15 03:10:30 +00:00
elf64.h One time whitespace fixup. 2014-09-27 09:47:23 -07:00
elfxx.c One time whitespace fixup. 2014-09-27 09:47:23 -07:00
elfxx.h One time whitespace fixup. 2014-09-27 09:47:23 -07:00
libunwind-generic.pc.in Add Cflags keyword to pkg-config metadata files 2013-08-26 05:40:19 -07:00
Makefile.am Merge branch 'fast-stack-trace-arm' of https://github.com/fillexen/libunwind 2014-09-20 08:09:55 -07:00
os-freebsd.c One time whitespace fixup. 2014-09-27 09:47:23 -07:00
os-hpux.c One time whitespace fixup. 2014-09-27 09:47:23 -07:00
os-linux.c One time whitespace fixup. 2014-09-27 09:47:23 -07:00
os-linux.h One time whitespace fixup. 2014-09-27 09:47:23 -07:00
os-qnx.c One time whitespace fixup. 2014-09-27 09:47:23 -07:00