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

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.
This commit is contained in:
Nelson Chu 2021-04-13 12:32:16 +08:00
parent 8d85d1f53f
commit e3839c100f
4 changed files with 33 additions and 17 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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))

View File

@ -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 *);