public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Jim Wilson <jimw@sifive.com>
To: gdb-patches@sourceware.org
Cc: Jim Wilson <jimw@sifive.com>
Subject: [PATCH 3/5] RISC-V: Add linux target support.
Date: Wed, 08 Aug 2018 18:35:00 -0000	[thread overview]
Message-ID: <20180808183443.25570-1-jimw@sifive.com> (raw)
In-Reply-To: <CAFyWVaYfdeo56PrGf7N8VLfUpMdnRekpru7vMyHS5BLKsszscA@mail.gmail.com>

Add initial target support for riscv*-linux*.

	gdb/
	* riscv-linux-tdep.c: New file.
---
 gdb/riscv-linux-tdep.c | 94 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)
 create mode 100644 gdb/riscv-linux-tdep.c

diff --git a/gdb/riscv-linux-tdep.c b/gdb/riscv-linux-tdep.c
new file mode 100644
index 0000000000..47c2ab6d4f
--- /dev/null
+++ b/gdb/riscv-linux-tdep.c
@@ -0,0 +1,94 @@
+/* Target-dependent code for GNU/Linux on RISC-V processors.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program 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 a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include "defs.h"
+#include "riscv-tdep.h"
+#include "osabi.h"
+#include "glibc-tdep.h"
+#include "linux-tdep.h"
+#include "solib-svr4.h"
+#include "regset.h"
+
+/* Define the general register mapping.  The kernel puts the PC at offset 0,
+   gdb puts it at offset 32.  Register x0 is always 0 and can be ignored.
+   Registers x1 to x31 are in the same place.  */
+
+static const struct regcache_map_entry riscv_linux_gregmap[] =
+{
+  { 1,  RISCV_PC_REGNUM, 0 },
+  { 31, RISCV_RA_REGNUM, 0 }, /* x1 to x31 */
+  { 0 }
+};
+
+/* Define the general register regset.  */
+
+static const struct regset riscv_linux_gregset =
+{
+  riscv_linux_gregmap, regcache_supply_regset, regcache_collect_regset
+};
+
+/* Define hook for core file support.  */
+
+static void
+riscv_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
+                                          iterate_over_regset_sections_cb *cb,
+                                          void *cb_data,
+                                          const struct regcache *regcache)
+{
+  cb (".reg", (32 * riscv_isa_xlen (gdbarch)),
+      &riscv_linux_gregset, NULL, cb_data);
+
+  /* TODO: Add FP register support.  */
+}
+
+/* Initialize RISC-V Linux ABI info.  */
+
+static void
+riscv_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+  linux_init_abi (info, gdbarch);
+
+  set_gdbarch_software_single_step (gdbarch, riscv_software_single_step);
+
+  set_solib_svr4_fetch_link_map_offsets (gdbarch,
+					 (riscv_isa_xlen (gdbarch) == 4
+					  ? svr4_ilp32_fetch_link_map_offsets
+					  : svr4_lp64_fetch_link_map_offsets));
+
+  /* GNU/Linux uses SVR4-style shared libraries.  */
+  set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
+
+  /* GNU/Linux uses the dynamic linker included in the GNU C Library.  */
+  set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
+
+  /* Enable TLS support.  */
+  set_gdbarch_fetch_tls_load_module_address (gdbarch,
+                                             svr4_fetch_objfile_link_map);
+
+  set_gdbarch_iterate_over_regset_sections
+    (gdbarch, riscv_linux_iterate_over_regset_sections);
+}
+
+/* Initialize RISC-V Linux target support.  */
+
+void
+_initialize_riscv_linux_tdep (void)
+{
+  gdbarch_register_osabi (bfd_arch_riscv, 0, GDB_OSABI_LINUX,
+			  riscv_linux_init_abi);
+}
-- 
2.17.1

  reply	other threads:[~2018-08-08 18:35 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-08  2:12 [PATCH 0/5] RISC-V Linux native port Jim Wilson
2018-08-08  2:15 ` [PATCH 1/5] RISC-V: Make riscv_isa_xlen a global function Jim Wilson
2018-08-08 12:42   ` Andrew Burgess
2018-08-08 17:55     ` Jim Wilson
2018-08-08 19:18   ` Simon Marchi
2018-08-08  2:16 ` [PATCH 2/5] RISC-V: Add software single step support Jim Wilson
2018-08-08 12:50   ` Andrew Burgess
2018-08-08 17:55     ` Jim Wilson
2018-08-08  2:16 ` [PATCH 3/5] RISC-V: Add linux target support Jim Wilson
2018-08-08 14:41   ` Andrew Burgess
2018-08-08 18:19     ` Jim Wilson
2018-08-08 18:35       ` Jim Wilson [this message]
2018-08-09 20:40         ` Jim Wilson
2018-08-08  2:17 ` [PATCH 5/5] RISC-V: Add configure support riscv*-linux* Jim Wilson
2018-08-08 16:00   ` Andrew Burgess
2018-08-08 17:30   ` Tom Tromey
2018-08-08 18:22     ` Eli Zaretskii
2018-08-08 20:49     ` Palmer Dabbelt
2018-08-08 23:26       ` Tom Tromey
2018-08-08 23:29         ` Tom Tromey
2018-08-09  2:36         ` Eli Zaretskii
2018-08-09  3:43           ` Jim Wilson
2018-08-09  4:55             ` Tom Tromey
2018-08-09  7:05             ` Andreas Schwab
2018-08-09 12:55             ` Eli Zaretskii
2018-08-09 17:25               ` Jim Wilson
2018-08-09  0:25     ` Jim Wilson
2018-08-09  0:29       ` [PATCH 5/5] RISC-V: Add configure support for riscv*-linux* Jim Wilson
2018-08-09  2:39         ` Eli Zaretskii
2018-08-09 15:57         ` Tom Tromey
2018-08-09 20:42           ` Jim Wilson
2018-08-08  2:17 ` [PATCH 4/5] RISC-V: Add native linux support Jim Wilson
2018-08-08 15:58   ` Andrew Burgess
2018-08-08 23:36     ` Jim Wilson
2018-08-08 23:39       ` Jim Wilson
2018-08-09  8:42         ` Andrew Burgess
2018-08-09 20:41           ` Jim Wilson
2018-10-25 10:49         ` Andreas Schwab
2018-10-25 11:09           ` Andrew Burgess
2018-10-25 12:06             ` Pedro Alves
2018-10-28 11:23               ` Andrew Burgess
2018-10-25 17:55             ` John Baldwin
2018-10-25 18:17               ` Jim Wilson
2018-10-25 19:19                 ` John Baldwin
2018-10-27  6:07                   ` Palmer Dabbelt
2018-10-29  8:50                 ` Andreas Schwab
2018-10-25 16:40           ` Jim Wilson
2018-08-08 12:41 ` [PATCH 0/5] RISC-V Linux native port Andrew Burgess
2018-08-08 17:41   ` Jim Wilson
2018-08-08 18:16     ` Andrew Burgess
2018-08-08 18:42       ` Jim Wilson
2018-08-09  3:18         ` Palmer Dabbelt
2018-08-10 18:04 ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180808183443.25570-1-jimw@sifive.com \
    --to=jimw@sifive.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).