403d1bd91d
bfd/ 2020-01-22 Maxim Blinov <maxim.blinov@embecosm.com> * bfd/elfnn-riscv.c (riscv_skip_prefix): New. (riscv_prefix_cmp): Likewise. (riscv_non_std_ext_p): Deleted. (riscv_std_sv_ext_p): Likewise. (riscv_non_std_sv_ext_p): Likewise. (riscv_merge_non_std_and_sv_ext): Rename to... (riscv_merge_multi_letter_ext): and modified to use riscv_prefix_cmp. (riscv_merge_arch_attr_info): Replace 3 calls to riscv_merge_non_std_and_sv_ext with single call to riscv_merge_multi_letter_ext. * bfd/elfxx-riscv.c (riscv_parse_std_ext): Break if we encounter a 'z' prefix. (riscv_get_prefix_class): New function, return prefix class based on first few characters of input string. (riscv_parse_config): New structure to factor out minor differences in extension class parsing behaviour. (riscv_parse_sv_or_non_std_ext): Rename to... (riscv_parse_prefixed_ext): and parameterise with riscv_parse_config. (riscv_std_z_ext_strtab, riscv_std_s_ext_strtab): New. (riscv_multi_letter_ext_valid_p): New. (riscv_ext_x_valid_p, riscv_ext_z_valid_p, riscv_ext_s_valid_p): New. (riscv_parse_subset): Delegate all non-single-letter parsing work to riscv_parse_prefixed_ext. * bfd/elfxx-riscv.h (riscv_isa_ext_class): New type. (riscv_get_prefix_class): Declare. gas/ 2020-01-22 Maxim Blinov <maxim.blinov@embecosm.com> * testsuite/gas/riscv/march-ok-s.d: sx is no longer valid and s exts must be known, so rename *ok* to *fail*. * testsuite/gas/riscv/march-ok-sx.d: Likewise. * testsuite/gas/riscv/march-ok-s-with-version: Likewise. * testsuite/gas/riscv/march-fail-s.l: Expected error messages for above change. * testsuite/gas/riscv/march-fail-sx.l: Likewise. * testsuite/gas/riscv/march-fail-sx-with-version.l: Likewise. Change-Id: Ic4d91a13d055a10d30ab28752a380a669b59f29c
106 lines
2.7 KiB
C
106 lines
2.7 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"
|
|
|
|
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_DONT_CARE_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 *);
|
|
|
|
extern riscv_subset_t *
|
|
riscv_lookup_subset_version (const riscv_subset_list_t *,
|
|
const char *,
|
|
int, int);
|
|
|
|
typedef struct {
|
|
riscv_subset_list_t *subset_list;
|
|
void (*error_handler) (const char *,
|
|
...) ATTRIBUTE_PRINTF_1;
|
|
unsigned *xlen;
|
|
} 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 *);
|
|
|
|
/* ISA extension name class. E.g. "zbb" corresponds to RV_ISA_CLASS_Z,
|
|
"xargs" corresponds to RV_ISA_CLASS_X, etc. Order is important
|
|
here. */
|
|
|
|
typedef enum riscv_isa_ext_class
|
|
{
|
|
RV_ISA_CLASS_S,
|
|
RV_ISA_CLASS_Z,
|
|
RV_ISA_CLASS_X,
|
|
RV_ISA_CLASS_UNKNOWN
|
|
} riscv_isa_ext_class_t;
|
|
|
|
/* Classify the argument 'ext' into one of riscv_isa_ext_class_t. */
|
|
|
|
riscv_isa_ext_class_t
|
|
riscv_get_prefix_class (const char *);
|