RISC-V: Report warning when linking the objects with different priv specs.
authorNelson Chu <nelson.chu@sifive.com>
Fri, 12 Jun 2020 15:06:49 +0000 (23:06 +0800)
committerNelson Chu <nelson.chu@sifive.com>
Mon, 22 Jun 2020 02:01:14 +0000 (10:01 +0800)
We do know some conflicts among different privileged specs.  For linker,
the safest approach is that don't allow the object linked with others which
may cause conflicts.  But this may cause inconvenience since not all objects
with conflicting priv specs are linked will cause problems.  But it is hard
to know the detailed conflict cases for linker, so we probably need a option
to tell linker that we do know there are no conflicts, or we are willing to
take risks to link the objects with conflicted priv specs.  But the option
is still under discussion.

Therefore, we can report warnings rather than errors when linking the objects
with conflicted priv specs.  This not only makes the linker more flexible,
but also warns people that the conflicts may happen.  We also need to update
the output priv spec version once the input priv spec is newer.

bfd/
* elfxx-riscv.c (struct priv_spec_t priv_specs[]): Move them from
opcodes/riscv-opc.c to bfd/elfxx-riscv.c, since we need it in linker.
(riscv_get_priv_spec_class): Likewise.
(riscv_get_priv_spec_name): Likewise.
(riscv_get_priv_spec_class_from_numbers): New function, convert
the version numbers into string, then call riscv_get_priv_spec_class
to get the priv spec class.
* elfxx-riscv.h (riscv_get_priv_spec_class): Move forward declaration
from include/opcode/riscv.h to bfd/elfxx-riscv.h.
(riscv_get_priv_spec_name): Likewise.
(riscv_get_priv_spec_class_from_numbers): New forward declaration.
(opcode/riscv.h): Include it in the header rather than elfxx-riscv.c.
* elfnn-riscv.c (riscv_merge_attributes):  Get the priv spec classes
of input and output objects form their priv spec attributes by
riscv_get_priv_spec_class_from_numbers.  Report warning rather than
errors when linking objects with differnet priv spec versions.  We do
know v1.9.1 may have conflicts to other versions, so report the
warning, too.  After that, update the output priv spec version to the
newest one so far.

gas/
* config/tc-riscv.c (buf_size, buf): Remove the unused variables.
(riscv_set_default_priv_spec): Get the priv spec version from the
priv spec attributes by riscv_get_priv_spec_class_from_numbers.

include/
* opcode/riscv.h (riscv_get_priv_spec_class): Move the function
forward declarations to bfd/elfxx-riscv.h.
(riscv_get_priv_spec_name): Likewise.

opcodes/
* riscv-opc.c: Move the structures and functions to bfd/elfxx-riscv.c.
* riscv-dis.c: Include elfxx-riscv.h.

ld/
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Updated.

18 files changed:
bfd/ChangeLog
bfd/elfnn-riscv.c
bfd/elfxx-riscv.c
bfd/elfxx-riscv.h
gas/ChangeLog
gas/config/tc-riscv.c
include/ChangeLog
include/opcode/riscv.h
ld/ChangeLog
ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d
ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d
ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d
ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d
ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d
ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d
opcodes/ChangeLog
opcodes/riscv-dis.c
opcodes/riscv-opc.c

index d9b66b55d347e37b940c5b869e77cec1f4a73dc8..6ac3c0fb67efc423a25dd12cad0daceccdc9b7ad 100644 (file)
@@ -1,3 +1,25 @@
+2020-06-22  Nelson Chu  <nelson.chu@sifive.com>
+
+       * elfxx-riscv.c (struct priv_spec_t priv_specs[]): Move them from
+       opcodes/riscv-opc.c to bfd/elfxx-riscv.c, since we need it in linker.
+       (riscv_get_priv_spec_class): Likewise.
+       (riscv_get_priv_spec_name): Likewise.
+       (riscv_get_priv_spec_class_from_numbers): New function, convert
+       the version numbers into string, then call riscv_get_priv_spec_class
+       to get the priv spec class.
+       * elfxx-riscv.h (riscv_get_priv_spec_class): Move forward declaration
+       from include/opcode/riscv.h to bfd/elfxx-riscv.h.
+       (riscv_get_priv_spec_name): Likewise.
+       (riscv_get_priv_spec_class_from_numbers): New forward declaration.
+       (opcode/riscv.h): Include it in the header rather than elfxx-riscv.c.
+       * elfnn-riscv.c (riscv_merge_attributes):  Get the priv spec classes
+       of input and output objects form their priv spec attributes by
+       riscv_get_priv_spec_class_from_numbers.  Report warning rather than
+       errors when linking objects with differnet priv spec versions.  We do
+       know v1.9.1 may have conflicts to other versions, so report the
+       warning, too.  After that, update the output priv spec version to the
+       newest one so far.
+
 2020-06-22  Nelson Chu  <nelson.chu@sifive.com>
 
        * elfnn-riscv.c (riscv_merge_attributes): Once we meet one of the
