summaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorNelson Chu <nelson.chu@sifive.com>2020-06-12 23:06:49 +0800
committerNelson Chu <nelson.chu@sifive.com>2020-06-22 10:01:14 +0800
commit39ff0b812324f4b050bb0b367b269db6d4d0cb8b (patch)
treed26141dff4583849bf6a8e99c6ea7458b9dcd0a8 /opcodes
parentcbd7581f343d85b4216db2eefdf601f6d988062d (diff)
downloadbinutils-gdb-39ff0b812324f4b050bb0b367b269db6d4d0cb8b.tar.gz
RISC-V: Report warning when linking the objects with different priv specs.
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.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/ChangeLog5
-rw-r--r--opcodes/riscv-dis.c1
-rw-r--r--opcodes/riscv-opc.c50
3 files changed, 6 insertions, 50 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 542b2c10867..ba0febec558 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -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.
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index f26a46e0b34..0855de39e8e 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -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>
diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c
index 25b35baaf3c..03e3bd7c054 100644
--- a/opcodes/riscv-opc.c
+++ b/opcodes/riscv-opc.c
@@ -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;
-}