Back to index

cell-binutils  2.17cvs20070401
tc-sh64.h
Go to the documentation of this file.
00001 /* This file is tc-sh64.h
00002    Copyright 2000, 2001, 2002, 2003, 2007
00003    Free Software Foundation, Inc.
00004 
00005    This file is part of GAS, the GNU Assembler.
00006 
00007    GAS is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2, or (at your option)
00010    any later version.
00011 
00012    GAS is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with GAS; see the file COPYING.  If not, write to
00019    the Free Software Foundation, 51 Franklin Street - Fifth Floor,
00020    Boston, MA 02110-1301, USA.  */
00021 
00022 #define TC_SH64
00023 #include "config/tc-sh.h"
00024 #include "elf/sh.h"
00025 #include "elf32-sh64.h"
00026 
00027 /* We need to override the tc-sh.h settings of HANDLE_ALIGN and
00028    MAX_MEM_FOR_RS_ALIGN_CODE; we might need to put in SHmedia NOP:s, not
00029    SHcompact NOP:s.  */
00030 #undef  HANDLE_ALIGN
00031 #define HANDLE_ALIGN(frag) sh64_handle_align (frag)
00032 extern void sh64_handle_align (fragS *);
00033 
00034 #undef  MAX_MEM_FOR_RS_ALIGN_CODE
00035 #define MAX_MEM_FOR_RS_ALIGN_CODE sh64_max_mem_for_rs_align_code ()
00036 extern int sh64_max_mem_for_rs_align_code (void);
00037 
00038 #undef  LISTING_HEADER
00039 #define LISTING_HEADER                                  \
00040   (target_big_endian ?                                  \
00041      "SuperH SHcompact/SHmedia Big Endian GAS"          \
00042    : "SuperH SHcompact/SHmedia Little Endian GAS")
00043 
00044 /* We need to record the new frag position after an .align.  */
00045 extern void sh64_do_align (int, const char *, int, int);
00046 #define md_do_align(n, fill, len, max, l) \
00047  do { sh64_do_align (n, fill, len, max); goto l; } while (0)
00048 
00049 struct sh64_segment_info_type
00050 {
00051   /* The type of the section is initialized when the range_start_symbol
00052      member is non-NULL.  */
00053   symbolS *mode_start_symbol;
00054   subsegT mode_start_subseg;
00055 
00056   /* A stored symbol indicating location of last call of
00057      "md_flush_pending_output".  It is NULLed when we actually use it;
00058      otherwise the contents is just filled in with segment, frag and
00059      offset within frag.  */
00060   symbolS *last_contents_mark;
00061 
00062   unsigned int emitted_ranges;
00063   enum sh64_elf_cr_type contents_type;
00064 
00065   /* This is used by the SH1-4 parts; we set it to 0 for SHmedia code and
00066      data.  */
00067   unsigned int in_code : 1;
00068 };
00069 
00070 #undef  TC_SEGMENT_INFO_TYPE
00071 #define TC_SEGMENT_INFO_TYPE struct sh64_segment_info_type
00072 
00073 #undef  TARGET_FORMAT
00074 #define TARGET_FORMAT sh64_target_format ()
00075 extern const char *sh64_target_format (void);
00076 
00077 #define TARGET_MACH sh64_target_mach ()
00078 extern int sh64_target_mach (void);
00079 
00080 #undef TC_FORCE_RELOCATION_LOCAL
00081 #define TC_FORCE_RELOCATION_LOCAL(FIX)                  \
00082   (!(FIX)->fx_pcrel                              \
00083    || (FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL \
00084    || (FIX)->fx_r_type == BFD_RELOC_SH_PLT_LOW16 \
00085    || (FIX)->fx_r_type == BFD_RELOC_SH_PLT_MEDLOW16     \
00086    || (FIX)->fx_r_type == BFD_RELOC_SH_PLT_MEDHI16      \
00087    || (FIX)->fx_r_type == BFD_RELOC_SH_PLT_HI16         \
00088    || (FIX)->fx_r_type == BFD_RELOC_32_GOT_PCREL \
00089    || (FIX)->fx_r_type == BFD_RELOC_SH_GOT_LOW16 \
00090    || (FIX)->fx_r_type == BFD_RELOC_SH_GOT_MEDLOW16     \
00091    || (FIX)->fx_r_type == BFD_RELOC_SH_GOT_MEDHI16      \
00092    || (FIX)->fx_r_type == BFD_RELOC_SH_GOT_HI16         \
00093    || (FIX)->fx_r_type == BFD_RELOC_SH_GOT10BY4         \
00094    || (FIX)->fx_r_type == BFD_RELOC_SH_GOT10BY8         \
00095    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT32         \
00096    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT_LOW16     \
00097    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT_MEDLOW16  \
00098    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT_MEDHI16   \
00099    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT_HI16      \
00100    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT10BY4      \
00101    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT10BY8      \
00102    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC            \
00103    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_LOW16      \
00104    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_MEDLOW16   \
00105    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_MEDHI16    \
00106    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_HI16       \
00107    || TC_FORCE_RELOCATION (FIX))
00108 
00109 #undef TC_FORCE_RELOCATION_SUB_SAME
00110 #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC)          \
00111   (! SEG_NORMAL (SEC)                                   \
00112    || TC_FORCE_RELOCATION (FIX)                         \
00113    || (sh_relax && SWITCH_TABLE (FIX))                  \
00114    || *symbol_get_tc ((FIX)->fx_addsy) != NULL)
00115 
00116 /* Don't complain when we leave fx_subsy around.  */
00117 #undef TC_VALIDATE_FIX_SUB
00118 #define TC_VALIDATE_FIX_SUB(FIX)                 \
00119   ((FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL           \
00120    || (sh_relax && SWITCH_TABLE (FIX))                  \
00121    || *symbol_get_tc ((FIX)->fx_addsy) != NULL)
00122 
00123 /* Note the kludge: we want to put back C, and we also want to consume the
00124    expression, since we have handled it ourselves.  FIXME: What we really
00125    need is a new GAS infrastructure feature: md_qualifier.  */
00126 #undef md_parse_name
00127 #define md_parse_name(NAME, EXP, MODE, CP) \
00128  sh64_consume_datalabel (NAME, EXP, MODE, CP, operand)
00129 extern int sh64_consume_datalabel (const char *, expressionS *,
00130                                enum expr_mode, char *,
00131                                segT (*) (expressionS *, enum expr_mode));
00132 
00133 /* Saying "$" is the same as saying ".".  */
00134 #define DOLLAR_DOT
00135 
00136 #undef MD_PCREL_FROM_SECTION
00137 #define MD_PCREL_FROM_SECTION(FIX, SEC)          \
00138   shmedia_md_pcrel_from_section (FIX, SEC)
00139 
00140 extern valueT shmedia_md_pcrel_from_section (struct fix *, segT);
00141 
00142 /* We need to mark this symbol as a BranchTarget; setting st_other for it
00143    and adding 1 to its value (temporarily).  */
00144 extern void sh64_frob_label (symbolS *);
00145 
00146 #undef  tc_frob_label
00147 #define tc_frob_label(sym) \
00148   do { sh_frob_label (sym); sh64_frob_label (sym); } while (0)
00149 
00150 #define tc_symbol_new_hook(s) sh64_frob_label (s)
00151 
00152 /* We use this to mark our "datalabel" symbol copies.  The "mark" is NULL
00153    for an ordinary symbol, and the pointer to the "ordinary" symbol for a
00154    datalabel symbol.  */
00155 #define TC_SYMFIELD_TYPE symbolS *
00156 
00157 #define tc_frob_symbol(symp, punt)        \
00158  do                                       \
00159    {                                      \
00160      punt = sh64_exclude_symbol (symp);          \
00161    }                                      \
00162  while (0)
00163 
00164 extern int sh64_exclude_symbol (symbolS *);
00165 
00166 extern void sh64_adjust_symtab (void);
00167 #define tc_adjust_symtab sh64_adjust_symtab
00168 
00169 #undef  md_flush_pending_output
00170 #define md_flush_pending_output() sh64_flush_pending_output ()
00171 extern void sh64_flush_pending_output (void);
00172 
00173 /* Note that tc-sh.c has a sh_frob_section, but it's called from
00174    tc_frob_file_before_adjust.  */
00175 #define tc_frob_section(sec) shmedia_frob_section_type (sec)
00176 extern void shmedia_frob_section_type (asection *);
00177 
00178 /* We need to emit fixups relative to the frag in which the instruction
00179    resides.  Safest way without calculating max fragment growth or making
00180    it a fixed number is to provide a pointer to the opcode frag.
00181 
00182    We also need to emit the right NOP pattern in .align frags.  This is
00183    done after the text-to-bits assembly pass, so we need to mark it with
00184    the ISA setting at the time the .align was assembled.  */
00185 #define TC_FRAG_TYPE struct sh64_tc_frag_data
00186 
00187 enum sh64_isa_values
00188  {
00189    sh64_isa_unspecified,
00190    sh64_isa_shcompact,
00191    sh64_isa_shmedia,
00192 
00193    /* Special guard value used in contexts when we don't know which ISA it
00194       is, just that it's specified (not sh64_isa_unspecified).  */
00195    sh64_isa_sh5_guard
00196  };
00197 
00198 struct sh64_tc_frag_data
00199 {
00200   fragS *opc_frag;
00201   enum sh64_isa_values isa;
00202 };
00203 
00204 extern enum sh64_isa_values sh64_isa_mode;
00205 
00206 #define TC_FRAG_INIT(FRAGP)                             \
00207  do                                                     \
00208    {                                                    \
00209      (FRAGP)->tc_frag_data.opc_frag = sh64_last_insn_frag;     \
00210      (FRAGP)->tc_frag_data.isa = sh64_isa_mode;                \
00211    }                                                    \
00212  while (0)
00213 
00214 /* This variable is set whenever we generate (or grow) a new opcode frag
00215    in shmedia_build_Mytes.  */
00216 extern fragS *sh64_last_insn_frag;
00217 
00218 #define md_end() shmedia_md_end ()
00219 void shmedia_md_end (void);
00220 
00221 /* Because we make .debug_line hold the SHmedia instruction address | 1,
00222    we have to say we only have minimum byte-size insns.  */
00223 #undef  DWARF2_LINE_MIN_INSN_LENGTH
00224 #define DWARF2_LINE_MIN_INSN_LENGTH 1
00225 
00226 #define TC_FAKE_LABEL(NAME) sh64_fake_label(NAME)
00227 extern int sh64_fake_label (const char *);