index 280445945dd21bf7821766c33659fd01c803188a..00553f774644d98ac30a2c358014c9a1c0b98137 100644 (file)
@@ -3052,25 +3052,31 @@ riscv_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
            unsigned int Tag_a = Tag_RISCV_priv_spec;
            unsigned int Tag_b = Tag_RISCV_priv_spec_minor;
            unsigned int Tag_c = Tag_RISCV_priv_spec_revision;
+           enum riscv_priv_spec_class in_priv_spec;
+           enum riscv_priv_spec_class out_priv_spec;
+
+           /* Get the priv spec class from elf attribute numbers.  */
+           riscv_get_priv_spec_class_from_numbers (in_attr[Tag_a].i,
+                                                   in_attr[Tag_b].i,
+                                                   in_attr[Tag_c].i,
+                                                   &in_priv_spec);
+           riscv_get_priv_spec_class_from_numbers (out_attr[Tag_a].i,
+                                                   out_attr[Tag_b].i,
+                                                   out_attr[Tag_c].i,
+                                                   &out_priv_spec);
 
            /* Allow to link the object without the priv specs.  */
-           if (out_attr[Tag_a].i == 0
-               && out_attr[Tag_b].i == 0
-               && out_attr[Tag_c].i == 0)
+           if (out_priv_spec == PRIV_SPEC_CLASS_NONE)
              {
                out_attr[Tag_a].i = in_attr[Tag_a].i;
                out_attr[Tag_b].i = in_attr[Tag_b].i;
                out_attr[Tag_c].i = in_attr[Tag_c].i;
              }
-           else if ((in_attr[Tag_a].i != 0
-                     || in_attr[Tag_b].i != 0
-                     || in_attr[Tag_c].i != 0)
-                    && (out_attr[Tag_a].i != in_attr[Tag_a].i
-                        || out_attr[Tag_b].i != in_attr[Tag_b].i
-                        || out_attr[Tag_c].i != in_attr[Tag_c].i))
+           else if (in_priv_spec != PRIV_SPEC_CLASS_NONE
+                    && in_priv_spec != out_priv_spec)
              {
                _bfd_error_handler
-                 (_("error: %pB use privilege spec version %u.%u.%u but "
+                 (_("warning: %pB use privilege spec version %u.%u.%u but "
                     "the output use version %u.%u.%u."),
                   ibfd,
                   in_attr[Tag_a].i,
@@ -3079,7 +3085,26 @@ riscv_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
                   out_attr[Tag_a].i,
                   out_attr[Tag_b].i,
                   out_attr[Tag_c].i);
-               result = FALSE;
+
+               /* The priv spec v1.9.1 can be linked with other spec
+                  versions since the conflicts.  We plan to drop the
+                  v1.9.1 in a year or two, so this confict should be
+                  removed in the future.  */
+               if (in_priv_spec == PRIV_SPEC_CLASS_1P9P1
+                   || out_priv_spec == PRIV_SPEC_CLASS_1P9P1)
+                 {
+                   _bfd_error_handler
+                     (_("warning: privilege spec version 1.9.1 can not be "
+                        "linked with other spec versions."));
+                 }
+
+               /* Update the output priv attributes to the newest.  */
+               if (in_priv_spec > out_priv_spec)
+                 {
+                   out_attr[Tag_a].i = in_attr[Tag_a].i;
+                   out_attr[Tag_b].i = in_attr[Tag_b].i;
+                   out_attr[Tag_c].i = in_attr[Tag_c].i;
+                 }
              }
            priv_attrs_merged = TRUE;
          }
index 5dd36ab965a9e56fe778d3c408faa2ec289c1c2c..fa46b06f8df9ddb12cff822d14885dbbf4a5b2e8 100644 (file)
@@ -25,7 +25,6 @@
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "elf/riscv.h"
-#include "opcode/riscv.h"
 #include "libiberty.h"
 #include "elfxx-riscv.h"
 #include "safe-ctype.h"
@@ -1750,3 +1749,98 @@ riscv_arch_str (unsigned xlen, const riscv_subset_list_t *subset)
 
   return attr_str;
 }
