diff options
author | Nelson Chu <nelson.chu@sifive.com> | 2021-12-09 11:52:16 +0800 |
---|---|---|
committer | Nelson Chu <nelson.chu@sifive.com> | 2021-12-09 15:55:04 +0800 |
commit | de3a913df6e0af6d6d88ecd308407971a44eae9e (patch) | |
tree | 14e77968337e32f78b93c63059b89c461037b5aa /bfd/elfxx-riscv.c | |
parent | de8a2781a57ecb4a852fb5b734bc7ce71bad34c9 (diff) | |
download | gdb-de3a913df6e0af6d6d88ecd308407971a44eae9e.zip gdb-de3a913df6e0af6d6d88ecd308407971a44eae9e.tar.gz gdb-de3a913df6e0af6d6d88ecd308407971a44eae9e.tar.bz2 |
RISC-V: Clarify the behavior of .option arch directive.
* To be consistent with -march option, removed the "=" operator when
user want to reset the whole architecture string. So the formats are,
.option arch, +<extension><version>, ...
.option arch, -<extension>
.option arch, <ISA string>
* Don't allow to add or remove the base extensions in the .option arch
directive. Instead, users should reset the whole architecture string
while they want to change the base extension.
* The operator "+" won't update the version of extension, if the
extension is already in the subset list.
bfd/
* elfxx-riscv.c (riscv_add_subset): Don't update the version
if the extension is already in the subset list.
(riscv_update_subset): To be consistent with -march option,
removed the "=" operator when user want to reset the whole
architecture string. Besides, Don't allow to add or remove
the base extensions in the .option arch directive.
gas/
* testsuite/gas/riscv/option-arch-01.s: Updated since we cannot
add or remove the base extensions in the .option arch directive.
* testsuite/gas/riscv/option-arch-02.s: Likewise.
* testsuite/gas/riscv/option-arch-fail.l: Likewise.
* testsuite/gas/riscv/option-arch-fail.s: Likewise.
* testsuite/gas/riscv/option-arch-01a.d: Set -misa-spec=2.2.
* testsuite/gas/riscv/option-arch-01b.d: Likewise.
* testsuite/gas/riscv/option-arch-02.d: Updated since the .option
arch, + won't change the version of extension, if the extension is
already in the subset list.
* testsuite/gas/riscv/option-arch-03.s: Removed the "=" operator
when resetting the whole architecture string.
Diffstat (limited to 'bfd/elfxx-riscv.c')
-rw-r--r-- | bfd/elfxx-riscv.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index 3bd41ff..8c44c4a 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -1468,15 +1468,7 @@ riscv_add_subset (riscv_subset_list_t *subset_list, riscv_subset_t *current, *new; if (riscv_lookup_subset (subset_list, subset, ¤t)) - { - if (major != RISCV_UNKNOWN_VERSION - && minor != RISCV_UNKNOWN_VERSION) - { - current->major_version = major; - current->minor_version = minor; - } - return; - } + return; new = xmalloc (sizeof *new); new->name = xstrdup (subset); @@ -2217,18 +2209,15 @@ riscv_update_subset (riscv_parse_subset_t *rps, int minor_version = RISCV_UNKNOWN_VERSION; bool removed = false; - switch (*p++) + switch (*p) { case '+': removed = false; break; case '-': removed = true; break; - case '=': + default: riscv_release_subset_list (rps->subset_list); return riscv_parse_subset (rps, p); - default: - rps->error_handler - (_("extensions must begin with +/-/= in .option arch `%s'"), str); - return false; } + ++p; char *subset = xstrdup (p); char *q = subset; @@ -2293,17 +2282,19 @@ riscv_update_subset (riscv_parse_subset_t *rps, return false; } - if (removed) + if (strcmp (subset, "i") == 0 + || strcmp (subset, "e") == 0 + || strcmp (subset, "g") == 0) { - if (strcmp (subset, "i") == 0) - { - rps->error_handler - (_("cannot remove extension `i' in .option arch `%s'"), str); - free (subset); - return false; - } - riscv_remove_subset (rps->subset_list, subset); + rps->error_handler + (_("cannot + or - base extension `%s' in .option " + "arch `%s'"), subset, str); + free (subset); + return false; } + + if (removed) + riscv_remove_subset (rps->subset_list, subset); else riscv_parse_add_subset (rps, subset, major_version, minor_version, true); p += end_of_version - subset; |