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