[v2] RISC-V: Fix gdbserver problem with handling arch strings.

Message ID 20200127232405.13229-1-jimw@sifive.com
State New
Headers show
Series
  • [v2] RISC-V: Fix gdbserver problem with handling arch strings.
Related show

Commit Message

Jim Wilson Jan. 27, 2020, 11:24 p.m.
No comments other than the one from Maciej, so I committed it with the change
he suggested.

Jim

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

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

-- 
2.17.1

Patch

diff --git a/bfd/cpu-riscv.c b/bfd/cpu-riscv.c
index bc90ffc876..b5c972ff4d 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
+riscv_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,						\
+    riscv_scan,							\
     bfd_arch_default_fill,					\
     NEXT,							\
     0 /* Maximum offset of a reloc from the start of an insn.  */\