+
+/* Record the priv spec version string and the corresponding class.  */
+
+struct priv_spec_t
+{
+  const char *name;
+  enum riscv_priv_spec_class class;
+};
+
+/* List for all supported privilege versions.  */
+
+static const struct priv_spec_t priv_specs[] =
+{
+  {"1.9.1", PRIV_SPEC_CLASS_1P9P1},
+  {"1.10",  PRIV_SPEC_CLASS_1P10},
+  {"1.11",  PRIV_SPEC_CLASS_1P11},
+
+/* Terminate the list.  */
+  {NULL, 0}
+};
+
+/* Get the corresponding CSR version class by giving a privilege
+   version string.  */
+
+int
+riscv_get_priv_spec_class (const char *s,
+                          enum riscv_priv_spec_class *class)
+{
+  const struct priv_spec_t *version;
+
+  if (s == NULL)
+    return 0;
+
+  for (version = &priv_specs[0]; version->name != NULL; ++version)
+    if (strcmp (version->name, s) == 0)
+      {
+       *class = version->class;
+       return 1;
+      }
+
+  /* Can not find the supported privilege version.  */
+  return 0;
+}
+
+/* Get the corresponding CSR version class by giving privilege
+   version numbers.  It is usually used to convert the priv
+   attribute numbers into the corresponding class.  */
+
+int
+riscv_get_priv_spec_class_from_numbers (unsigned int major,
+                                       unsigned int minor,
+                                       unsigned int revision,
+                                       enum riscv_priv_spec_class *class)
+{
+  size_t buf_size;
+  char *buf;
+  int result = 1;
+
+  if (major == 0 && minor == 0 && revision == 0)
+    {
+      *class = PRIV_SPEC_CLASS_NONE;
+      return result;
+    }
+
+  buf_size = riscv_estimate_digit (major)
+            + 1 /* '.' */
+            + riscv_estimate_digit (minor)
+            + 1; /* string terminator */
+  if (revision != 0)
+    {
+      buf_size += 1 /* '.' */
+                 + riscv_estimate_digit (revision);
+      buf = xmalloc (buf_size);
+      snprintf (buf, buf_size, "%d.%d.%d", major, minor, revision);
+    }
+  else
+    {
+      buf = xmalloc (buf_size);
+      snprintf (buf, buf_size, "%d.%d", major, minor);
+    }
+
+  result = riscv_get_priv_spec_class (buf, class);
+  free (buf);
+  return result;
+}
+
+/* Get the corresponding privilege version string by giving a CSR
+   version class.  */
+
+const char *
+riscv_get_priv_spec_name (enum riscv_priv_spec_class class)
+{
+  /* The first enum is PRIV_SPEC_CLASS_NONE.  */
+  return priv_specs[class - 1].name;
+}
index 7b8f09b82c4b11a2986ff958f4c839203369b561..c91b169e99e26fa5ece5c9289e2302409bffd094 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "elf/common.h"
 #include "elf/internal.h"
+#include "opcode/riscv.h"
 
 extern reloc_howto_type *
 riscv_reloc_name_lookup (bfd *, const char *);
@@ -109,3 +110,15 @@ typedef enum riscv_isa_ext_class
 
 riscv_isa_ext_class_t
 riscv_get_prefix_class (const char *);
