]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
RISC-V: Improve the error message for the mis-matched ISA versions.
authorKito Cheng <kito.cheng@sifive.com>
Tue, 7 Jul 2020 02:30:36 +0000 (19:30 -0700)
committerNelson Chu <nelson.chu@sifive.com>
Thu, 3 Sep 2020 03:11:38 +0000 (11:11 +0800)
Consider the updated attr-merge-arch-failed-01.d testcase.  Extension
A's version are mis-matched between attr-merge-arch-failed-01a.s and
attr-merge-arch-failed-01b.s.  But the old binutils reports that the
mis-matched extension is M rather than A.  This commit is used to fix
the wrong mis-matched error message.

Besides, when parsing the arch string in the riscv_parse_subset, it
shouldn't be NULL or empty.  However, it might be empty when we failed
to merge the arch string in the riscv_merge_attributes.  Since we should
already issue the correct error message in another side, and the message
- ISA string must begin with rv32 or rv64 - is meaninglesss when the arch
string is empty, so do not issue it.

bfd/
* elfnn-riscv.c (riscv_merge_std_ext): Fix to report the correct
error message when the versions of extension are mis-matched.
* elfxx-riscv.c (riscv_parse_subset): Don't issue the error when
the string is empty.

ld/
* testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s: Likewise.

bfd/ChangeLog
bfd/elfnn-riscv.c
bfd/elfxx-riscv.c
ld/ChangeLog
ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d
ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s
ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s

index 76055ba18f2a3f5c6d9676ad635ccab9a30be94d..8703aebeb3464f5998e8407272289c0ea9cc2fbf 100644 (file)
@@ -1,3 +1,10 @@
+2020-09-03  Kito Cheng  <kito.cheng@sifive.com>
+
+       * elfnn-riscv.c (riscv_merge_std_ext): Fix to report the correct
+       error message when the versions of extension are mis-matched.
+       * elfxx-riscv.c (riscv_parse_subset): Don't issue the error when
+       the string is empty.
+
 2020-09-03  Alan Modra  <amodra@gmail.com>
 
        * xcofflink.c (xcoff_get_archive_info): Allocate xcoff_archive_info
index 8a3338c4728c68bcf03b13f074b05076b07d1e01..f8de7194ea65edcd8d8e8422cb45117e7931c05e 100644 (file)
@@ -2724,7 +2724,7 @@ riscv_merge_std_ext (bfd *ibfd,
          && ((find_in->major_version != find_out->major_version)
              || (find_in->minor_version != find_out->minor_version)))
        {
-         riscv_version_mismatch (ibfd, in, out);
+         riscv_version_mismatch (ibfd, find_in, find_out);
          return FALSE;
        }
 
index 1570f1d862904869c04c21cc88e876aec1c3be02..cfdd867e0dec697202d994d4c8eb9b1f50e5e65d 100644 (file)
@@ -1519,9 +1519,15 @@ riscv_parse_subset (riscv_parse_subset_t *rps,
     }
   else
     {
-      rps->error_handler
-       (_("-march=%s: ISA string must begin with rv32 or rv64"),
-        arch);
+      /* Arch string shouldn't be NULL or empty here.  However,
+        it might be empty only when we failed to merge the arch
+        string in the riscv_merge_attributes.  We have already
+        issued the correct error message in another side, so do
+        not issue this error when the arch string is empty.  */
+      if (strlen (arch))
+       rps->error_handler (
+         _("-march=%s: ISA string must begin with rv32 or rv64"),
+         arch);
       return FALSE;
     }
 
index 6c447dd4af07246fde6cf5829d15d17ebf0cbc96..4bba88474378f52faade677ffae297117835dc26 100644 (file)
@@ -1,3 +1,9 @@
+2020-09-03  Kito Cheng  <kito.cheng@sifive.com>
+
+       * testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Updated.
+       * testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s: Likewise.
+       * testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s: Likewise.
+
 2020-09-03  Alan Modra  <amodra@gmail.com>
 
        * testsuite/ld-scripts/sysroot-prefix.exp (single_sysroot_prefix_test):
index c77f80b6bff249ceaa525e24e055204c533108da..8a9c0929f80b4f315f10b967fefdfa300ff9b3dc 100644 (file)
@@ -2,4 +2,4 @@
 #source: attr-merge-arch-failed-01b.s
 #as: -march-attr
 #ld: -r -melf32lriscv
-#error: Mis-matched ISA version for 'm' extension. 3.0 vs 2.0
+#error: Mis-matched ISA version for 'a' extension. 3.0 vs 2.0
index acc98a53cf5021416313e085fd9fe8cd2d57571f..365901d8dc15d6d6c331bf2db461437555cc8a78 100644 (file)
@@ -1 +1 @@
-       .attribute arch, "rv32i2p0_m2p0"
+       .attribute arch, "rv32i2p0_m2p0_a2p0"
index c9a590a9d937edf71188bd409171265fb559538b..49263bf66d4cfce8eac3d0595288f7e2c5d82e85 100644 (file)
@@ -1 +1 @@
-       .attribute arch, "rv32i2p0_m3p0"
+       .attribute arch, "rv32i2p0_m2p0_a3p0"