summaryrefslogtreecommitdiffstats
path: root/backends
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@linux-m68k.org>2018-07-21 23:42:07 +0200
committerMark Wielaard <mark@klomp.org>2018-07-22 10:20:01 +0200
commitdf9053f67c637fd240771705bb926a6d0e3381cf (patch)
treed42b1a31871886cc1732ce3aa39e624a1694d389 /backends
parent4d240015c63d7cb702b70f7b17c8535c8223858a (diff)
backends: add abi_cfi and set_initial_registers_tid callbacks for M68K
This fixes all testsuite failures. Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Diffstat (limited to 'backends')
-rw-r--r--backends/ChangeLog8
-rw-r--r--backends/Makefile.am2
-rw-r--r--backends/m68k_cfi.c58
-rw-r--r--backends/m68k_init.c4
-rw-r--r--backends/m68k_initreg.c82
5 files changed, 153 insertions, 1 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 79370b6f..52149482 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,11 @@
+2018-07-21 Andreas Schwab <schwab@linux-m68k.org>
+
+ * Makefile.am (m68k_SRCS): Add m68k_cfi.c and m68k_initreg.c.
+ * m68k_cfi.c: New file.
+ * m68k_initreg.c: New file.
+ * m68k_init.c (m68k_init): Hook abi_cfi and
+ set_initial_registers_tid.
+
2018-07-19 Andreas Schwab <schwab@suse.de>
* riscv_regs.c (riscv_register_info): Fix typo.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 803df809..9d340425 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -115,7 +115,7 @@ libebl_tilegx_pic_a_SOURCES = $(tilegx_SRCS)
am_libebl_tilegx_pic_a_OBJECTS = $(tilegx_SRCS:.c=.os)
m68k_SRCS = m68k_init.c m68k_symbol.c m68k_regs.c \
- m68k_retval.c m68k_corenote.c
+ m68k_retval.c m68k_corenote.c m68k_cfi.c m68k_initreg.c
libebl_m68k_pic_a_SOURCES = $(m68k_SRCS)
am_libebl_m68k_pic_a_OBJECTS = $(m68k_SRCS:.c=.os)
diff --git a/backends/m68k_cfi.c b/backends/m68k_cfi.c
new file mode 100644
index 00000000..9303fb22
--- /dev/null
+++ b/backends/m68k_cfi.c
@@ -0,0 +1,58 @@
+/* m68k ABI-specified defaults for DWARF CFI.
+ 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 m68k_
+#include "libebl_CPU.h"
+
+int
+m68k_abi_cfi (Ebl *ebl __attribute__ ((unused)), Dwarf_CIE *abi_info)
+{
+ static const uint8_t abi_cfi[] =
+ {
+#define SV(n) DW_CFA_same_value, ULEB128_7 (n)
+ /* Call-saved registers %d2-%d7, %a2-%a6. */
+ SV (2), SV (3), SV (4), SV (5), SV (6), SV (7),
+ SV (10), SV (11), SV (12), SV (13), SV (14),
+
+ /* The CFA is the SP. */
+ DW_CFA_val_offset, ULEB128_7 (15), ULEB128_7 (0),
+ };
+
+ abi_info->initial_instructions = abi_cfi;
+ abi_info->initial_instructions_end = &abi_cfi[sizeof abi_cfi];
+ abi_info->data_alignment_factor = -4;
+
+ abi_info->return_address_register = 24; /* %pc */
+
+ return 0;
+}
diff --git a/backends/m68k_init.c b/backends/m68k_init.c
index 943478fb..8cae710b 100644
--- a/backends/m68k_init.c
+++ b/backends/m68k_init.c
@@ -55,6 +55,10 @@ m68k_init (Elf *elf __attribute__ ((unused)),
HOOK (eh, return_value_location);
HOOK (eh, register_info);
HOOK (eh, core_note);
+ HOOK (eh, abi_cfi);
+ /* gcc/config/ #define DWARF_FRAME_REGISTERS. */
+ eh->frame_nregs = 25;
+ HOOK (eh, set_initial_registers_tid);
return MODVERSION;
}
diff --git a/backends/m68k_initreg.c b/backends/m68k_initreg.c
new file mode 100644
index 00000000..61f260f6
--- /dev/null
+++ b/backends/m68k_initreg.c
@@ -0,0 +1,82 @@
+/* Fetch live process registers from TID.
+ 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
+
+#if defined __m68k__ && defined __linux__
+# include <sys/types.h>
+# include <sys/user.h>
+# include <sys/ptrace.h>
+#endif
+
+#define BACKEND m68k_
+#include "libebl_CPU.h"
+
+bool
+m68k_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
+ ebl_tid_registers_t *setfunc __attribute__ ((unused)),
+ void *arg __attribute__ ((unused)))
+{
+#if !defined __m68k__ || !defined __linux__
+ return false;
+#else /* __m68k__ */
+ struct user_regs_struct user_regs;
+ if (ptrace (PTRACE_GETREGS, tid, NULL, &user_regs) != 0)
+ return false;
+
+ Dwarf_Word dwarf_regs[16];
+ dwarf_regs[0] = user_regs.d0;
+ dwarf_regs[1] = user_regs.d1;
+ dwarf_regs[2] = user_regs.d2;
+ dwarf_regs[3] = user_regs.d3;
+ dwarf_regs[4] = user_regs.d4;
+ dwarf_regs[5] = user_regs.d5;
+ dwarf_regs[6] = user_regs.d6;
+ dwarf_regs[7] = user_regs.d7;
+ dwarf_regs[8] = user_regs.a0;
+ dwarf_regs[9] = user_regs.a1;
+ dwarf_regs[10] = user_regs.a2;
+ dwarf_regs[11] = user_regs.a3;
+ dwarf_regs[12] = user_regs.a4;
+ dwarf_regs[13] = user_regs.a5;
+ dwarf_regs[14] = user_regs.a6;
+ dwarf_regs[15] = user_regs.usp;
+
+ /* D0..D7, A0..A7. */
+ if (! setfunc (0, 16, dwarf_regs, arg))
+ return false;
+
+ /* PC. */
+ dwarf_regs[0] = user_regs.pc;
+ if (! setfunc (24, 1, dwarf_regs, arg))
+ return false;
+
+ return true;
+#endif /* __m68k__ */
+}