tc-aarch64.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /* tc-aarch64.h -- Header file for tc-aarch64.c.
  2. Copyright (C) 2009-2022 Free Software Foundation, Inc.
  3. Contributed by ARM Ltd.
  4. This file is part of GAS.
  5. GAS is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the license, or
  8. (at your option) any later version.
  9. GAS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; see the file COPYING3. If not,
  15. see <http://www.gnu.org/licenses/>. */
  16. #ifndef TC_AARCH64
  17. #define TC_AARCH64 1
  18. #include "opcode/aarch64.h"
  19. #ifndef TARGET_BYTES_BIG_ENDIAN
  20. #define TARGET_BYTES_BIG_ENDIAN 0
  21. #endif
  22. #define WORKING_DOT_WORD
  23. #define TARGET_ARCH bfd_arch_aarch64
  24. #define DIFF_EXPR_OK
  25. /* Permit // comments. */
  26. #define DOUBLESLASH_LINE_COMMENTS
  27. #ifdef LITTLE_ENDIAN
  28. #undef LITTLE_ENDIAN
  29. #endif
  30. #ifdef BIG_ENDIAN
  31. #undef BIG_ENDIAN
  32. #endif
  33. #define LITTLE_ENDIAN 1234
  34. #define BIG_ENDIAN 4321
  35. #define SWAP_32(n) \
  36. ((((n) & 0xff) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) \
  37. | (((n) >> 24) & 0xff))
  38. struct fix;
  39. struct aarch64_fix
  40. {
  41. struct aarch64_inst *inst;
  42. enum aarch64_opnd opnd;
  43. };
  44. #if defined OBJ_ELF
  45. # define AARCH64_BI_ENDIAN
  46. # define TARGET_FORMAT elf64_aarch64_target_format ()
  47. #endif
  48. #define TC_FORCE_RELOCATION(FIX) aarch64_force_relocation (FIX)
  49. /* Currently there is no machine specific frags generated. */
  50. #define md_convert_frag(b,s,f) as_fatal ("aarch64 convert_frag called\n")
  51. #define md_cleanup() aarch64_cleanup ()
  52. #define md_start_line_hook() aarch64_start_line_hook ()
  53. #define tc_frob_label(S) aarch64_frob_label (S)
  54. /* We also need to mark assembler created symbols: */
  55. #define tc_frob_fake_label(S) aarch64_frob_label (S)
  56. #define tc_frob_section(S) aarch64_frob_section (S)
  57. /* The key used to sign a function's return address. */
  58. enum pointer_auth_key {
  59. AARCH64_PAUTH_KEY_A,
  60. AARCH64_PAUTH_KEY_B
  61. };
  62. /* The extra fields required by AArch64 in fde_entry and cie_entry. Currently
  63. only used to store the key used to sign the frame's return address. */
  64. #define tc_fde_entry_extras enum pointer_auth_key pauth_key;
  65. #define tc_cie_entry_extras enum pointer_auth_key pauth_key;
  66. /* The extra initialisation steps needed by AArch64 in alloc_fde_entry.
  67. Currently only used to initialise the key used to sign the return
  68. address. */
  69. #define tc_fde_entry_init_extra(fde) fde->pauth_key = AARCH64_PAUTH_KEY_A;
  70. /* Extra checks required by AArch64 when outputting the current cie_entry.
  71. Currently only used to output a 'B' if the return address is signed with the
  72. B key. */
  73. #define tc_output_cie_extra(cie) \
  74. do \
  75. { \
  76. if (cie->pauth_key == AARCH64_PAUTH_KEY_B) \
  77. out_one ('B'); \
  78. } \
  79. while (0)
  80. /* Extra equivalence checks required by AArch64 when selecting the correct cie
  81. for some fde. Currently only used to check for quivalence between keys used
  82. to sign ther return address. */
  83. #define tc_cie_fde_equivalent_extra(cie, fde) (cie->pauth_key == fde->pauth_key)
  84. /* The extra initialisation steps needed by AArch64 in select_cie_for_fde.
  85. Currently only used to initialise the key used to sign the return
  86. address. */
  87. #define tc_cie_entry_init_extra(cie, fde) cie->pauth_key = fde->pauth_key;
  88. #define TC_FIX_TYPE struct aarch64_fix
  89. #define TC_INIT_FIX_DATA(FIX) { (FIX)->tc_fix_data.inst = NULL; \
  90. (FIX)->tc_fix_data.opnd = AARCH64_OPND_NIL; }
  91. #define TC_SYMFIELD_TYPE unsigned int
  92. #define AARCH64_GET_FLAG(s) (*symbol_get_tc (s))
  93. void aarch64_copy_symbol_attributes (symbolS *, symbolS *);
  94. #ifndef TC_COPY_SYMBOL_ATTRIBUTES
  95. #define TC_COPY_SYMBOL_ATTRIBUTES(DEST, SRC) \
  96. (aarch64_copy_symbol_attributes (DEST, SRC))
  97. #endif
  98. #ifdef OBJ_ELF
  99. void aarch64_elf_copy_symbol_attributes (symbolS *, symbolS *);
  100. #define OBJ_COPY_SYMBOL_ATTRIBUTES(DEST, SRC) \
  101. aarch64_elf_copy_symbol_attributes (DEST, SRC)
  102. #endif
  103. #define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) \
  104. (NEXT_CHAR == ':' || (NEXT_CHAR == '/' && aarch64_data_in_code ()))
  105. #define tc_canonicalize_symbol_name(str) aarch64_canonicalize_symbol_name (str);
  106. #define obj_adjust_symtab() aarch64_adjust_symtab ()
  107. #define LISTING_HEADER "AARCH64 GAS "
  108. #define LOCAL_LABEL(name) (name[0] == '.' && name[1] == 'L')
  109. #define LOCAL_LABELS_FB 1
  110. /* This expression evaluates to true if the relocation is for a local
  111. object for which we still want to do the relocation at runtime.
  112. False if we are willing to perform this relocation while building
  113. the .o file. GOTOFF does not need to be checked here because it is
  114. not pcrel. I am not sure if some of the others are ever used with
  115. pcrel, but it is easier to be safe than sorry. */
  116. #define TC_FORCE_RELOCATION_LOCAL(FIX) \
  117. (GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
  118. || (FIX)->fx_r_type == BFD_RELOC_64 \
  119. || (FIX)->fx_r_type == BFD_RELOC_32)
  120. #define TC_CONS_FIX_NEW(f,w,s,e,r) cons_fix_new_aarch64 ((f), (w), (s), (e))
  121. /* Max space for a rs_align_code fragment is 3 unaligned bytes
  122. (fr_fix) plus 4 bytes to contain the repeating NOP (fr_var). */
  123. #define MAX_MEM_FOR_RS_ALIGN_CODE 7
  124. /* For frags in code sections we need to record whether they contain
  125. code or data. */
  126. struct aarch64_frag_type
  127. {
  128. int recorded;
  129. #ifdef OBJ_ELF
  130. /* If there is a mapping symbol at offset 0 in this frag,
  131. it will be saved in FIRST_MAP. If there are any mapping
  132. symbols in this frag, the last one will be saved in
  133. LAST_MAP. */
  134. symbolS *first_map, *last_map;
  135. #endif
  136. };
  137. #define TC_FRAG_TYPE struct aarch64_frag_type
  138. #define TC_FRAG_INIT(fragp, max_bytes) aarch64_init_frag (fragp, max_bytes)
  139. #define HANDLE_ALIGN(fragp) aarch64_handle_align (fragp)
  140. #define md_do_align(N, FILL, LEN, MAX, LABEL) \
  141. if (FILL == NULL && (N) != 0 && ! need_pass_2 && subseg_text_p (now_seg)) \
  142. { \
  143. frag_align_code (N, MAX); \
  144. goto LABEL; \
  145. }
  146. #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
  147. #define DWARF2_LINE_MIN_INSN_LENGTH 4
  148. /* The lr register is r30. */
  149. #define DWARF2_DEFAULT_RETURN_COLUMN 30
  150. /* Registers are generally saved at negative offsets to the CFA. */
  151. #define DWARF2_CIE_DATA_ALIGNMENT (-8)
  152. extern int aarch64_dwarf2_addr_size (void);
  153. #define DWARF2_ADDR_SIZE(bfd) aarch64_dwarf2_addr_size ()
  154. #ifdef OBJ_ELF
  155. # define obj_frob_symbol(sym, punt) aarch64elf_frob_symbol ((sym), & (punt))
  156. # define GLOBAL_OFFSET_TABLE_NAME "_GLOBAL_OFFSET_TABLE_"
  157. # define TC_SEGMENT_INFO_TYPE struct aarch64_segment_info_type
  158. /* This is not really an alignment operation, but it's something we
  159. need to do at the same time: whenever we are figuring out the
  160. alignment for data, we should check whether a $d symbol is
  161. necessary. */
  162. # define md_cons_align(nbytes) mapping_state (MAP_DATA)
  163. enum mstate
  164. {
  165. MAP_UNDEFINED = 0, /* Must be zero, for seginfo in new sections. */
  166. MAP_DATA,
  167. MAP_INSN,
  168. };
  169. void mapping_state (enum mstate);
  170. struct aarch64_segment_info_type
  171. {
  172. const char *last_file;
  173. unsigned last_line;
  174. enum mstate mapstate;
  175. unsigned int marked_pr_dependency;
  176. aarch64_instr_sequence insn_sequence;
  177. };
  178. /* We want .cfi_* pseudo-ops for generating unwind info. */
  179. #define TARGET_USE_CFIPOP 1
  180. /* CFI hooks. */
  181. #define tc_regname_to_dw2regnum tc_aarch64_regname_to_dw2regnum
  182. #define tc_cfi_frame_initial_instructions tc_aarch64_frame_initial_instructions
  183. extern void aarch64_after_parse_args (void);
  184. #define md_after_parse_args() aarch64_after_parse_args ()
  185. #else /* Not OBJ_ELF. */
  186. #define GLOBAL_OFFSET_TABLE_NAME "__GLOBAL_OFFSET_TABLE_"
  187. #endif
  188. #if defined OBJ_ELF || defined OBJ_COFF
  189. # define EXTERN_FORCE_RELOC 1
  190. # define tc_fix_adjustable(FIX) 1
  191. /* Values passed to md_apply_fix don't include the symbol value. */
  192. # define MD_APPLY_SYM_VALUE(FIX) 0
  193. #endif
  194. #define MD_PCREL_FROM_SECTION(F,S) md_pcrel_from_section(F,S)
  195. extern void aarch64_frag_align_code (int, int);
  196. extern const char * elf64_aarch64_target_format (void);
  197. extern int aarch64_force_relocation (struct fix *);
  198. extern void aarch64_cleanup (void);
  199. extern void aarch64_start_line_hook (void);
  200. extern void aarch64_frob_label (symbolS *);
  201. extern void aarch64_frob_section (asection *sec);
  202. extern int aarch64_data_in_code (void);
  203. extern char * aarch64_canonicalize_symbol_name (char *);
  204. extern void aarch64_adjust_symtab (void);
  205. extern void aarch64elf_frob_symbol (symbolS *, int *);
  206. extern void cons_fix_new_aarch64 (fragS *, int, int, expressionS *);
  207. extern void aarch64_init_frag (struct frag *, int);
  208. extern void aarch64_handle_align (struct frag *);
  209. extern int tc_aarch64_regname_to_dw2regnum (char *regname);
  210. extern void tc_aarch64_frame_initial_instructions (void);
  211. #ifdef TE_PE
  212. #define O_secrel O_md1
  213. #define TC_DWARF2_EMIT_OFFSET tc_pe_dwarf2_emit_offset
  214. void tc_pe_dwarf2_emit_offset (symbolS *, unsigned int);
  215. #endif /* TE_PE */
  216. #endif /* TC_AARCH64 */