mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-11 19:33:33 +08:00
d3ffd7f776
https://github.com/riscv/riscv-asm-manual/pull/67 Format: .option arch, +<extension><version>, ... .option arch, -<extension> .option arch, =<ISA string> The new direcitve is used to enable/disable extensions for the specific code region. For example, .attribute arch, "rv64ic" # arch = rv64i2p0_c2p0 .option push .option arch, +d2p0, -c # arch = rv64i2p0_f2p0_d2p0, f is added implied .option arch, =rv32gc # arch = rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0 .option pop # arch = rv64i2p0_c2p0 Note that, 1. ".option rvc/norvc" have the same behavior as ".option arch +c/-c". 2. ".option arch -i" is illegal, since we cannot remove base i extension. 3. If arch=rv64i2p0, then ".option arch, +i3p0" will update the i's version from 2.0 to 3.0. 4. If arch=rv64i3p0, then ".option arch, +i" will update the i's version from 2.0 to the default one according to the chosen isa spec. bfd/ * elfxx-riscv.c (riscv_add_subset): If the subset is already added, and the new versions are not RISCV_UNKNOWN_VERSION, then update the versions to the subset list. (riscv_copy_subset): New function. Copy the subset from list. (riscv_copy_subset_list): New function. Return the new copyed list. (riscv_update_subset): Updated to make .option arch directives workable. * elfxx-riscv.h: Updated. gas/ * config/tc-riscv.c (riscv_subsets): Defined as a pointer. (riscv_rps_as): Init the subset_list to NULL, we will set it later once riscv_opts_stack is created or updated. (struct riscv_option_stack, riscv_opts_stack): Moved forward. (riscv_set_arch): Updated. (s_riscv_option): Support new .option arch directive, to add, remove or update subsets for the specific code region. (riscv_write_out_attrs): Updated. * doc/c-riscv.texi: Added document for new .option arch directive. * testsuite/gas/riscv/option-arch-01a.d: New testcase. * testsuite/gas/riscv/option-arch-01b.d: Likewise. * testsuite/gas/riscv/option-arch-01.s: Likewise.. * testsuite/gas/riscv/option-arch-02.d: Likewise. * testsuite/gas/riscv/option-arch-02.s: Likewise. * testsuite/gas/riscv/option-arch-fail.d: Likewise. * testsuite/gas/riscv/option-arch-fail.l: Likewise. * testsuite/gas/riscv/option-arch-fail.s: Likewise.
111 lines
2.8 KiB
C
111 lines
2.8 KiB
C
/* RISC-V ELF specific backend routines.
|
|
Copyright (C) 2011-2021 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"
|
|
#include "cpu-riscv.h"
|
|
|
|
#define RISCV_UNKNOWN_VERSION -1
|
|
|
|
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);
|
|
|
|
/* 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 bool
|
|
riscv_lookup_subset (const riscv_subset_list_t *,
|
|
const char *,
|
|
riscv_subset_t **);
|
|
|
|
typedef struct
|
|
{
|
|
riscv_subset_list_t *subset_list;
|
|
void (*error_handler) (const char *,
|
|
...) ATTRIBUTE_PRINTF_1;
|
|
unsigned *xlen;
|
|
enum riscv_spec_class *isa_spec;
|
|
bool check_unknown_prefixed_ext;
|
|
} riscv_parse_subset_t;
|
|
|
|
extern bool
|
|
riscv_parse_subset (riscv_parse_subset_t *,
|
|
const char *);
|
|
|
|
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);
|
|
|
|
extern int
|
|
riscv_compare_subsets (const char *, const char *);
|
|
|
|
extern riscv_subset_list_t *
|
|
riscv_copy_subset_list (riscv_subset_list_t *);
|
|
|
|
extern bool
|
|
riscv_update_subset (riscv_parse_subset_t *, const char *);
|
|
|
|
extern bool
|
|
riscv_subset_supports (riscv_parse_subset_t *, const char *);
|
|
|
|
extern bool
|
|
riscv_multi_subset_supports (riscv_parse_subset_t *, enum riscv_insn_class);
|
|
|
|
extern void
|
|
bfd_elf32_riscv_set_data_segment_info (struct bfd_link_info *, int *);
|
|
extern void
|
|
bfd_elf64_riscv_set_data_segment_info (struct bfd_link_info *, int *);
|