+
+extern int
+riscv_get_priv_spec_class (const char *, enum riscv_priv_spec_class *);
+
+extern int
+riscv_get_priv_spec_class_from_numbers (unsigned int,
+                                       unsigned int,
+                                       unsigned int,
+                                       enum riscv_priv_spec_class *);
+
+extern const char *
+riscv_get_priv_spec_name (enum riscv_priv_spec_class);
index 56c2f63526937444c2c8758fa9ea2ea04c5e1f55..25d47147d66dfa14cd5abcb64c6e720c137fefb5 100644 (file)
@@ -1,3 +1,9 @@
+2020-06-22  Nelson Chu  <nelson.chu@sifive.com>
+
+       * config/tc-riscv.c (buf_size, buf): Remove the unused variables.
+       (riscv_set_default_priv_spec): Get the priv spec version from the
+       priv spec attributes by riscv_get_priv_spec_class_from_numbers.
+
 2020-06-20  Alan Modra  <amodra@gmail.com>
 
        * configure.tgt: Set bfd_gas for all SH targets.
index cc77dbf6c00a3c9fe769da654b657e0d276d6736..b6c8c4eb23e7bb9ca6b7e4eae6bc0594d8296312 100644 (file)
@@ -126,8 +126,6 @@ riscv_set_default_priv_spec (const char *s)
   enum riscv_priv_spec_class class;
   unsigned major, minor, revision;
   obj_attribute *attr;
-  size_t buf_size;
-  char *buf;
 
   /* Find the corresponding priv spec class.  */
   if (riscv_get_priv_spec_class (s, &class))
@@ -149,40 +147,24 @@ riscv_set_default_priv_spec (const char *s)
   minor = (unsigned) attr[Tag_RISCV_priv_spec_minor].i;
   revision = (unsigned) attr[Tag_RISCV_priv_spec_revision].i;
 
-  /* The priv attributes setting 0.0.0 is meaningless.  We should have set
-     the default_priv_spec by md_parse_option and riscv_after_parse_args,
-     so just skip the following setting.  */
-  if (major == 0 && minor == 0 && revision == 0)
-    return 1;
-
-  buf_size = riscv_estimate_digit (major)
-            + 1 /* '.' */
-            + riscv_estimate_digit (minor)
-            + 1; /* string terminator */
-  if (revision != 0)
+  if (riscv_get_priv_spec_class_from_numbers (major,
+                                             minor,
+                                             revision,
+                                             &class))
     {
-      buf_size += 1 /* '.' */
-                 + riscv_estimate_digit (revision);
-      buf = xmalloc (buf_size);
-      snprintf (buf, buf_size, "%d.%d.%d", major, minor, revision);
-    }
-  else
-    {
-      buf = xmalloc (buf_size);
-      snprintf (buf, buf_size, "%d.%d", major, minor);
-    }
+      /* The priv attributes setting 0.0.0 is meaningless.  We should have set
+        the default_priv_spec by md_parse_option and riscv_after_parse_args,
+        so just skip the following setting.  */
+      if (class == PRIV_SPEC_CLASS_NONE)
+       return 1;
 
-  if (riscv_get_priv_spec_class (buf, &class))
-    {
       default_priv_spec = class;
-      free (buf);
       return 1;
     }
 
   /* Still can not find the priv spec class.  */
   as_bad (_("Unknown default privilege spec `%d.%d.%d' set by  "
            "privilege attributes"),  major, minor, revision);
-  free (buf);
   return 0;
 }
 
index 7201be9f4d1ea64c882d6dfc0270cff0162d2734..65e8af867f9a18cf72099a6ab4192091fa7eeb3d 100644 (file)
@@ -1,3 +1,9 @@
+2020-06-22  Nelson Chu  <nelson.chu@sifive.com>
+
+       * opcode/riscv.h (riscv_get_priv_spec_class): Move the function
+       forward declarations to bfd/elfxx-riscv.h.
+       (riscv_get_priv_spec_name): Likewise.
+
 2020-06-15  Max Filippov  <jcmvbkbc@gmail.com>
 
        * elf/xtensa.h (xtensa_abi_choice): New declaration.
