RISC-V: Fix gdbserver problem with handling arch strings.
authorJim Wilson <jimw@sifive.com>
Mon, 27 Jan 2020 23:19:30 +0000 (15:19 -0800)
committerJim Wilson <jimw@sifive.com>
Mon, 27 Jan 2020 23:19:30 +0000 (15:19 -0800)
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.

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

Change-Id: I096476705e1da5cb8934c5005b1eed2a8989f7a7

bfd/ChangeLog
bfd/cpu-riscv.c

index afa8928eecaf27faf6d8743c78c1e8376ee9f182..83a1cc67430329da70fd0596c8b52fc21663d2fe 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-27  Jim Wilson  <jimw@sifive.com>
+
+       * cpu-riscv.c (riscv_scan): New.
+       (N): Change bfd_default_scan to riscv_scan.
+
 2020-01-27  Andreas Schwab  <schwab@suse.de>
 
        * Makefile.am (ALL_MACHINES): Remove cpu-plugin.lo.
index bc90ffc87683b62479bb7276247f18cb62a79a7d..b5c972ff4dc9c2287fe97fcb20bb540b798dbe14 100644 (file)
@@ -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.  */\
This page took 0.027948 seconds and 4 git commands to generate.