aboutsummaryrefslogtreecommitdiff
path: root/gas/config
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 /gas/config
parentcbd7581f343d85b4216db2eefdf601f6d988062d (diff)
downloadgdb-39ff0b812324f4b050bb0b367b269db6d4d0cb8b.zip
gdb-39ff0b812324f4b050bb0b367b269db6d4d0cb8b.tar.gz
gdb-39ff0b812324f4b050bb0b367b269db6d4d0cb8b.tar.bz2
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 'gas/config')
-rw-r--r--gas/config/tc-riscv.c36
1 files changed, 9 insertions, 27 deletions
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index cc77dbf..b6c8c4e 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -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;
}