[committed] RISC-V: Don't report the mismatched version warning for the implicit extensions.

Message ID 1618292366-26345-1-git-send-email-nelson.chu@sifive.com
State New
Headers show
Series
  • [committed] RISC-V: Don't report the mismatched version warning for the implicit extensions.
Related show

Commit Message

Nelson Chu April 13, 2021, 5:39 a.m.
bfd/
    * elfnn-riscv.c (riscv_version_mismatch): Do not report the warning
    when the version of input or output is RISCV_UNKNOWN_VERSION, since
    the extension is added implicitly.
    * elfxx-riscv.c: Updated the obsolete comments.
    (RISCV_UNKNOWN_VERSION): Moved to elfxx-riscv.h.
    * elfxx-riscv.h (RISCV_UNKNOWN_VERSION): Added.
---
 bfd/ChangeLog     |  9 +++++++++
 bfd/elfnn-riscv.c | 28 +++++++++++++++++++---------
 bfd/elfxx-riscv.c | 11 +++--------
 bfd/elfxx-riscv.h |  2 ++
 4 files changed, 33 insertions(+), 17 deletions(-)

-- 
2.7.4

Patch

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index fa7e649..28c5791 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@ 
+2021-04-13  Nelson Chu  <nelson.chu@sifive.com>
+
+	* elfnn-riscv.c (riscv_version_mismatch): Do not report the warning
+	when the version of input or output is RISCV_UNKNOWN_VERSION, since
+	the extension is added implicitly.
+	* elfxx-riscv.c: Updated the obsolete comments.
+	(RISCV_UNKNOWN_VERSION): Moved to elfxx-riscv.h.
+	* elfxx-riscv.h (RISCV_UNKNOWN_VERSION): Added.
+
 2021-04-12  Alan Modra  <amodra@gmail.com>
 
 	* elf-bfd.h (ENABLE_CHECKING): Define.
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 07089ef7..5e29278 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -3332,15 +3332,25 @@  riscv_version_mismatch (bfd *ibfd,
   if (in->major_version != out->major_version
       || in->minor_version != out->minor_version)
     {
-      _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);
+      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)
diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 13719e5..3b38192 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1026,8 +1026,6 @@  riscv_elf_add_sub_reloc (bfd *abfd,
   return bfd_reloc_ok;
 }
 
-#define RISCV_UNKNOWN_VERSION -1
-
 /* Lists of prefixed class extensions that binutils should know about.
    Whether or not a particular entry is in these lists will dictate if
    gas/ld will accept its presence in the architecture string.
@@ -1588,9 +1586,7 @@  riscv_parse_std_ext (riscv_parse_subset_t *rps,
    Arguments:
      `rps`: Hooks and status for parsing extensions.
      `march`: Full ISA string.
-     `p`: Curent parsing position.
-     `config`: What class and predicate function to use for the
-     extension.  */
+     `p`: Curent parsing position.  */
 
 static const char *
 riscv_parse_prefixed_ext (riscv_parse_subset_t *rps,
@@ -1640,9 +1636,8 @@  riscv_parse_prefixed_ext (riscv_parse_subset_t *rps,
 
       /* Check if the prefix extension is known.
 	 For 'x', anything goes but it cannot simply be 'x'.
-	 For 's', it must be known from a list and cannot simply be 's'.
-	 For 'h', it must be known from a list and cannot simply be 'h'.
-	 For 'z', it must be known from a list and cannot simply be 'z'.  */
+	 For other prefixed extensions, it must be known from a list
+	 and cannot simply be the prefixed name.  */
 
       /* Check that the extension name is well-formed.  */
       if (!riscv_valid_prefixed_ext (subset))
diff --git a/bfd/elfxx-riscv.h b/bfd/elfxx-riscv.h
index 2955b75..ff18ff6 100644
--- a/bfd/elfxx-riscv.h
+++ b/bfd/elfxx-riscv.h
@@ -24,6 +24,8 @@ 
 #include "elf/internal.h"
 #include "opcode/riscv.h"
 
+#define RISCV_UNKNOWN_VERSION -1
+
 extern reloc_howto_type *
 riscv_reloc_name_lookup (bfd *, const char *);