elfxx-mips.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /* MIPS ELF specific backend routines.
  2. Copyright (C) 2002-2022 Free Software Foundation, Inc.
  3. This file is part of BFD, the Binary File Descriptor library.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  15. MA 02110-1301, USA. */
  16. #include "elf/common.h"
  17. #include "elf/internal.h"
  18. #include "elf/mips.h"
  19. extern bool _bfd_mips_elf_mkobject
  20. (bfd *);
  21. extern bool _bfd_mips_elf_new_section_hook
  22. (bfd *, asection *);
  23. extern void _bfd_mips_elf_symbol_processing
  24. (bfd *, asymbol *);
  25. extern unsigned int _bfd_mips_elf_eh_frame_address_size
  26. (bfd *, const asection *);
  27. extern bool _bfd_mips_elf_name_local_section_symbols
  28. (bfd *);
  29. extern bool _bfd_mips_elf_section_processing
  30. (bfd *, Elf_Internal_Shdr *);
  31. extern bool _bfd_mips_elf_section_from_shdr
  32. (bfd *, Elf_Internal_Shdr *, const char *, int);
  33. extern bool _bfd_mips_elf_fake_sections
  34. (bfd *, Elf_Internal_Shdr *, asection *);
  35. extern bool _bfd_mips_elf_section_from_bfd_section
  36. (bfd *, asection *, int *);
  37. extern bool _bfd_mips_elf_add_symbol_hook
  38. (bfd *, struct bfd_link_info *, Elf_Internal_Sym *,
  39. const char **, flagword *, asection **, bfd_vma *);
  40. extern int _bfd_mips_elf_link_output_symbol_hook
  41. (struct bfd_link_info *, const char *, Elf_Internal_Sym *,
  42. asection *, struct elf_link_hash_entry *);
  43. extern bool _bfd_mips_elf_create_dynamic_sections
  44. (bfd *, struct bfd_link_info *);
  45. extern bool _bfd_mips_elf_check_relocs
  46. (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
  47. extern bool _bfd_mips_elf_adjust_dynamic_symbol
  48. (struct bfd_link_info *, struct elf_link_hash_entry *);
  49. extern bool _bfd_mips_elf_always_size_sections
  50. (bfd *, struct bfd_link_info *);
  51. extern bool _bfd_mips_elf_size_dynamic_sections
  52. (bfd *, struct bfd_link_info *);
  53. extern int _bfd_mips_elf_relocate_section
  54. (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
  55. Elf_Internal_Rela *, Elf_Internal_Sym *, asection **);
  56. extern bool _bfd_mips_elf_finish_dynamic_symbol
  57. (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
  58. Elf_Internal_Sym *);
  59. extern bool _bfd_mips_vxworks_finish_dynamic_symbol
  60. (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
  61. Elf_Internal_Sym *);
  62. extern bool _bfd_mips_elf_finish_dynamic_sections
  63. (bfd *, struct bfd_link_info *);
  64. extern bool _bfd_mips_elf_sort_relocs_p
  65. (asection *);
  66. extern void _bfd_mips_final_write_processing
  67. (bfd *);
  68. extern bool _bfd_mips_elf_final_write_processing
  69. (bfd *);
  70. extern int _bfd_mips_elf_additional_program_headers
  71. (bfd *, struct bfd_link_info *);
  72. extern bool _bfd_mips_elf_modify_segment_map
  73. (bfd *, struct bfd_link_info *);
  74. extern asection * _bfd_mips_elf_gc_mark_hook
  75. (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
  76. struct elf_link_hash_entry *, Elf_Internal_Sym *);
  77. extern void _bfd_mips_elf_copy_indirect_symbol
  78. (struct bfd_link_info *, struct elf_link_hash_entry *,
  79. struct elf_link_hash_entry *);
  80. extern void _bfd_mips_elf_hide_symbol
  81. (struct bfd_link_info *, struct elf_link_hash_entry *, bool);
  82. extern bool _bfd_mips_elf_ignore_discarded_relocs
  83. (asection *);
  84. extern bool _bfd_mips_elf_is_target_special_symbol
  85. (bfd *abfd, asymbol *sym);
  86. extern bool _bfd_mips_elf_find_nearest_line
  87. (bfd *, asymbol **, asection *, bfd_vma,
  88. const char **, const char **, unsigned int *, unsigned int *);
  89. extern bool _bfd_mips_elf_find_inliner_info
  90. (bfd *, const char **, const char **, unsigned int *);
  91. extern bool _bfd_mips_elf_set_section_contents
  92. (bfd *, asection *, const void *, file_ptr, bfd_size_type);
  93. extern bfd_byte *_bfd_elf_mips_get_relocated_section_contents
  94. (bfd *, struct bfd_link_info *, struct bfd_link_order *,
  95. bfd_byte *, bool, asymbol **);
  96. extern bool _bfd_mips_elf_relax_section
  97. (bfd *abfd, asection *sec, struct bfd_link_info *link_info,
  98. bool *again);
  99. extern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create
  100. (bfd *);
  101. extern struct bfd_link_hash_table *_bfd_mips_vxworks_link_hash_table_create
  102. (bfd *);
  103. extern bool _bfd_mips_elf_final_link
  104. (bfd *, struct bfd_link_info *);
  105. extern bool _bfd_mips_elf_merge_private_bfd_data
  106. (bfd *, struct bfd_link_info *);
  107. extern bool _bfd_mips_elf_set_private_flags
  108. (bfd *, flagword);
  109. extern const char * _bfd_mips_fp_abi_string
  110. (int);
  111. extern bool _bfd_mips_elf_print_private_bfd_data
  112. (bfd *, void *);
  113. extern bool _bfd_mips_elf_discard_info
  114. (bfd *, struct elf_reloc_cookie *, struct bfd_link_info *);
  115. extern bool _bfd_mips_elf_write_section
  116. (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
  117. extern bool _bfd_mips_elf_read_ecoff_info
  118. (bfd *, asection *, struct ecoff_debug_info *);
  119. extern void _bfd_mips_elf_reloc_unshuffle
  120. (bfd *, int, bool, bfd_byte *);
  121. extern void _bfd_mips_elf_reloc_shuffle
  122. (bfd *, int, bool, bfd_byte *);
  123. extern bfd_reloc_status_type _bfd_mips_elf_gprel16_with_gp
  124. (bfd *, asymbol *, arelent *, asection *, bool, void *, bfd_vma);
  125. extern bfd_reloc_status_type _bfd_mips_elf32_gprel16_reloc
  126. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  127. extern bfd_reloc_status_type _bfd_mips_elf_hi16_reloc
  128. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  129. extern bfd_reloc_status_type _bfd_mips_elf_got16_reloc
  130. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  131. extern bfd_reloc_status_type _bfd_mips_elf_lo16_reloc
  132. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  133. extern bfd_reloc_status_type _bfd_mips_elf_generic_reloc
  134. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  135. extern unsigned long _bfd_elf_mips_mach
  136. (flagword);
  137. extern bfd_vma _bfd_mips_elf_sign_extend
  138. (bfd_vma, int);
  139. extern void _bfd_mips_elf_merge_symbol_attribute
  140. (struct elf_link_hash_entry *, unsigned int, bool, bool);
  141. extern char *_bfd_mips_elf_get_target_dtag (bfd_vma);
  142. extern bool _bfd_mips_elf_ignore_undef_symbol
  143. (struct elf_link_hash_entry *);
  144. extern void _bfd_mips_elf_use_plts_and_copy_relocs
  145. (struct bfd_link_info *);
  146. extern void _bfd_mips_elf_linker_flags
  147. (struct bfd_link_info *, bool, bool, bool);
  148. extern void _bfd_mips_elf_compact_branches
  149. (struct bfd_link_info *, bool);
  150. extern bool _bfd_mips_elf_init_stubs
  151. (struct bfd_link_info *,
  152. asection *(*) (const char *, asection *, asection *));
  153. extern bfd_vma _bfd_mips_elf_plt_sym_val
  154. (bfd_vma, const asection *, const arelent *rel);
  155. extern long _bfd_mips_elf_get_synthetic_symtab
  156. (bfd *, long, asymbol **, long, asymbol **, asymbol **);
  157. extern bool _bfd_mips_elf_gc_mark_extra_sections
  158. (struct bfd_link_info *, elf_gc_mark_hook_fn);
  159. extern bool _bfd_mips_init_file_header
  160. (bfd *abfd, struct bfd_link_info *link_info);
  161. extern const struct bfd_elf_special_section _bfd_mips_elf_special_sections [];
  162. extern bool _bfd_mips_elf_common_definition (Elf_Internal_Sym *);
  163. extern int _bfd_mips_elf_compact_eh_encoding (struct bfd_link_info *);
  164. extern int _bfd_mips_elf_cant_unwind_opcode (struct bfd_link_info *);
  165. extern void _bfd_mips_elf_record_xhash_symbol
  166. (struct elf_link_hash_entry *h, bfd_vma xlat_loc);
  167. /* MIPS ABI flags data access. For the disassembler. */
  168. extern struct elf_internal_abiflags_v0 *bfd_mips_elf_get_abiflags (bfd *);
  169. static inline bool
  170. gprel16_reloc_p (unsigned int r_type)
  171. {
  172. return (r_type == R_MIPS_GPREL16
  173. || r_type == R_MIPS16_GPREL
  174. || r_type == R_MICROMIPS_GPREL16
  175. || r_type == R_MICROMIPS_GPREL7_S2);
  176. }
  177. static inline bool
  178. literal_reloc_p (int r_type)
  179. {
  180. return r_type == R_MIPS_LITERAL || r_type == R_MICROMIPS_LITERAL;
  181. }
  182. #define elf_backend_common_definition _bfd_mips_elf_common_definition
  183. #define elf_backend_name_local_section_symbols \
  184. _bfd_mips_elf_name_local_section_symbols
  185. #define elf_backend_special_sections _bfd_mips_elf_special_sections
  186. #define elf_backend_eh_frame_address_size _bfd_mips_elf_eh_frame_address_size
  187. #define elf_backend_merge_symbol_attribute _bfd_mips_elf_merge_symbol_attribute
  188. #define elf_backend_ignore_undef_symbol _bfd_mips_elf_ignore_undef_symbol
  189. #define elf_backend_init_file_header _bfd_mips_init_file_header
  190. #define elf_backend_compact_eh_encoding _bfd_mips_elf_compact_eh_encoding
  191. #define elf_backend_cant_unwind_opcode _bfd_mips_elf_cant_unwind_opcode
  192. #define elf_backend_record_xhash_symbol _bfd_mips_elf_record_xhash_symbol
  193. #define elf_backend_always_renumber_dynsyms true