Commit | Line | Data |
---|---|---|
adde6300 | 1 | /* This file is tc-avr.h |
82704155 | 2 | Copyright (C) 1999-2019 Free Software Foundation, Inc. |
adde6300 AM |
3 | |
4 | Contributed by Denis Chertykov <denisc@overta.ru> | |
5 | ||
6 | This file is part of GAS, the GNU Assembler. | |
7 | ||
8 | GAS is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
ec2655a6 | 10 | the Free Software Foundation; either version 3, or (at your option) |
adde6300 AM |
11 | any later version. |
12 | ||
13 | GAS is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GAS; see the file COPYING. If not, write to the Free | |
4b4da160 NC |
20 | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
21 | 02110-1301, USA. */ | |
adde6300 | 22 | |
a161fe53 AM |
23 | /* By convention, you should define this macro in the `.h' file. For |
24 | example, `tc-m68k.h' defines `TC_M68K'. You might have to use this | |
25 | if it is necessary to add CPU specific code to the object format | |
26 | file. */ | |
adde6300 | 27 | #define TC_AVR |
adde6300 | 28 | |
a161fe53 AM |
29 | /* This macro is the BFD target name to use when creating the output |
30 | file. This will normally depend upon the `OBJ_FMT' macro. */ | |
adde6300 | 31 | #define TARGET_FORMAT "elf32-avr" |
adde6300 | 32 | |
a161fe53 | 33 | /* This macro is the BFD architecture to pass to `bfd_set_arch_mach'. */ |
adde6300 | 34 | #define TARGET_ARCH bfd_arch_avr |
adde6300 | 35 | |
a161fe53 AM |
36 | /* This macro is the BFD machine number to pass to |
37 | `bfd_set_arch_mach'. If it is not defined, GAS will use 0. */ | |
adde6300 | 38 | #define TARGET_MACH 0 |
adde6300 | 39 | |
a161fe53 AM |
40 | /* You should define this macro to be non-zero if the target is big |
41 | endian, and zero if the target is little endian. */ | |
adde6300 | 42 | #define TARGET_BYTES_BIG_ENDIAN 0 |
adde6300 | 43 | |
a161fe53 AM |
44 | /* If you define this macro, GAS will warn about the use of |
45 | nonstandard escape sequences in a string. */ | |
adde6300 | 46 | #define ONLY_STANDARD_ESCAPES |
adde6300 | 47 | |
328e7bfd DC |
48 | #define DIFF_EXPR_OK /* .-foo gets turned into PC relative relocs */ |
49 | ||
a161fe53 AM |
50 | /* GAS will call this function for any expression that can not be |
51 | recognized. When the function is called, `input_line_pointer' | |
52 | will point to the start of the expression. */ | |
adde6300 | 53 | #define md_operand(x) |
adde6300 | 54 | |
62ebcb5c AM |
55 | typedef struct |
56 | { | |
57 | /* Name of the expression modifier allowed with .byte, .word, etc. */ | |
58 | const char *name; | |
59 | ||
60 | /* Only allowed with n bytes of data. */ | |
61 | int nbytes; | |
62 | ||
63 | /* Associated RELOC. */ | |
64 | bfd_reloc_code_real_type reloc; | |
65 | ||
66 | /* Part of the error message. */ | |
67 | const char *error; | |
68 | } exp_mod_data_t; | |
69 | ||
70 | extern const exp_mod_data_t exp_mod_data[]; | |
71 | #define TC_PARSE_CONS_RETURN_TYPE const exp_mod_data_t * | |
72 | #define TC_PARSE_CONS_RETURN_NONE exp_mod_data | |
73 | ||
a161fe53 AM |
74 | /* You may define this macro to parse an expression used in a data |
75 | allocation pseudo-op such as `.word'. You can use this to | |
76 | recognize relocation directives that may appear in such directives. */ | |
dc191a8f | 77 | #define TC_PARSE_CONS_EXPRESSION(EXPR,N) avr_parse_cons_expression (EXPR, N) |
62ebcb5c | 78 | extern const exp_mod_data_t *avr_parse_cons_expression (expressionS *, int); |
adde6300 | 79 | |
a161fe53 AM |
80 | /* You may define this macro to generate a fixup for a data |
81 | allocation pseudo-op. */ | |
62ebcb5c AM |
82 | #define TC_CONS_FIX_NEW avr_cons_fix_new |
83 | extern void avr_cons_fix_new (fragS *,int, int, expressionS *, | |
84 | const exp_mod_data_t *); | |
adde6300 | 85 | |
a161fe53 AM |
86 | /* This should just call either `number_to_chars_bigendian' or |
87 | `number_to_chars_littleendian', whichever is appropriate. On | |
88 | targets like the MIPS which support options to change the | |
89 | endianness, which function to call is a runtime decision. On | |
90 | other targets, `md_number_to_chars' can be a simple macro. */ | |
adde6300 | 91 | #define md_number_to_chars number_to_chars_littleendian |
adde6300 | 92 | |
a161fe53 AM |
93 | /* `md_short_jump_size' |
94 | `md_long_jump_size' | |
95 | `md_create_short_jump' | |
96 | `md_create_long_jump' | |
97 | If `WORKING_DOT_WORD' is defined, GAS will not do broken word | |
98 | processing (*note Broken words::.). Otherwise, you should set | |
99 | `md_short_jump_size' to the size of a short jump (a jump that is | |
100 | just long enough to jump around a long jmp) and | |
101 | `md_long_jump_size' to the size of a long jump (a jump that can go | |
102 | anywhere in the function), You should define | |
103 | `md_create_short_jump' to create a short jump around a long jump, | |
104 | and define `md_create_long_jump' to create a long jump. */ | |
adde6300 | 105 | #define WORKING_DOT_WORD |
adde6300 | 106 | |
a161fe53 AM |
107 | /* If you define this macro, it means that `tc_gen_reloc' may return |
108 | multiple relocation entries for a single fixup. In this case, the | |
109 | return value of `tc_gen_reloc' is a pointer to a null terminated | |
110 | array. */ | |
adde6300 | 111 | #undef RELOC_EXPANSION_POSSIBLE |
adde6300 | 112 | |
a161fe53 AM |
113 | /* No shared lib support, so we don't need to ensure externally |
114 | visible symbols can be overridden. */ | |
115 | #define EXTERN_FORCE_RELOC 0 | |
116 | ||
e4ef1b6c DC |
117 | /* If defined, this macro allows control over whether fixups for a |
118 | given section will be processed when the linkrelax variable is | |
119 | set. Define it to zero and handle things in md_apply_fix instead.*/ | |
120 | #define TC_LINKRELAX_FIXUP(SEG) 0 | |
121 | ||
122 | /* If this macro returns non-zero, it guarantees that a relocation will be emitted | |
123 | even when the value can be resolved locally. Do that if linkrelax is turned on */ | |
124 | #define TC_FORCE_RELOCATION(fix) avr_force_relocation (fix) | |
125 | #define TC_FORCE_RELOCATION_SUB_SAME(fix, seg) \ | |
91cb9803 AM |
126 | (GENERIC_FORCE_RELOCATION_SUB_SAME (fix, seg) \ |
127 | || avr_force_relocation (fix)) | |
e4ef1b6c DC |
128 | extern int avr_force_relocation (struct fix *); |
129 | ||
55cf6793 | 130 | /* Values passed to md_apply_fix don't include the symbol value. */ |
a161fe53 AM |
131 | #define MD_APPLY_SYM_VALUE(FIX) 0 |
132 | ||
133 | /* If you define this macro, it should return the offset between the | |
134 | address of a PC relative fixup and the position from which the PC | |
135 | relative adjustment should be made. On many processors, the base | |
136 | of a PC relative instruction is the next instruction, so this | |
137 | macro would return the length of an instruction. */ | |
dc191a8f NC |
138 | #define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from_section (FIX, SEC) |
139 | extern long md_pcrel_from_section (struct fix *, segT); | |
00d2865b | 140 | |
a161fe53 AM |
141 | /* The number of bytes to put into a word in a listing. This affects |
142 | the way the bytes are clumped together in the listing. For | |
143 | example, a value of 2 might print `1234 5678' where a value of 1 | |
144 | would print `12 34 56 78'. The default value is 4. */ | |
adde6300 | 145 | #define LISTING_WORD_SIZE 2 |
adde6300 | 146 | |
73160847 | 147 | /* AVR port uses `$' as a logical line separator. */ |
a161fe53 | 148 | #define LEX_DOLLAR 0 |
70a516ef | 149 | |
a161fe53 AM |
150 | /* An `.lcomm' directive with no explicit alignment parameter will |
151 | use this macro to set P2VAR to the alignment that a request for | |
152 | SIZE bytes will have. The alignment is expressed as a power of | |
153 | two. If no alignment should take place, the macro definition | |
154 | should do nothing. Some targets define a `.bss' directive that is | |
155 | also affected by this macro. The default definition will set | |
156 | P2VAR to the truncated power of two of sizes up to eight bytes. */ | |
70a516ef | 157 | #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) (P2VAR) = 0 |
73160847 NC |
158 | |
159 | /* We don't want gas to fixup the following program memory related relocations. | |
160 | We will need them in case that we want to do linker relaxation. | |
161 | We could in principle keep these fixups in gas when not relaxing. | |
94d4433a | 162 | However, there is no serious performance penalty when making the linker |
28c9d252 | 163 | make the fixup work. Check also that fx_addsy is not NULL, in order to make |
94d4433a | 164 | sure that the fixup refers to some sort of label. */ |
28c9d252 NC |
165 | #define TC_VALIDATE_FIX(FIXP,SEG,SKIP) \ |
166 | if ( (FIXP->fx_r_type == BFD_RELOC_AVR_7_PCREL \ | |
167 | || FIXP->fx_r_type == BFD_RELOC_AVR_13_PCREL \ | |
168 | || FIXP->fx_r_type == BFD_RELOC_AVR_LO8_LDI_PM \ | |
169 | || FIXP->fx_r_type == BFD_RELOC_AVR_LO8_LDI_GS \ | |
170 | || FIXP->fx_r_type == BFD_RELOC_AVR_HI8_LDI_PM \ | |
171 | || FIXP->fx_r_type == BFD_RELOC_AVR_HI8_LDI_GS \ | |
172 | || FIXP->fx_r_type == BFD_RELOC_AVR_HH8_LDI_PM \ | |
173 | || FIXP->fx_r_type == BFD_RELOC_AVR_LO8_LDI_PM_NEG \ | |
174 | || FIXP->fx_r_type == BFD_RELOC_AVR_HI8_LDI_PM_NEG \ | |
175 | || FIXP->fx_r_type == BFD_RELOC_AVR_HH8_LDI_PM_NEG \ | |
1179bed3 DC |
176 | || FIXP->fx_r_type == BFD_RELOC_AVR_8_LO \ |
177 | || FIXP->fx_r_type == BFD_RELOC_AVR_8_HI \ | |
178 | || FIXP->fx_r_type == BFD_RELOC_AVR_8_HLO \ | |
28c9d252 | 179 | || FIXP->fx_r_type == BFD_RELOC_AVR_16_PM) \ |
94d4433a AM |
180 | && FIXP->fx_addsy != NULL \ |
181 | && FIXP->fx_subsy == NULL) \ | |
182 | { \ | |
183 | symbol_mark_used_in_reloc (FIXP->fx_addsy); \ | |
184 | goto SKIP; \ | |
1179bed3 | 185 | } |
a1836728 | 186 | |
e4ef1b6c DC |
187 | /* This macro is evaluated for any fixup with a fx_subsy that |
188 | fixup_segment cannot reduce to a number. If the macro returns | |
189 | false an error will be reported. */ | |
190 | #define TC_VALIDATE_FIX_SUB(fix, seg) avr_validate_fix_sub (fix) | |
191 | extern int avr_validate_fix_sub (struct fix *); | |
192 | ||
a1836728 AM |
193 | /* This target is buggy, and sets fix size too large. */ |
194 | #define TC_FX_SIZE_SLACK(FIX) 2 | |
66b4202f TG |
195 | |
196 | /* AVR instructions are 2 or 4 bytes long. */ | |
197 | #define DWARF2_LINE_MIN_INSN_LENGTH 2 | |
198 | ||
199 | /* 32 bits pseudo-addresses are used on AVR. */ | |
200 | #define DWARF2_ADDR_SIZE(bfd) 4 | |
af3ecb4a RH |
201 | |
202 | /* Enable cfi directives. */ | |
203 | #define TARGET_USE_CFIPOP 1 | |
204 | ||
205 | /* The stack grows down, and is only byte aligned. */ | |
206 | #define DWARF2_CIE_DATA_ALIGNMENT -1 | |
207 | ||
208 | /* Define the column that represents the PC. */ | |
209 | #define DWARF2_DEFAULT_RETURN_COLUMN 36 | |
210 | ||
211 | /* Define a hook to setup initial CFI state. */ | |
212 | extern void tc_cfi_frame_initial_instructions (void); | |
213 | #define tc_cfi_frame_initial_instructions tc_cfi_frame_initial_instructions | |
e4ef1b6c DC |
214 | |
215 | /* The difference between same-section symbols may be affected by linker | |
216 | relaxation, so do not resolve such expressions in the assembler. */ | |
217 | #define md_allow_local_subtract(l,r,s) avr_allow_local_subtract (l, r, s) | |
218 | extern bfd_boolean avr_allow_local_subtract (expressionS *, expressionS *, segT); | |
eac7440d AB |
219 | |
220 | #define elf_tc_final_processing avr_elf_final_processing | |
221 | extern void avr_elf_final_processing (void); | |
fdd410ac | 222 | |
32f76c67 GJL |
223 | #define md_pre_output_hook avr_pre_output_hook () |
224 | extern void avr_pre_output_hook (void); | |
225 | ||
226 | #define md_undefined_symbol avr_undefined_symbol | |
227 | extern symbolS* avr_undefined_symbol (char*); | |
228 | ||
fdd410ac AB |
229 | #define md_post_relax_hook avr_post_relax_hook () |
230 | extern void avr_post_relax_hook (void); | |
231 | ||
232 | #define HANDLE_ALIGN(fragP) avr_handle_align (fragP) | |
95e42ad4 | 233 | extern void avr_handle_align (fragS *); |
fdd410ac AB |
234 | |
235 | struct avr_frag_data | |
236 | { | |
237 | unsigned is_org : 1; | |
238 | unsigned is_align : 1; | |
239 | unsigned has_fill : 1; | |
240 | ||
241 | char fill; | |
242 | offsetT alignment; | |
95e42ad4 | 243 | unsigned int prev_opcode; |
fdd410ac AB |
244 | }; |
245 | #define TC_FRAG_TYPE struct avr_frag_data | |
db222310 | 246 | #define TC_FRAG_INIT(frag, max_bytes) avr_frag_init (frag) |
95e42ad4 | 247 | extern void avr_frag_init (fragS *); |