1 1.1 skrll /* This file is tc-sh.h 2 1.1.1.11 christos Copyright (C) 1993-2026 Free Software Foundation, Inc. 3 1.1 skrll 4 1.1 skrll This file is part of GAS, the GNU Assembler. 5 1.1 skrll 6 1.1 skrll GAS is free software; you can redistribute it and/or modify 7 1.1 skrll it under the terms of the GNU General Public License as published by 8 1.1 skrll the Free Software Foundation; either version 3, or (at your option) 9 1.1 skrll any later version. 10 1.1 skrll 11 1.1 skrll GAS is distributed in the hope that it will be useful, 12 1.1 skrll but WITHOUT ANY WARRANTY; without even the implied warranty of 13 1.1 skrll MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 1.1 skrll GNU General Public License for more details. 15 1.1 skrll 16 1.1 skrll You should have received a copy of the GNU General Public License 17 1.1 skrll along with GAS; see the file COPYING. If not, write to 18 1.1 skrll the Free Software Foundation, 51 Franklin Street - Fifth Floor, 19 1.1 skrll Boston, MA 02110-1301, USA. */ 20 1.1 skrll 21 1.1 skrll #define TC_SH 22 1.1 skrll 23 1.1 skrll #define TARGET_ARCH bfd_arch_sh 24 1.1 skrll 25 1.1 skrll /* The type fixS is defined (to struct fix) in write.h, but write.h uses 26 1.1 skrll definitions from this file. To avoid problems with including write.h 27 1.1 skrll after the "right" definitions, don't; just forward-declare struct fix 28 1.1 skrll here. */ 29 1.1 skrll struct fix; 30 1.1 skrll struct segment_info_struct; 31 1.1 skrll struct internal_reloc; 32 1.1 skrll 33 1.1 skrll /* Whether -relax was used. */ 34 1.1 skrll extern int sh_relax; 35 1.1 skrll 36 1.1 skrll /* Whether -small was used. */ 37 1.1 skrll extern int sh_small; 38 1.1 skrll 39 1.1 skrll /* Don't try to break words. */ 40 1.1 skrll #define WORKING_DOT_WORD 41 1.1 skrll 42 1.1 skrll /* We require .long, et. al., to be aligned correctly. */ 43 1.1 skrll #define md_cons_align(nbytes) sh_cons_align (nbytes) 44 1.1 skrll extern void sh_cons_align (int); 45 1.1 skrll 46 1.1 skrll /* We need to optimize expr with taking account of rs_align_test 47 1.1 skrll frags. */ 48 1.1 skrll 49 1.1 skrll #ifdef OBJ_ELF 50 1.1 skrll #define md_optimize_expr(l,o,r) sh_optimize_expr (l, o, r) 51 1.1 skrll extern int sh_optimize_expr (expressionS *, operatorT, expressionS *); 52 1.1 skrll #endif 53 1.1 skrll 54 1.1 skrll /* When relaxing, we need to generate relocations for alignment 55 1.1 skrll directives. */ 56 1.1.1.10 christos #define HANDLE_ALIGN(sec, frag) sh_handle_align (frag) 57 1.1 skrll extern void sh_handle_align (fragS *); 58 1.1 skrll 59 1.1.1.10 christos #define MAX_MEM_FOR_RS_ALIGN_CODE(p2align, max) (1 + 2) 60 1.1 skrll 61 1.1 skrll /* We need to force out some relocations when relaxing. */ 62 1.1 skrll #define TC_FORCE_RELOCATION(fix) sh_force_relocation (fix) 63 1.1 skrll extern int sh_force_relocation (struct fix *); 64 1.1 skrll 65 1.1 skrll /* This macro decides whether a particular reloc is an entry in a 66 1.1 skrll switch table. It is used when relaxing, because the linker needs 67 1.1 skrll to know about all such entries so that it can adjust them if 68 1.1 skrll necessary. */ 69 1.1 skrll 70 1.1 skrll #define SWITCH_TABLE(FIX) \ 71 1.1 skrll ((FIX)->fx_addsy != NULL \ 72 1.1 skrll && (FIX)->fx_subsy != NULL \ 73 1.1 skrll && S_GET_SEGMENT ((FIX)->fx_addsy) == text_section \ 74 1.1 skrll && S_GET_SEGMENT ((FIX)->fx_subsy) == text_section \ 75 1.1 skrll && ((FIX)->fx_r_type == BFD_RELOC_32 \ 76 1.1 skrll || (FIX)->fx_r_type == BFD_RELOC_16 \ 77 1.1 skrll || (FIX)->fx_r_type == BFD_RELOC_8)) 78 1.1 skrll 79 1.1 skrll #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \ 80 1.1.1.5 christos (GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC) \ 81 1.1 skrll || TC_FORCE_RELOCATION (FIX) \ 82 1.1 skrll || (sh_relax && SWITCH_TABLE (FIX))) 83 1.1 skrll 84 1.1 skrll /* Don't complain when we leave fx_subsy around. */ 85 1.1 skrll #define TC_VALIDATE_FIX_SUB(FIX, SEG) \ 86 1.1 skrll ((md_register_arithmetic || (SEG) != reg_section) \ 87 1.1 skrll && sh_relax && SWITCH_TABLE (FIX)) 88 1.1 skrll 89 1.1 skrll #define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from_section (FIX, SEC) 90 1.1 skrll 91 1.1 skrll /* SH_COUNT relocs are allowed outside of frag. 92 1.1 skrll The target is also buggy and sets fix size too large for other relocs. */ 93 1.1 skrll #define TC_FX_SIZE_SLACK(FIX) \ 94 1.1 skrll ((FIX)->fx_r_type == BFD_RELOC_SH_COUNT ? -1 : 2) 95 1.1 skrll 96 1.1 skrll #define IGNORE_NONSTANDARD_ESCAPES 97 1.1 skrll 98 1.1 skrll #define LISTING_HEADER \ 99 1.1 skrll (!target_big_endian \ 100 1.1 skrll ? "Renesas / SuperH SH GAS Little Endian" \ 101 1.1 skrll : "Renesas / SuperH SH GAS Big Endian") 102 1.1 skrll 103 1.1 skrll #define md_operand(x) 104 1.1 skrll 105 1.1 skrll extern const struct relax_type md_relax_table[]; 106 1.1 skrll #define TC_GENERIC_RELAX_TABLE md_relax_table 107 1.1 skrll 108 1.1 skrll /* We record, for each section, whether we have most recently output a 109 1.1 skrll CODE reloc or a DATA reloc. */ 110 1.1 skrll struct sh_segment_info_type 111 1.1 skrll { 112 1.1 skrll int in_code : 1; 113 1.1 skrll }; 114 1.1 skrll #define TC_SEGMENT_INFO_TYPE struct sh_segment_info_type 115 1.1 skrll 116 1.1 skrll /* We call a routine to emit a reloc for a label, so that the linker 117 1.1 skrll can align loads and stores without crossing a label. */ 118 1.1 skrll extern void sh_frob_label (symbolS *); 119 1.1 skrll #define tc_frob_label(sym) sh_frob_label (sym) 120 1.1 skrll 121 1.1 skrll /* We call a routine to flush pending output in order to output a DATA 122 1.1 skrll reloc when required. */ 123 1.1 skrll extern void sh_flush_pending_output (void); 124 1.1 skrll #define md_flush_pending_output() sh_flush_pending_output () 125 1.1 skrll 126 1.1 skrll #define tc_frob_file_before_adjust sh_frob_file 127 1.1 skrll extern void sh_frob_file (void); 128 1.1 skrll 129 1.1 skrll 130 1.1 skrll #ifdef OBJ_COFF 131 1.1 skrll /* COFF specific definitions. */ 132 1.1 skrll 133 1.1.1.2 christos #define tc_coff_symbol_emit_hook(a) ; /* Not used. */ 134 1.1 skrll 135 1.1 skrll #define TC_KEEP_FX_OFFSET 1 136 1.1 skrll 137 1.1 skrll #define SEG_NAME(SEG) segment_name (SEG) 138 1.1 skrll 139 1.1 skrll /* We align most sections to a 16 byte boundary. */ 140 1.1 skrll #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) \ 141 1.1.1.11 christos ((startswith (SEG_NAME (SEG), ".stabstr") \ 142 1.1.1.11 christos || do_not_pad_sections_to_alignment) \ 143 1.1 skrll ? 0 \ 144 1.1.1.8 christos : ((startswith (SEG_NAME (SEG), ".stab") \ 145 1.1 skrll || strcmp (SEG_NAME (SEG), ".ctors") == 0 \ 146 1.1 skrll || strcmp (SEG_NAME (SEG), ".dtors") == 0) \ 147 1.1 skrll ? 2 \ 148 1.1 skrll : (sh_small ? 2 : 4))) 149 1.1 skrll 150 1.1 skrll #endif /* OBJ_COFF */ 151 1.1 skrll 152 1.1 skrll #ifdef OBJ_ELF 153 1.1 skrll /* ELF specific definitions. */ 154 1.1 skrll 155 1.1.1.2 christos /* Whether or not the target is big endian. */ 156 1.1 skrll extern int target_big_endian; 157 1.1 skrll #ifdef TE_LINUX 158 1.1 skrll #define TARGET_FORMAT (!target_big_endian ? "elf32-sh-linux" : "elf32-shbig-linux") 159 1.1 skrll #elif defined(TE_NetBSD) 160 1.1 skrll #define TARGET_FORMAT (!target_big_endian ? "elf32-shl-nbsd" : "elf32-sh-nbsd") 161 1.1 skrll #elif defined (TE_VXWORKS) 162 1.1 skrll #define TARGET_FORMAT (!target_big_endian ? "elf32-shl-vxworks" : "elf32-sh-vxworks") 163 1.1.1.2 christos #elif defined (TE_UCLINUX) 164 1.1.1.2 christos #define TARGET_FORMAT sh_uclinux_target_format () 165 1.1.1.2 christos extern const char * sh_uclinux_target_format (void); 166 1.1 skrll #else 167 1.1 skrll #define TARGET_FORMAT (!target_big_endian ? "elf32-shl" : "elf32-sh") 168 1.1 skrll #endif 169 1.1 skrll 170 1.1 skrll #define elf_tc_final_processing sh_elf_final_processing 171 1.1 skrll extern void sh_elf_final_processing (void); 172 1.1 skrll 173 1.1.1.2 christos #define DIFF_EXPR_OK /* foo-. gets turned into PC relative relocs. */ 174 1.1 skrll 175 1.1 skrll #define GLOBAL_OFFSET_TABLE_NAME "_GLOBAL_OFFSET_TABLE_" 176 1.1 skrll 177 1.1 skrll /* This is the relocation type for direct references to 178 1.1 skrll GLOBAL_OFFSET_TABLE. It comes up in complicated expressions such 179 1.1 skrll as _GLOBAL_OFFSET_TABLE_+[.-.L284], which cannot be expressed 180 1.1 skrll normally with the regular expressions. The fixup specified here 181 1.1 skrll when used at runtime implies that we should add the address of the 182 1.1 skrll GOT to the specified location, and as a result we have simplified 183 1.1 skrll the expression into something we can use. */ 184 1.1 skrll #define TC_RELOC_GLOBAL_OFFSET_TABLE BFD_RELOC_SH_GOTPC 185 1.1 skrll 186 1.1 skrll #define tc_fix_adjustable(FIX) sh_fix_adjustable(FIX) 187 1.1.1.8 christos extern bool sh_fix_adjustable (struct fix *); 188 1.1 skrll 189 1.1 skrll /* Values passed to md_apply_fix don't include symbol values. */ 190 1.1 skrll #define MD_APPLY_SYM_VALUE(FIX) 0 191 1.1 skrll 192 1.1 skrll /* This expression evaluates to true if the relocation is for a local object 193 1.1 skrll for which we still want to do the relocation at runtime. False if we 194 1.1 skrll are willing to perform this relocation while building the .o file. 195 1.1 skrll 196 1.1 skrll We can't resolve references to the GOT or the PLT when creating the 197 1.1 skrll object file, since these tables are only created by the linker. 198 1.1 skrll Also, if the symbol is global, weak, common or not defined, the 199 1.1 skrll assembler can't compute the appropriate reloc, since its location 200 1.1 skrll can only be determined at link time. */ 201 1.1 skrll 202 1.1 skrll #define TC_FORCE_RELOCATION_LOCAL(FIX) \ 203 1.1.1.5 christos (GENERIC_FORCE_RELOCATION_LOCAL (FIX) \ 204 1.1 skrll || (FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL \ 205 1.1 skrll || (FIX)->fx_r_type == BFD_RELOC_32_GOT_PCREL \ 206 1.1.1.5 christos || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC) 207 1.1 skrll 208 1.1 skrll #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) \ 209 1.1 skrll ((!md_register_arithmetic && (SEG) == reg_section) \ 210 1.1 skrll || (sh_relax && SWITCH_TABLE (FIX))) 211 1.1 skrll 212 1.1 skrll /* This keeps the subtracted symbol around, for use by PLT_PCREL 213 1.1 skrll relocs. */ 214 1.1 skrll #define TC_FORCE_RELOCATION_SUB_ABS(FIX, SEG) \ 215 1.1 skrll ((FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL \ 216 1.1 skrll || (!md_register_arithmetic && (SEG) == reg_section)) 217 1.1 skrll 218 1.1 skrll /* Don't complain when we leave fx_subsy around. */ 219 1.1 skrll #undef TC_VALIDATE_FIX_SUB 220 1.1 skrll #define TC_VALIDATE_FIX_SUB(FIX, SEG) \ 221 1.1 skrll ((md_register_arithmetic || (SEG) != reg_section) \ 222 1.1 skrll && ((FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL \ 223 1.1 skrll || (sh_relax && SWITCH_TABLE (FIX)))) 224 1.1 skrll 225 1.1 skrll #define md_parse_name(name, exprP, mode, nextcharP) \ 226 1.1 skrll sh_parse_name ((name), (exprP), (mode), (nextcharP)) 227 1.1.1.2 christos int sh_parse_name (char const *, expressionS *, 228 1.1.1.2 christos enum expr_mode, char *); 229 1.1 skrll 230 1.1.1.3 christos #define TC_CONS_FIX_NEW(FRAG, OFF, LEN, EXP, RELOC) \ 231 1.1.1.3 christos sh_cons_fix_new ((FRAG), (OFF), (LEN), (EXP), (RELOC)) 232 1.1.1.3 christos void sh_cons_fix_new (fragS *, int, int, expressionS *, 233 1.1.1.3 christos bfd_reloc_code_real_type); 234 1.1 skrll 235 1.1 skrll /* This is used to construct expressions out of @GOTOFF, @PLT and @GOT 236 1.1 skrll symbols. The relocation type is stored in X_md. */ 237 1.1 skrll #define O_PIC_reloc O_md1 238 1.1 skrll 239 1.1 skrll #define TARGET_USE_CFIPOP 1 240 1.1 skrll 241 1.1 skrll #define tc_cfi_frame_initial_instructions sh_cfi_frame_initial_instructions 242 1.1 skrll extern void sh_cfi_frame_initial_instructions (void); 243 1.1 skrll 244 1.1 skrll #define tc_regname_to_dw2regnum sh_regname_to_dw2regnum 245 1.1.1.2 christos extern int sh_regname_to_dw2regnum (char *); 246 1.1 skrll 247 1.1 skrll /* All SH instructions are multiples of 16 bits. */ 248 1.1 skrll #define DWARF2_LINE_MIN_INSN_LENGTH 2 249 1.1 skrll #define DWARF2_DEFAULT_RETURN_COLUMN 17 250 1.1 skrll #define DWARF2_CIE_DATA_ALIGNMENT (-4) 251 1.1 skrll 252 1.1 skrll #endif /* OBJ_ELF */ 253 1.1 skrll 254 1.1 skrll #define H_TICK_HEX 1 255