diff options
| author | Jan Kratochvil <[email protected]> | 2013-12-15 18:56:17 +0100 |
|---|---|---|
| committer | Jan Kratochvil <[email protected]> | 2013-12-15 18:56:17 +0100 |
| commit | 5cbf42aaf47195e2c41171786371d55b253a7667 (patch) | |
| tree | 8def24d1108f287998fadbdc6348a925ce3d72ec /backends | |
| parent | 63572f42b04e1c3b752b113810ec642121c8090e (diff) | |
unwinder: ppc and ppc64
Signed-off-by: Jan Kratochvil <[email protected]>
Diffstat (limited to 'backends')
| -rw-r--r-- | backends/ChangeLog | 11 | ||||
| -rw-r--r-- | backends/Makefile.am | 4 | ||||
| -rw-r--r-- | backends/ppc64_init.c | 4 | ||||
| -rw-r--r-- | backends/ppc_corenote.c | 2 | ||||
| -rw-r--r-- | backends/ppc_init.c | 4 | ||||
| -rw-r--r-- | backends/ppc_initreg.c | 114 |
6 files changed, 136 insertions, 3 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog index 787223d8..dc960485 100644 --- a/backends/ChangeLog +++ b/backends/ChangeLog @@ -1,3 +1,14 @@ +2013-12-15 Jan Kratochvil <[email protected]> + + unwinder: ppc and ppc64 + * Makefile.am (ppc_SRCS, ppc64_SRCS): Add ppc_initreg.c. + * ppc64_init.c (ppc64_init): Initialize also frame_nregs, + set_initial_registers_tid and dwarf_to_regno. + * ppc_corenote.c (PRSTATUS_REGSET_ITEMS) <nip>: Set PC_REGISTER. + * ppc_init.c (ppc64_init): Initialize also frame_nregs, + set_initial_registers_tid and dwarf_to_regno. + * ppc_initreg.c: New file. + 2013-11-25 Petr Machata <[email protected]> * Makefile.am (modules): Add aarch64. diff --git a/backends/Makefile.am b/backends/Makefile.am index 9bca9941..4752a643 100644 --- a/backends/Makefile.am +++ b/backends/Makefile.am @@ -95,13 +95,13 @@ am_libebl_sparc_pic_a_OBJECTS = $(sparc_SRCS:.c=.os) ppc_SRCS = ppc_init.c ppc_symbol.c ppc_retval.c ppc_regs.c \ ppc_corenote.c ppc_auxv.c ppc_attrs.c ppc_syscall.c \ - ppc_cfi.c + ppc_cfi.c ppc_initreg.c libebl_ppc_pic_a_SOURCES = $(ppc_SRCS) am_libebl_ppc_pic_a_OBJECTS = $(ppc_SRCS:.c=.os) ppc64_SRCS = ppc64_init.c ppc64_symbol.c ppc64_retval.c \ ppc64_corenote.c ppc_regs.c ppc_auxv.c ppc_attrs.c ppc_syscall.c \ - ppc_cfi.c + ppc_cfi.c ppc_initreg.c libebl_ppc64_pic_a_SOURCES = $(ppc64_SRCS) am_libebl_ppc64_pic_a_OBJECTS = $(ppc64_SRCS:.c=.os) diff --git a/backends/ppc64_init.c b/backends/ppc64_init.c index 14358754..05f8898c 100644 --- a/backends/ppc64_init.c +++ b/backends/ppc64_init.c @@ -65,6 +65,10 @@ ppc64_init (elf, machine, eh, ehlen) HOOK (eh, core_note); HOOK (eh, auxv_info); HOOK (eh, abi_cfi); + /* gcc/config/ #define DWARF_FRAME_REGISTERS. */ + eh->frame_nregs = (114 - 1) + 32; + HOOK (eh, set_initial_registers_tid); + HOOK (eh, dwarf_to_regno); return MODVERSION; } diff --git a/backends/ppc_corenote.c b/backends/ppc_corenote.c index 707a3954..9ac88712 100644 --- a/backends/ppc_corenote.c +++ b/backends/ppc_corenote.c @@ -123,7 +123,7 @@ static const Ebl_Register_Location spe_regs[] = { \ .name = "nip", .type = ELF_T_ADDR, .format = 'x', \ .offset = offsetof (struct EBLHOOK(prstatus), pr_reg[32]), \ - .group = "register" \ + .group = "register", .pc_register = true \ }, \ { \ .name = "orig_gpr3", .type = TYPE_LONG, .format = 'd', \ diff --git a/backends/ppc_init.c b/backends/ppc_init.c index 004c6016..ad92765c 100644 --- a/backends/ppc_init.c +++ b/backends/ppc_init.c @@ -65,6 +65,10 @@ ppc_init (elf, machine, eh, ehlen) HOOK (eh, auxv_info); HOOK (eh, check_object_attribute); HOOK (eh, abi_cfi); + /* gcc/config/ #define DWARF_FRAME_REGISTERS. */ + eh->frame_nregs = (114 - 1) + 32; + HOOK (eh, set_initial_registers_tid); + HOOK (eh, dwarf_to_regno); return MODVERSION; } diff --git a/backends/ppc_initreg.c b/backends/ppc_initreg.c new file mode 100644 index 00000000..64f53793 --- /dev/null +++ b/backends/ppc_initreg.c @@ -0,0 +1,114 @@ +/* Fetch live process registers from TID. + Copyright (C) 2013 Red Hat, Inc. + This file is part of elfutils. + + This file is free software; you can redistribute it and/or modify + it under the terms of either + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version + + or both in parallel, as here. + + elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see <http://www.gnu.org/licenses/>. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "system.h" +#include <stdlib.h> +#ifdef __powerpc__ +# include <sys/user.h> +# include <sys/ptrace.h> +#endif + +#define BACKEND ppc_ +#include "libebl_CPU.h" + +bool +ppc_dwarf_to_regno (Ebl *ebl __attribute__ ((unused)), unsigned *regno) +{ + switch (*regno) + { + case 108: + // LR uses both 65 and 108 numbers, there is no consistency for it. + *regno = 65; + return true; + case 0 ... 107: + case 109 ... (114 - 1) -1: + return true; + case 1200 ... 1231: + *regno = *regno - 1200 + (114 - 1); + return true; + default: + return false; + } + abort (); +} + +__typeof (ppc_dwarf_to_regno) + ppc64_dwarf_to_regno + __attribute__ ((alias ("ppc_dwarf_to_regno"))); + +bool +ppc_set_initial_registers_tid (pid_t tid __attribute__ ((unused)), + ebl_tid_registers_t *setfunc __attribute__ ((unused)), + void *arg __attribute__ ((unused))) +{ +#ifndef __powerpc__ + return false; +#else /* __powerpc__ */ + union + { + struct pt_regs r; + long l[sizeof (struct pt_regs) / sizeof (long)]; + } + user_regs; + eu_static_assert (sizeof (struct pt_regs) % sizeof (long) == 0); + /* PTRACE_GETREGS is EIO on kernel-2.6.18-308.el5.ppc64. */ + errno = 0; + for (unsigned regno = 0; regno < sizeof (user_regs) / sizeof (long); + regno++) + { + user_regs.l[regno] = ptrace (PTRACE_PEEKUSER, tid, + (void *) (uintptr_t) (regno + * sizeof (long)), + NULL); + if (errno != 0) + return false; + } + const size_t gprs = sizeof (user_regs.r.gpr) / sizeof (*user_regs.r.gpr); + Dwarf_Word dwarf_regs[gprs]; + for (unsigned gpr = 0; gpr < gprs; gpr++) + dwarf_regs[gpr] = user_regs.r.gpr[gpr]; + if (! setfunc (0, gprs, dwarf_regs, arg)) + return false; + dwarf_regs[0] = user_regs.r.link; + // LR uses both 65 and 108 numbers, there is no consistency for it. + if (! setfunc (65, 1, dwarf_regs, arg)) + return false; + /* Registers like msr, ctr, xer, dar, dsisr etc. are probably irrelevant + for CFI. */ + dwarf_regs[0] = user_regs.r.nip; + return setfunc (-1, 1, dwarf_regs, arg); +#endif /* __powerpc__ */ +} + +__typeof (ppc_set_initial_registers_tid) + ppc64_set_initial_registers_tid + __attribute__ ((alias ("ppc_set_initial_registers_tid"))); |
