mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-12 03:43:33 +08:00
7ef19aa616
Keep the riscv_add_subset to do the same thing, and use a new function, riscv_parse_add_subset, to cover most of the things when parsing, including find the default versions for extensions, and check whether the versions are valid. The version 0p0 should be an invalid version, that is the mistake I made before. This patch clarify the version rules as follows, * We accept any version of extensions set by users, except 0p0. * The non-standard x extensions must be set with versions in arch string. * If user don't set the versions, or set 0p0 for the extensions, then try to find the supported versions according to the chosen ISA spec. Otherwise, report errors rather than output 0p0 for them. Besides, we use as_bad rather than as_fatal to report more errors for assembler. bfd/ * elfxx-riscv.c (riscv_lookup_subset): Moved to front. (riscv_add_subset): Likewise. (riscv_release_subset_list): Likewise. (riscv_parse_add_subset): New function. Find and check the versions before adding them by riscv_add_subset. (riscv_parsing_subset_version): Remove use_default_version and change the version type from unsigned to int. Set the versions to RISCV_UNKNOWN_VERSION if we can not find them in the arch string. (riscv_parse_std_ext): Updated. (riscv_parse_prefixed_ext): Updated. Since we use as_bad rather than as_fatal to report more errors, return NULL string if the parsed end_of_version is NULL, too. (riscv_parse_subset): Use a new boolean, no_conflict, to report more errors when we have more than one ISA conflicts. * elfxx-riscv.h (RISCV_DONT_CARE_VERSION): Changed to RISCV_UNKNOWN_VERSION. (riscv_lookup_subset_version): Removed. (riscv_parse_subset_t): Updated. gas/ * config/tc-riscv.c (riscv_get_default_ext_version): Change the version type from unsigned to int. (riscv_set_arch): Use as_bad rather than as_fatal to report more errors. * testsuite/gas/riscv/attribute-02.d: Updated since x must be set with versions. * testsuite/gas/riscv/attribute-03.d: Likewise. * testsuite/gas/riscv/march-ok-two-nse.d: Likewise. * testsuite/gas/riscv/attribute-09.d: zicsr wasn't supported in the spec 2.2, so choose the newer spec. * testsuite/gas/riscv/march-fail-base-01.l: Updated since as_bad. * testsuite/gas/riscv/march-fail-base-02.l: Likewise. * testsuite/gas/riscv/march-fail-order-std.l: Likewise. * testsuite/gas/riscv/march-fail-order-x.l: Likewise. * testsuite/gas/riscv/march-fail-order-z.l: Likewise. * testsuite/gas/riscv/march-fail-porder.l: Likewise. * testsuite/gas/riscv/march-fail-rv32ef.l: Likewise. * testsuite/gas/riscv/march-fail-rv32id.l: Likewise. * testsuite/gas/riscv/march-fail-rv32iq.l: Likewise. * testsuite/gas/riscv/march-fail-rv64iq.l: Likewise. * testsuite/gas/riscv/march-fail-single-char.l: Likewise. * testsuite/gas/riscv/march-fail-unknown-std.l: Likewise. * testsuite/gas/riscv/march-fail-unknown.l: Likewise. * testsuite/gas/riscv/march-fail-uppercase.l: Likewise. * testsuite/gas/riscv/march-fail-version.l: Likewise. * testsuite/gas/riscv/march-fail-isa-spec.d: Likewise. * testsuite/gas/riscv/march-fail-isa-spec.l: Likewise. include/ * opcode/riscv.h (riscv_ext_version): Change the version type from unsigned to int.
120 lines
3.0 KiB
C
120 lines
3.0 KiB
C
/* RISC-V ELF specific backend routines.
|
|
Copyright (C) 2011-2020 Free Software Foundation, Inc.
|
|
|
|
Contributed by Andrew Waterman (andrew@sifive.com).
|
|
Based on MIPS target.
|
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; see the file COPYING3. If not,
|
|
see <http://www.gnu.org/licenses/>. */
|
|
|
|
#include "elf/common.h"
|
|
#include "elf/internal.h"
|
|
#include "opcode/riscv.h"
|
|
|
|
extern reloc_howto_type *
|
|
riscv_reloc_name_lookup (bfd *, const char *);
|
|
|
|
extern reloc_howto_type *
|
|
riscv_reloc_type_lookup (bfd *, bfd_reloc_code_real_type);
|
|
|
|
extern reloc_howto_type *
|
|
riscv_elf_rtype_to_howto (bfd *, unsigned int r_type);
|
|
|
|
#define RISCV_UNKNOWN_VERSION -1
|
|
|
|
/* The information of architecture attribute. */
|
|
struct riscv_subset_t
|
|
{
|
|
const char *name;
|
|
int major_version;
|
|
int minor_version;
|
|
struct riscv_subset_t *next;
|
|
};
|
|
|
|
typedef struct riscv_subset_t riscv_subset_t;
|
|
|
|
typedef struct
|
|
{
|
|
riscv_subset_t *head;
|
|
riscv_subset_t *tail;
|
|
} riscv_subset_list_t;
|
|
|
|
extern void
|
|
riscv_release_subset_list (riscv_subset_list_t *);
|
|
|
|
extern void
|
|
riscv_add_subset (riscv_subset_list_t *,
|
|
const char *,
|
|
int, int);
|
|
|
|
extern riscv_subset_t *
|
|
riscv_lookup_subset (const riscv_subset_list_t *,
|
|
const char *);
|
|
|
|
typedef struct
|
|
{
|
|
riscv_subset_list_t *subset_list;
|
|
void (*error_handler) (const char *,
|
|
...) ATTRIBUTE_PRINTF_1;
|
|
unsigned *xlen;
|
|
void (*get_default_version) (const char *,
|
|
int *,
|
|
int *);
|
|
} riscv_parse_subset_t;
|
|
|
|
extern bfd_boolean
|
|
riscv_parse_subset (riscv_parse_subset_t *,
|
|
const char *);
|
|
|
|
extern const char *
|
|
riscv_supported_std_ext (void);
|
|
|
|
extern void
|
|
riscv_release_subset_list (riscv_subset_list_t *);
|
|
|
|
extern char *
|
|
riscv_arch_str (unsigned, const riscv_subset_list_t *);
|
|
|
|
extern size_t
|
|
riscv_estimate_digit (unsigned);
|
|
|
|
/* ISA extension name class. E.g. "zbb" corresponds to RV_ISA_CLASS_Z,
|
|
"xargs" corresponds to RV_ISA_CLASS_X, etc. */
|
|
|
|
typedef enum riscv_isa_ext_class
|
|
{
|
|
RV_ISA_CLASS_S,
|
|
RV_ISA_CLASS_H,
|
|
RV_ISA_CLASS_Z,
|
|
RV_ISA_CLASS_X,
|
|
RV_ISA_CLASS_UNKNOWN
|
|
} riscv_isa_ext_class_t;
|
|
|
|
riscv_isa_ext_class_t
|
|
riscv_get_prefix_class (const char *);
|
|
|
|
extern int
|
|
riscv_get_priv_spec_class (const char *, enum riscv_priv_spec_class *);
|
|
|
|
extern int
|
|
riscv_get_priv_spec_class_from_numbers (unsigned int,
|
|
unsigned int,
|
|
unsigned int,
|
|
enum riscv_priv_spec_class *);
|
|
|
|
extern const char *
|
|
riscv_get_priv_spec_name (enum riscv_priv_spec_class);
|