public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Fix gdbserver problem with handling arch strings.
@ 2020-01-24  2:09 Jim Wilson
  2020-01-24 13:32 ` Maciej W. Rozycki
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jim Wilson @ 2020-01-24  2:09 UTC (permalink / raw)
  To: binutils; +Cc: macro, Jim Wilson

Maciej reported a problem found by his RISC-V gdbserver port.
warning: while parsing target description (at line 4): Target description specified unknown architecture "riscv:rv64id"
warning: Could not load XML target description; ignoring

We only have two arches defined, riscv:rv32 and riscv:rv64.  Both bfd and
gdb are creating arch strings that have extension letters added to the base
architecture.  The bfd_default_scan function requires an exact match, so
these strings fail to map to a bfd_arch.  I think we should ignore the
extension letters in a RISC-V specific scan function.

Tested with riscv{32,64}-{elf,linux} cross build and test with no regressions.

Not committed yet in case anyone wanted to comment on it before I check it in.

Jim

	bfd/
	* cpu-riscv.c (scan): New.
	(N): Change bfd_default_scan to scan.

Change-Id: I1498390cc4cc827a947eff039278f21c628e1fa3
---
 bfd/cpu-riscv.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/bfd/cpu-riscv.c b/bfd/cpu-riscv.c
index bc90ffc876..bfd98d4e95 100644
--- a/bfd/cpu-riscv.c
+++ b/bfd/cpu-riscv.c
@@ -39,6 +39,23 @@ riscv_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b)
   return a;
 }
 
+/* Return TRUE if STRING matches the architecture described by INFO.  */
+
+static bfd_boolean
+scan (const struct bfd_arch_info *info, const char *string)
+{
+  if (bfd_default_scan (info, string))
+    return TRUE;
+
+  /* The string might have extra characters for supported subsets.  So allow
+     a match that ignores trailing characters in string.  */
+  if (strncasecmp (string, info->printable_name,
+		   strlen (info->printable_name)) == 0)
+    return TRUE;
+
+  return FALSE;
+}
+
 #define N(BITS, NUMBER, PRINT, DEFAULT, NEXT)			\
   {								\
     BITS,      /* Bits in a word.  */				\
@@ -51,7 +68,7 @@ riscv_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b)
     3,								\
     DEFAULT,							\
     riscv_compatible,						\
-    bfd_default_scan,						\
+    scan,							\
     bfd_arch_default_fill,					\
     NEXT,							\
     0 /* Maximum offset of a reloc from the start of an insn.  */\
-- 
2.17.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-30 15:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-24  2:09 [PATCH] RISC-V: Fix gdbserver problem with handling arch strings Jim Wilson
2020-01-24 13:32 ` Maciej W. Rozycki
2020-01-24 22:38   ` Jim Wilson
2020-01-27 13:04     ` Maciej W. Rozycki
2020-01-27 20:31       ` Jim Wilson
2020-01-27 23:24 ` [PATCH v2] " Jim Wilson
2020-01-30 15:41 ` [PATCH] " Palmer Dabbelt via binutils

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).