aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfnn-riscv.c
diff options
context:
space:
mode:
authorPalmer Dabbelt <palmer@rivosinc.com>2022-02-07 12:14:30 -0800
committerPalmer Dabbelt <palmer@rivosinc.com>2022-02-08 08:23:28 -0800
commit87fdd7ac09b1c3cfd7443a3ffc5abb9bb178bc6e (patch)
treec03e2f879052249179318dde222bb0a6bdaf40ed /bfd/elfnn-riscv.c
parent481153777e278b71e694fd2db6b897f7a9e3dcb8 (diff)
downloadgdb-87fdd7ac09b1c3cfd7443a3ffc5abb9bb178bc6e.zip
gdb-87fdd7ac09b1c3cfd7443a3ffc5abb9bb178bc6e.tar.gz
gdb-87fdd7ac09b1c3cfd7443a3ffc5abb9bb178bc6e.tar.bz2
RISC-V: Stop reporting warnings for mismatched extension versions
The extension version checking logic is really just too complicated to encode into the linker, trying to do so causes more harm than good. This removes the checks and the associated tests, leaving the logic to keep the largest version of each extension linked into the target. bfd/ * elfnn-riscv.c (riscv_version_mismatch): Rename to riscv_update_subset_version, and stop reporting warnings on version mismatches. (riscv_merge_std_ext): Adjust calls to riscv_version_mismatch. (riscv_merge_multi_letter_ext): Likewise. ld/ * testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Remove * testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s: Likewise * testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s: Likewise * testsuite/ld-riscv-elf/attr-merge-arch-failed-02.d: Likewise * testsuite/ld-riscv-elf/attr-merge-arch-failed-02a.s: Likewise * testsuite/ld-riscv-elf/attr-merge-arch-failed-02b.s: Likewise * testsuite/ld-riscv-elf/attr-merge-arch-failed-02c.s: Likewise * testsuite/ld-riscv-elf/attr-merge-arch-failed-02d.s: Likewise * testsuite/ld-riscv-elf/attr-merge-user-ext-01.d: New test. * testsuite/ld-riscv-elf/attr-merge-user-ext-rv32i21_m2p0.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-user-ext-rv32i21_m2p1.s: Likewise. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Remove obselete attr-merge-arch-failed-{01,02}, replace with attr-merge-user-ext-01. Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'bfd/elfnn-riscv.c')
-rw-r--r--bfd/elfnn-riscv.c78
1 files changed, 24 insertions, 54 deletions
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 95fcc77..8f9f0d8 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -3371,52 +3371,27 @@ riscv_std_ext_p (const char *name)
return (strlen (name) == 1) && (name[0] != 'x') && (name[0] != 's');
}
-/* Check if the versions are compatible. */
+/* Update the output subset's version to match the input when the input
+ subset's version is newer. */
-static bool
-riscv_version_mismatch (bfd *ibfd,
- struct riscv_subset_t *in,
- struct riscv_subset_t *out)
+static void
+riscv_update_subset_version (struct riscv_subset_t *in,
+ struct riscv_subset_t *out)
{
if (in == NULL || out == NULL)
- return true;
+ return;
- /* Since there are no version conflicts for now, we just report
- warning when the versions are mis-matched. */
- if (in->major_version != out->major_version
- || in->minor_version != out->minor_version)
+ /* Update the output ISA versions to the newest ones, but otherwise don't
+ provide any errors or warnings about mis-matched ISA versions as it's
+ generally too tricky to check for these at link time. */
+ if ((in->major_version > out->major_version)
+ || (in->major_version == out->major_version
+ && in->minor_version > out->minor_version)
+ || (out->major_version == RISCV_UNKNOWN_VERSION))
{
- if ((in->major_version == RISCV_UNKNOWN_VERSION
- && in->minor_version == RISCV_UNKNOWN_VERSION)
- || (out->major_version == RISCV_UNKNOWN_VERSION
- && out->minor_version == RISCV_UNKNOWN_VERSION))
- {
- /* Do not report the warning when the version of input
- or output is RISCV_UNKNOWN_VERSION, since the extension
- is added implicitly. */
- }
- else
- _bfd_error_handler
- (_("warning: %pB: mis-matched ISA version %d.%d for '%s' "
- "extension, the output version is %d.%d"),
- ibfd,
- in->major_version,
- in->minor_version,
- in->name,
- out->major_version,
- out->minor_version);
-
- /* Update the output ISA versions to the newest ones. */
- if ((in->major_version > out->major_version)
- || (in->major_version == out->major_version
- && in->minor_version > out->minor_version))
- {
- out->major_version = in->major_version;
- out->minor_version = in->minor_version;
- }
+ out->major_version = in->major_version;
+ out->minor_version = in->minor_version;
}
-
- return true;
}
/* Return true if subset is 'i' or 'e'. */
@@ -3477,11 +3452,10 @@ riscv_merge_std_ext (bfd *ibfd,
ibfd, in->name, out->name);
return false;
}
- else if (!riscv_version_mismatch (ibfd, in, out))
- return false;
- else
- riscv_add_subset (&merged_subsets,
- out->name, out->major_version, out->minor_version);
+
+ riscv_update_subset_version(in, out);
+ riscv_add_subset (&merged_subsets,
+ out->name, out->major_version, out->minor_version);
in = in->next;
out = out->next;
@@ -3499,10 +3473,8 @@ riscv_merge_std_ext (bfd *ibfd,
if (!find_in && !find_out)
continue;
- if (find_in
- && find_out
- && !riscv_version_mismatch (ibfd, ext_in, ext_out))
- return false;
+ if (find_in && find_out)
+ riscv_update_subset_version(ext_in, ext_out);
ext_merged = find_out ? ext_out : ext_in;
riscv_add_subset (&merged_subsets, ext_merged->name,
@@ -3524,8 +3496,7 @@ riscv_merge_std_ext (bfd *ibfd,
on success and FALSE when a conflict is found. */
static bool
-riscv_merge_multi_letter_ext (bfd *ibfd,
- riscv_subset_t **pin,
+riscv_merge_multi_letter_ext (riscv_subset_t **pin,
riscv_subset_t **pout)
{
riscv_subset_t *in = *pin;
@@ -3555,8 +3526,7 @@ riscv_merge_multi_letter_ext (bfd *ibfd,
else
{
/* Both present, check version and increment both. */
- if (!riscv_version_mismatch (ibfd, in, out))
- return false;
+ riscv_update_subset_version (in, out);
riscv_add_subset (&merged_subsets, out->name, out->major_version,
out->minor_version);
@@ -3629,7 +3599,7 @@ riscv_merge_arch_attr_info (bfd *ibfd, char *in_arch, char *out_arch)
return NULL;
/* Merge all non-single letter extensions with single call. */
- if (!riscv_merge_multi_letter_ext (ibfd, &in, &out))
+ if (!riscv_merge_multi_letter_ext (&in, &out))
return NULL;
if (xlen_in != xlen_out)