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