elfxx-riscv.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* RISC-V ELF specific backend routines.
  2. Copyright (C) 2011-2022 Free Software Foundation, Inc.
  3. Contributed by Andrew Waterman (andrew@sifive.com).
  4. Based on MIPS target.
  5. This file is part of BFD, the Binary File Descriptor library.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; see the file COPYING3. If not,
  16. see <http://www.gnu.org/licenses/>. */
  17. #include "elf/common.h"
  18. #include "elf/internal.h"
  19. #include "opcode/riscv.h"
  20. #include "cpu-riscv.h"
  21. #define RISCV_UNKNOWN_VERSION -1
  22. extern reloc_howto_type *
  23. riscv_reloc_name_lookup (bfd *, const char *);
  24. extern reloc_howto_type *
  25. riscv_reloc_type_lookup (bfd *, bfd_reloc_code_real_type);
  26. extern reloc_howto_type *
  27. riscv_elf_rtype_to_howto (bfd *, unsigned int r_type);
  28. /* The information of architecture attribute. */
  29. struct riscv_subset_t
  30. {
  31. const char *name;
  32. int major_version;
  33. int minor_version;
  34. struct riscv_subset_t *next;
  35. };
  36. typedef struct riscv_subset_t riscv_subset_t;
  37. typedef struct
  38. {
  39. riscv_subset_t *head;
  40. riscv_subset_t *tail;
  41. } riscv_subset_list_t;
  42. extern void
  43. riscv_release_subset_list (riscv_subset_list_t *);
  44. extern void
  45. riscv_add_subset (riscv_subset_list_t *,
  46. const char *,
  47. int, int);
  48. extern bool
  49. riscv_lookup_subset (const riscv_subset_list_t *,
  50. const char *,
  51. riscv_subset_t **);
  52. typedef struct
  53. {
  54. riscv_subset_list_t *subset_list;
  55. void (*error_handler) (const char *,
  56. ...) ATTRIBUTE_PRINTF_1;
  57. unsigned *xlen;
  58. enum riscv_spec_class *isa_spec;
  59. bool check_unknown_prefixed_ext;
  60. } riscv_parse_subset_t;
  61. extern bool
  62. riscv_parse_subset (riscv_parse_subset_t *,
  63. const char *);
  64. extern void
  65. riscv_release_subset_list (riscv_subset_list_t *);
  66. extern char *
  67. riscv_arch_str (unsigned, const riscv_subset_list_t *);
  68. extern size_t
  69. riscv_estimate_digit (unsigned);
  70. extern int
  71. riscv_compare_subsets (const char *, const char *);
  72. extern riscv_subset_list_t *
  73. riscv_copy_subset_list (riscv_subset_list_t *);
  74. extern bool
  75. riscv_update_subset (riscv_parse_subset_t *, const char *);
  76. extern bool
  77. riscv_subset_supports (riscv_parse_subset_t *, const char *);
  78. extern bool
  79. riscv_multi_subset_supports (riscv_parse_subset_t *, enum riscv_insn_class);
  80. extern const char *
  81. riscv_multi_subset_supports_ext (riscv_parse_subset_t *, enum riscv_insn_class);
  82. extern void
  83. bfd_elf32_riscv_set_data_segment_info (struct bfd_link_info *, int *);
  84. extern void
  85. bfd_elf64_riscv_set_data_segment_info (struct bfd_link_info *, int *);