This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
abi_cfi hooks for ppc and s390 (Was: [patch 5/4] unwinder: non-x86* parts of the unwinder)
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Tue, 27 Aug 2013 23:18:44 +0200
- Subject: abi_cfi hooks for ppc and s390 (Was: [patch 5/4] unwinder: non-x86* parts of the unwinder)
Hi Jan,
> present in:
> jankratochvil/forunwind-baseaddr-hookvars-corereport-unwindx86-nonx86
> [...]
> backends/
> 2012-11-14 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * Makefile.am (ppc_SRCS, ppc64_SRCS): Add ppc_frame_state.c and
> ppc_cfi.c.
> (s390_SRCS): Add s390_cfi.c, s390_frame_state.c and
> s390_frame_unwind.c.
> (noinst_HEADERS): Add core-get-pc.c.
> * core-get-pc.c: New file.
> * ppc64_init.c (ppc64_init): Initialize frame_state_nregs, frame_state,
> abi_cfi, frame_dwarf_to_regno, get_func_pc and destr.
> * ppc_cfi.c: New file.
> * ppc_frame_state.c: New file.
> * ppc_init.c (ppc_init): Initialize frame_state_nregs, frame_state,
> abi_cfi and frame_dwarf_to_regno.
> * s390_cfi.c: New file.
> * s390_frame_state.c: New file.
> * s390_frame_unwind.c: New file.
> * s390_init.c (s390_init): Initialize abi_cfi, frame_state_nregs,
> frame_state, optionally normalize_pc and also frame_unwind.
I like to finally get at least the abi_cfi hook part in. It is self
contained. And kind of required now. I picked up the change for ppc and
s390 from your branch. When this is in I'll add some tests to
run-addrcfi.sh test. And then see if I can implement the abi_cfi hook
for the other backends.
If you think the attached commit still looks OK to go in I'll add your
Signed-off-by.
Thanks,
Mark
>From 5395e9f7293761d97483fcdeac1af7915174415d Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Tue, 27 Aug 2013 22:49:36 +0200
Subject: [PATCH] backends: Hook abi_cfi for ppc and s390.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
backends/ChangeLog | 10 ++++++
backends/Makefile.am | 10 ++++--
backends/ppc64_init.c | 3 +-
backends/ppc_cfi.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++
backends/ppc_init.c | 3 +-
backends/s390_cfi.c | 65 +++++++++++++++++++++++++++++++++++++++++
backends/s390_init.c | 3 +-
7 files changed, 164 insertions(+), 7 deletions(-)
create mode 100644 backends/ppc_cfi.c
create mode 100644 backends/s390_cfi.c
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 4f7480d..646a7da 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,13 @@
+2013-08-27 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * Makefile.am (ppc_SRCS, ppc64_SRCS): Add ppc_cfi.c.
+ (s390_SRCS): Add s390_cfi.c.
+ * ppc64_init.c (ppc64_init): Initialize abi_cfi.
+ * ppc_cfi.c: New file.
+ * ppc_init.c (ppc_init): Initialize abi_cfi.
+ * s390_cfi.c: New file.
+ * s390_init.c (s390_init): Initialize abi_cfi.
+
2013-04-24 Mark Wielaard <mjw@redhat.com>
* Makefile.am: Use AM_CPPFLAGS instead of INCLUDES.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 1923702..ec022b0 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to create Makefile.in
##
-## Copyright (C) 2000-2010 Red Hat, Inc.
+## Copyright (C) 2000-2010, 2013 Red Hat, Inc.
## Copyright (C) 2012 Tilera Corporation
## This file is part of elfutils.
##
@@ -85,17 +85,19 @@ libebl_sparc_pic_a_SOURCES = $(sparc_SRCS)
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_corenote.c ppc_auxv.c ppc_attrs.c ppc_syscall.c \
+ ppc_cfi.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
+ ppc64_corenote.c ppc_regs.c ppc_auxv.c ppc_attrs.c ppc_syscall.c \
+ ppc_cfi.c
libebl_ppc64_pic_a_SOURCES = $(ppc64_SRCS)
am_libebl_ppc64_pic_a_OBJECTS = $(ppc64_SRCS:.c=.os)
s390_SRCS = s390_init.c s390_symbol.c s390_regs.c s390_retval.c \
- s390_corenote.c s390x_corenote.c
+ s390_corenote.c s390x_corenote.c s390_cfi.c
libebl_s390_pic_a_SOURCES = $(s390_SRCS)
am_libebl_s390_pic_a_OBJECTS = $(s390_SRCS:.c=.os)
diff --git a/backends/ppc64_init.c b/backends/ppc64_init.c
index 90d4f2b..1435875 100644
--- a/backends/ppc64_init.c
+++ b/backends/ppc64_init.c
@@ -1,5 +1,5 @@
/* Initialization of PPC64 specific backend library.
- Copyright (C) 2004, 2005, 2006, 2007, 2008 Red Hat, Inc.
+ Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2004.
@@ -64,6 +64,7 @@ ppc64_init (elf, machine, eh, ehlen)
HOOK (eh, syscall_abi);
HOOK (eh, core_note);
HOOK (eh, auxv_info);
+ HOOK (eh, abi_cfi);
return MODVERSION;
}
diff --git a/backends/ppc_cfi.c b/backends/ppc_cfi.c
new file mode 100644
index 0000000..6a4f461
--- /dev/null
+++ b/backends/ppc_cfi.c
@@ -0,0 +1,77 @@
+/* ppc ABI-specified defaults for DWARF CFI.
+ Copyright (C) 2012, 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 <dwarf.h>
+
+#define BACKEND ppc_
+#include "libebl_CPU.h"
+
+int
+ppc_abi_cfi (Ebl *ebl __attribute__ ((unused)), Dwarf_CIE *abi_info)
+{
+ static const uint8_t abi_cfi[] =
+ {
+ /* This instruction is provided in every CIE. It is not repeated here:
+ DW_CFA_def_cfa, ULEB128_7 (1), ULEB128_7 (0) */
+ /* r1 is assumed to be restored from cfa adress,
+ r1 acts as a stack frame pointer. */
+ DW_CFA_val_expression, ULEB128_7 (1), ULEB128_7 (1), DW_OP_nop,
+ /* lr is not callee-saved but it needs to be preserved as it is pre-set
+ by the caller. */
+ DW_CFA_same_value, ULEB128_7 (65), /* lr */
+
+ /* Callee-saved regs. */
+#define SV(n) DW_CFA_same_value, ULEB128_7 (n)
+ SV (2), /* r2 is TOC pointer. */
+ SV (13), /* Reserved as system thread id (is it for CFI?). */
+ /* r14-r31 are non-volatile registers. */
+ SV (14), SV (15), SV (16), SV (17), SV (18), SV (19), SV (20), SV (21),
+ SV (22), SV (23), SV (24), SV (25), SV (26), SV (27), SV (28), SV (29),
+ SV (30), SV (31)
+ /* VMX registers v20-v31 and vrsave are non-volatile but they are
+ assigned DWARF registers 1144-1156 (v20-v31) which is outside of the
+ CFI supported range. */
+#undef SV
+ };
+
+ abi_info->initial_instructions = abi_cfi;
+ abi_info->initial_instructions_end = &abi_cfi[sizeof abi_cfi];
+ abi_info->data_alignment_factor = ebl->class == ELFCLASS64 ? 8 : 4;
+
+ abi_info->return_address_register = 65;
+
+ return 0;
+}
+
+__typeof (ppc_abi_cfi)
+ ppc64_abi_cfi
+ __attribute__ ((alias ("ppc_abi_cfi")));
diff --git a/backends/ppc_init.c b/backends/ppc_init.c
index 6054007..004c601 100644
--- a/backends/ppc_init.c
+++ b/backends/ppc_init.c
@@ -1,5 +1,5 @@
/* Initialization of PPC specific backend library.
- Copyright (C) 2004, 2005, 2006, 2007, 2008 Red Hat, Inc.
+ Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2004.
@@ -64,6 +64,7 @@ ppc_init (elf, machine, eh, ehlen)
HOOK (eh, core_note);
HOOK (eh, auxv_info);
HOOK (eh, check_object_attribute);
+ HOOK (eh, abi_cfi);
return MODVERSION;
}
diff --git a/backends/s390_cfi.c b/backends/s390_cfi.c
new file mode 100644
index 0000000..cb49486
--- /dev/null
+++ b/backends/s390_cfi.c
@@ -0,0 +1,65 @@
+/* s390 ABI-specified defaults for DWARF CFI.
+ Copyright (C) 2012, 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 <dwarf.h>
+
+#define BACKEND s390_
+#include "libebl_CPU.h"
+
+int
+s390_abi_cfi (Ebl *ebl, Dwarf_CIE *abi_info)
+{
+ static const uint8_t abi_cfi[] =
+ {
+ /* This instruction is provided in every CIE. It is not repeated here:
+ DW_CFA_def_cfa, ULEB128_7 (15), ULEB128_7 (96) */
+ /* r14 is not callee-saved but it needs to be preserved as it is pre-set
+ by the caller. */
+ DW_CFA_same_value, ULEB128_7 (14), /* r14 */
+
+ /* Callee-saved regs. */
+#define SV(n) DW_CFA_same_value, ULEB128_7 (n)
+ SV (6), SV (7), SV (8), SV (9), SV (10), /* r6-r13, r15 */
+ SV (11), SV (12), SV (13), SV (15),
+ SV (16 + 8), SV (16 + 9), SV (16 + 10), SV (16 + 11), /* f8-f15 */
+ SV (16 + 12), SV (16 + 13), SV (16 + 14), SV (16 + 15)
+#undef SV
+ };
+
+ abi_info->initial_instructions = abi_cfi;
+ abi_info->initial_instructions_end = &abi_cfi[sizeof abi_cfi];
+ abi_info->data_alignment_factor = ebl->class == ELFCLASS64 ? 8 : 4;
+
+ abi_info->return_address_register = 14;
+
+ return 0;
+}
diff --git a/backends/s390_init.c b/backends/s390_init.c
index 91fe4b8..630a2ee 100644
--- a/backends/s390_init.c
+++ b/backends/s390_init.c
@@ -1,5 +1,5 @@
/* Initialization of S/390 specific backend library.
- Copyright (C) 2005, 2006 Red Hat, Inc.
+ Copyright (C) 2005, 2006, 2013 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -61,6 +61,7 @@ s390_init (elf, machine, eh, ehlen)
eh->core_note = s390x_core_note;
else
HOOK (eh, core_note);
+ HOOK (eh, abi_cfi);
/* Only the 64-bit format uses the incorrect hash table entry size. */
if (eh->class == ELFCLASS64)
--
1.7.1