Home | History | Annotate | Line # | Download | only in bfd
elfxx-riscv.h revision 1.7
      1  1.1      matt /* RISC-V ELF specific backend routines.
      2  1.7  christos    Copyright (C) 2011-2024 Free Software Foundation, Inc.
      3  1.1      matt 
      4  1.3  christos    Contributed by Andrew Waterman (andrew (at) sifive.com).
      5  1.1      matt    Based on MIPS target.
      6  1.1      matt 
      7  1.1      matt    This file is part of BFD, the Binary File Descriptor library.
      8  1.1      matt 
      9  1.1      matt    This program is free software; you can redistribute it and/or modify
     10  1.1      matt    it under the terms of the GNU General Public License as published by
     11  1.1      matt    the Free Software Foundation; either version 3 of the License, or
     12  1.1      matt    (at your option) any later version.
     13  1.1      matt 
     14  1.1      matt    This program is distributed in the hope that it will be useful,
     15  1.1      matt    but WITHOUT ANY WARRANTY; without even the implied warranty of
     16  1.1      matt    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17  1.1      matt    GNU General Public License for more details.
     18  1.1      matt 
     19  1.1      matt    You should have received a copy of the GNU General Public License
     20  1.3  christos    along with this program; see the file COPYING3. If not,
     21  1.3  christos    see <http://www.gnu.org/licenses/>.  */
     22  1.1      matt 
     23  1.1      matt #include "elf/common.h"
     24  1.1      matt #include "elf/internal.h"
     25  1.6  christos #include "opcode/riscv.h"
     26  1.6  christos #include "cpu-riscv.h"
     27  1.6  christos 
     28  1.6  christos #define RISCV_UNKNOWN_VERSION -1
     29  1.1      matt 
     30  1.7  christos struct riscv_elf_params
     31  1.7  christos {
     32  1.7  christos   /* Whether to relax code sequences to GP-relative addressing.  */
     33  1.7  christos   bool relax_gp;
     34  1.7  christos   /* Whether to check if SUB_ULEB128 relocation has non-zero addend.  */
     35  1.7  christos   bool check_uleb128;
     36  1.7  christos };
     37  1.7  christos 
     38  1.7  christos extern void riscv_elf32_set_options (struct bfd_link_info *,
     39  1.7  christos 				     struct riscv_elf_params *);
     40  1.7  christos extern void riscv_elf64_set_options (struct bfd_link_info *,
     41  1.7  christos 				     struct riscv_elf_params *);
     42  1.7  christos 
     43  1.2      matt extern reloc_howto_type *
     44  1.2      matt riscv_reloc_name_lookup (bfd *, const char *);
     45  1.1      matt 
     46  1.2      matt extern reloc_howto_type *
     47  1.2      matt riscv_reloc_type_lookup (bfd *, bfd_reloc_code_real_type);
     48  1.1      matt 
     49  1.2      matt extern reloc_howto_type *
     50  1.4  christos riscv_elf_rtype_to_howto (bfd *, unsigned int r_type);
     51  1.5  christos 
     52  1.5  christos /* The information of architecture attribute.  */
     53  1.5  christos struct riscv_subset_t
     54  1.5  christos {
     55  1.5  christos   const char *name;
     56  1.5  christos   int major_version;
     57  1.5  christos   int minor_version;
     58  1.5  christos   struct riscv_subset_t *next;
     59  1.5  christos };
     60  1.5  christos 
     61  1.5  christos typedef struct riscv_subset_t riscv_subset_t;
     62  1.5  christos 
     63  1.6  christos typedef struct
     64  1.6  christos {
     65  1.5  christos   riscv_subset_t *head;
     66  1.5  christos   riscv_subset_t *tail;
     67  1.7  christos   const char *arch_str;
     68  1.5  christos } riscv_subset_list_t;
     69  1.5  christos 
     70  1.5  christos extern void
     71  1.5  christos riscv_release_subset_list (riscv_subset_list_t *);
     72  1.5  christos 
     73  1.5  christos extern void
     74  1.5  christos riscv_add_subset (riscv_subset_list_t *,
     75  1.5  christos 		  const char *,
     76  1.5  christos 		  int, int);
     77  1.5  christos 
     78  1.6  christos extern bool
     79  1.5  christos riscv_lookup_subset (const riscv_subset_list_t *,
     80  1.6  christos 		     const char *,
     81  1.6  christos 		     riscv_subset_t **);
     82  1.5  christos 
     83  1.6  christos typedef struct
     84  1.6  christos {
     85  1.5  christos   riscv_subset_list_t *subset_list;
     86  1.5  christos   void (*error_handler) (const char *,
     87  1.5  christos 			 ...) ATTRIBUTE_PRINTF_1;
     88  1.5  christos   unsigned *xlen;
     89  1.6  christos   enum riscv_spec_class *isa_spec;
     90  1.6  christos   bool check_unknown_prefixed_ext;
     91  1.5  christos } riscv_parse_subset_t;
     92  1.5  christos 
     93  1.6  christos extern bool
     94  1.5  christos riscv_parse_subset (riscv_parse_subset_t *,
     95  1.5  christos 		    const char *);
     96  1.5  christos 
     97  1.5  christos extern void
     98  1.5  christos riscv_release_subset_list (riscv_subset_list_t *);
     99  1.5  christos 
    100  1.5  christos extern char *
    101  1.5  christos riscv_arch_str (unsigned, const riscv_subset_list_t *);
    102  1.6  christos 
    103  1.6  christos extern size_t
    104  1.6  christos riscv_estimate_digit (unsigned);
    105  1.6  christos 
    106  1.6  christos extern int
    107  1.6  christos riscv_compare_subsets (const char *, const char *);
    108  1.6  christos 
    109  1.6  christos extern riscv_subset_list_t *
    110  1.6  christos riscv_copy_subset_list (riscv_subset_list_t *);
    111  1.6  christos 
    112  1.6  christos extern bool
    113  1.6  christos riscv_update_subset (riscv_parse_subset_t *, const char *);
    114  1.6  christos 
    115  1.6  christos extern bool
    116  1.6  christos riscv_subset_supports (riscv_parse_subset_t *, const char *);
    117  1.6  christos 
    118  1.6  christos extern bool
    119  1.6  christos riscv_multi_subset_supports (riscv_parse_subset_t *, enum riscv_insn_class);
    120  1.6  christos 
    121  1.6  christos extern const char *
    122  1.6  christos riscv_multi_subset_supports_ext (riscv_parse_subset_t *, enum riscv_insn_class);
    123  1.6  christos 
    124  1.6  christos extern void
    125  1.6  christos bfd_elf32_riscv_set_data_segment_info (struct bfd_link_info *, int *);
    126  1.6  christos extern void
    127  1.6  christos bfd_elf64_riscv_set_data_segment_info (struct bfd_link_info *, int *);
    128