aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-or1k.c
diff options
context:
space:
mode:
authorStafford Horne <shorne@gmail.com>2018-12-08 07:01:40 +0900
committerStafford Horne <shorne@gmail.com>2018-12-08 07:07:36 +0900
commit42e151bf4cc66b8781f2b139c6da320095f9a045 (patch)
tree3004954c0eb750ed1414e3751f882c9797b533ee /bfd/elf32-or1k.c
parentf50fabe4f66534c9addacddeaa439e8d164eadda (diff)
downloadgdb-42e151bf4cc66b8781f2b139c6da320095f9a045.zip
gdb-42e151bf4cc66b8781f2b139c6da320095f9a045.tar.gz
gdb-42e151bf4cc66b8781f2b139c6da320095f9a045.tar.bz2
gdb/or1k: Add linux debugging support
Up until now OpenRISC GDB only has supported bare metal debugging. This patch adds linux userspace debugging and core dump analysis support. The changes are loosely based on nios2 and riscv implementations. This was tested with linux 4.20 core dumps for executables linked against musl libc. bfd/ChangeLog: * elf32-or1k.c (or1k_grok_prstatus): New function. (or1k_grok_psinfo): Likewise. gdb/ChangeLog: * Makefile.in (ALL_TARGET_OBS): Add or1k-linux-tdep.o. * configure.tgt: Add or1k*-*-linux*. * or1k-linux-tdep.c: New file. * or1k-tdep.c (or1k_gdbarch_init): Call gdbarch_init_osabi.
Diffstat (limited to 'bfd/elf32-or1k.c')
-rw-r--r--bfd/elf32-or1k.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
index a2b0ff1..8edd758 100644
--- a/bfd/elf32-or1k.c
+++ b/bfd/elf32-or1k.c
@@ -3226,6 +3226,58 @@ elf32_or1k_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
}
+/* Implement elf_backend_grok_prstatus:
+ Support for core dump NOTE sections. */
+static bfd_boolean
+or1k_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
+{
+ int offset;
+ size_t size;
+
+ switch (note->descsz)
+ {
+ default:
+ return FALSE;
+
+ case 212: /* Linux/OpenRISC */
+ /* pr_cursig */
+ elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
+
+ /* pr_pid */
+ elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24);
+
+ /* pr_reg */
+ offset = 72;
+ size = 132;
+
+ break;
+ }
+
+ /* Make a ".reg/999" section. */
+ return _bfd_elfcore_make_pseudosection (abfd, ".reg",
+ size, note->descpos + offset);
+}
+
+/* Implement elf_backend_grok_psinfo. */
+static bfd_boolean
+or1k_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
+{
+ switch (note->descsz)
+ {
+ default:
+ return FALSE;
+
+ case 128: /* Linux/OpenRISC elf_prpsinfo */
+ elf_tdata (abfd)->core->program
+ = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
+ elf_tdata (abfd)->core->command
+ = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
+ }
+
+ return TRUE;
+}
+
+
#define ELF_ARCH bfd_arch_or1k
#define ELF_MACHINE_CODE EM_OR1K
#define ELF_TARGET_ID OR1K_ELF_DATA
@@ -3269,4 +3321,7 @@ elf32_or1k_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
#define elf_backend_adjust_dynamic_symbol or1k_elf_adjust_dynamic_symbol
#define elf_backend_finish_dynamic_symbol or1k_elf_finish_dynamic_symbol
+#define elf_backend_grok_prstatus or1k_grok_prstatus
+#define elf_backend_grok_psinfo or1k_grok_psinfo
+
#include "elf32-target.h"