index f3bf173bde1689adfc65d1c2c98ea36b1fb92eae..ba993e7d34dd621bcb8da31bfbbadab7a9633a80 100644 (file)
@@ -490,9 +490,5 @@ extern const struct riscv_ext_version riscv_ext_version_table[];
 
 extern int
 riscv_get_isa_spec_class (const char *, enum riscv_isa_spec_class *);
-extern int
-riscv_get_priv_spec_class (const char *, enum riscv_priv_spec_class *);
-extern const char *
-riscv_get_priv_spec_name (enum riscv_priv_spec_class);
 
 #endif /* _RISCV_H_ */
index 5d460cfefa0951476456b340f9ca4b3dfc38c09b..b67cd518a6a4ef797c7b898e27c195e88143c597 100644 (file)
@@ -1,3 +1,12 @@
+2020-06-22  Nelson Chu  <nelson.chu@sifive.com>
+
+       * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Updated.
+       * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Updated.
+       * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Updated.
+       * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Updated.
+       * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Updated.
+       * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Updated.
+
 2020-06-21  Alan Modra  <amodra@gmail.com>
 
        * ldfile.c: Replace uses of ENABLE_PLUGINS with BFD_SUPPORTS_PLUGINS.
index c52ebac30199e3527d0e38f5c0b9d01756273813..0d5d6dc4a02e3ffb975a92925cb74ba58e50a23b 100644 (file)
@@ -2,4 +2,12 @@
 #source: attr-merge-priv-spec-c.s
 #as:
 #ld: -r
-#error: .*use privilege spec version 1.11.0 but the output use version 1.9.1.
+#warning: .*warning: .*use privilege spec version 1.11.0 but the output use version 1.9.1.
+#warning: .*warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
+#readelf: -A
+
+Attribute Section: riscv
+File Attributes
+  Tag_RISCV_arch: [a-zA-Z0-9_\"].*
+  Tag_RISCV_priv_spec: 1
+  Tag_RISCV_priv_spec_minor: 11
index fc001459c697be3f1efac61d37ed954f89cbfdd2..f0f75b2ba5a951091bbcd420a707beb5b972c116 100644 (file)
@@ -2,4 +2,12 @@
 #source: attr-merge-priv-spec-a.s
 #as:
 #ld: -r
-#error: .*use privilege spec version 1.9.1 but the output use version 1.11.0.
+#warning: .*warning: .*use privilege spec version 1.9.1 but the output use version 1.11.0.
+#warning: .*warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
+#readelf: -A
+
+Attribute Section: riscv
+File Attributes
+  Tag_RISCV_arch: [a-zA-Z0-9_\"].*
+  Tag_RISCV_priv_spec: 1
+  Tag_RISCV_priv_spec_minor: 11
index 1d40e905e3800aabbe751b59eccdd328c34a0389..af5155271e3b87cdb5589962d8fead8a9da348d3 100644 (file)
@@ -3,4 +3,12 @@
 #source: attr-merge-priv-spec-c.s
 #as:
 #ld: -r
-#error: .*use privilege spec version 1.11.0 but the output use version 1.9.1.
+#warning: .*warning: .*use privilege spec version 1.11.0 but the output use version 1.9.1.
+#warning: .*warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
+#readelf: -A
+
+Attribute Section: riscv
+File Attributes
+  Tag_RISCV_arch: [a-zA-Z0-9_\"].*
+  Tag_RISCV_priv_spec: 1
+  Tag_RISCV_priv_spec_minor: 11
index 0efee3ce24a8c7a2da936f2d5239515177216a79..2328807086190abbd8147faf24c4d93423e3f65f 100644 (file)
@@ -3,4 +3,12 @@
 #source: attr-merge-priv-spec-c.s
 #as:
 #ld: -r
-#error: .*use privilege spec version 1.11.0 but the output use version 1.9.1.
+#warning: .*warning: .*use privilege spec version 1.11.0 but the output use version 1.9.1.
+#warning: .*warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
+#readelf: -A
+
+Attribute Section: riscv
+File Attributes
+  Tag_RISCV_arch: [a-zA-Z0-9_\"].*
+  Tag_RISCV_priv_spec: 1
+  Tag_RISCV_priv_spec_minor: 11
index 5b9b8d08edc53547182f9b5e4d7d8c7edd4345df..cabaab68f54607ae21572bbf15369e8d2d7eabec 100644 (file)
@@ -3,4 +3,12 @@
 #source: attr-merge-priv-spec-a.s
 #as:
 #ld: -r
-#error: .*use privilege spec version 1.9.1 but the output use version 1.11.0.
+#warning: .*warning: .*use privilege spec version 1.9.1 but the output use version 1.11.0.
+#warning: .*warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
+#readelf: -A
+
+Attribute Section: riscv
+File Attributes
+  Tag_RISCV_arch: [a-zA-Z0-9_\"].*
+  Tag_RISCV_priv_spec: 1
+  Tag_RISCV_priv_spec_minor: 11
index dab7eb6b34d82c1ca9e2dd942cad8345a6305d00..e77474888806586055827a1061157c4ae80e5311 100644 (file)
@@ -3,4 +3,12 @@
 #source: attr-merge-priv-spec-a.s
 #as:
 #ld: -r
-#error: .*use privilege spec version 1.9.1 but the output use version 1.11.0.
+#warning: .*warning: .*use privilege spec version 1.9.1 but the output use version 1.11.0.
+#warning: .*warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
+#readelf: -A
+
+Attribute Section: riscv
+File Attributes
+  Tag_RISCV_arch: [a-zA-Z0-9_\"].*
+  Tag_RISCV_priv_spec: 1
+  Tag_RISCV_priv_spec_minor: 11
index 542b2c10867340da358bca88e5bd470cba7597da..ba0febec558108a3dc46f6d71c4a58a0642644ae 100644 (file)
@@ -1,3 +1,8 @@
+2020-06-22  Nelson Chu  <nelson.chu@sifive.com>
+
+       * riscv-opc.c: Move the structures and functions to bfd/elfxx-riscv.c.
+       * riscv-dis.c: Include elfxx-riscv.h.
+
 2020-06-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        * i386-dis.c (prefix_table): Revert the last vmgexit change.
index f26a46e0b34aa8c2e59530714f18d1126317a92b..0855de39e8e847a340ad930180b63f4bae5743d5 100644 (file)
@@ -27,6 +27,7 @@
 #include "opintl.h"
 #include "elf-bfd.h"
 #include "elf/riscv.h"
+#include "elfxx-riscv.h"
 
 #include "bfd_stdint.h"
 #include <ctype.h>
index 25b35baaf3c45e98acc04f0d72f4fcb0de4d4dfe..03e3bd7c054500f7e1ae523703143f768d7c137c 100644 (file)
@@ -977,53 +977,3 @@ riscv_get_isa_spec_class (const char *s,
   /* Can not find the supported ISA spec.  */
   return 0;
 }
-
-struct priv_spec_t
-{
-  const char *name;
-  enum riscv_priv_spec_class class;
-};
-
-/* List for all supported privilege versions.  */
-static const struct priv_spec_t priv_specs[] =
-{
-  {"1.9.1", PRIV_SPEC_CLASS_1P9P1},
-  {"1.10",  PRIV_SPEC_CLASS_1P10},
-  {"1.11",  PRIV_SPEC_CLASS_1P11},
-
-/* Terminate the list.  */
-  {NULL, 0}
-};
-
-/* Get the corresponding CSR version class by giving a privilege
-   version string.  */
-
-int
-riscv_get_priv_spec_class (const char *s,
-                          enum riscv_priv_spec_class *class)
-{
-  const struct priv_spec_t *version;
-
-  if (s == NULL)
-    return 0;
-
-  for (version = &priv_specs[0]; version->name != NULL; ++version)
-    if (strcmp (version->name, s) == 0)
-      {
-       *class = version->class;
-       return 1;
-      }
-
-  /* Can not find the supported privilege version.  */
-  return 0;
-}
-
-/* Get the corresponding privilege version string by giving a CSR
-   version class.  */
-
-const char *
-riscv_get_priv_spec_name (enum riscv_priv_spec_class class)
-{
-  /* The first enum is PRIV_SPEC_CLASS_NONE.  */
-  return priv_specs[class - 1].name;
-}
This page took 0.045212 seconds and 4 git commands to generate.