| 1 | /* tc-xtensa.h -- Header file for tc-xtensa.c.
|
|---|
| 2 | Copyright (C) 2003 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This file is part of GAS, the GNU Assembler.
|
|---|
| 5 |
|
|---|
| 6 | GAS is free software; you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 9 | any later version.
|
|---|
| 10 |
|
|---|
| 11 | GAS is distributed in the hope that it will be useful,
|
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | GNU General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with GAS; see the file COPYING. If not, write to the Free
|
|---|
| 18 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|---|
| 19 | 02111-1307, USA. */
|
|---|
| 20 |
|
|---|
| 21 | #ifndef TC_XTENSA
|
|---|
| 22 | #define TC_XTENSA 1
|
|---|
| 23 |
|
|---|
| 24 | #ifdef ANSI_PROTOTYPES
|
|---|
| 25 | struct fix;
|
|---|
| 26 | #endif
|
|---|
| 27 |
|
|---|
| 28 | #ifndef BFD_ASSEMBLER
|
|---|
| 29 | #error Xtensa support requires BFD_ASSEMBLER
|
|---|
| 30 | #endif
|
|---|
| 31 |
|
|---|
| 32 | #ifndef OBJ_ELF
|
|---|
| 33 | #error Xtensa support requires ELF object format
|
|---|
| 34 | #endif
|
|---|
| 35 |
|
|---|
| 36 | #include "xtensa-config.h"
|
|---|
| 37 |
|
|---|
| 38 | #define TARGET_BYTES_BIG_ENDIAN XCHAL_HAVE_BE
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 | struct xtensa_frag_type
|
|---|
| 42 | {
|
|---|
| 43 | unsigned is_literal:1;
|
|---|
| 44 | unsigned is_text:1;
|
|---|
| 45 | unsigned is_loop_target:1;
|
|---|
| 46 | unsigned is_branch_target:1;
|
|---|
| 47 | unsigned is_insn:1;
|
|---|
| 48 |
|
|---|
| 49 | /* Info about the current state of assembly, i.e., density, relax,
|
|---|
| 50 | generics, freeregs, longcalls. These need to be passed to the
|
|---|
| 51 | backend and then to the linking file. */
|
|---|
| 52 |
|
|---|
| 53 | unsigned is_no_density:1;
|
|---|
| 54 | unsigned is_relax:1;
|
|---|
| 55 | unsigned is_generics:1;
|
|---|
| 56 | unsigned is_longcalls:1;
|
|---|
| 57 |
|
|---|
| 58 | /* For text fragments that can generate literals at relax time, this
|
|---|
| 59 | variable points to the frag where the literal will be stored. For
|
|---|
| 60 | literal frags, this variable points to the nearest literal pool
|
|---|
| 61 | location frag. This literal frag will be moved to after this
|
|---|
| 62 | location. */
|
|---|
| 63 |
|
|---|
| 64 | fragS *literal_frag;
|
|---|
| 65 |
|
|---|
| 66 | /* The destination segment for literal frags. (Note that this is only
|
|---|
| 67 | valid after xtensa_move_literals. */
|
|---|
| 68 |
|
|---|
| 69 | segT lit_seg;
|
|---|
| 70 |
|
|---|
| 71 | /* For the relaxation scheme, some literal fragments can have their
|
|---|
| 72 | expansions modified by an instruction that relaxes. */
|
|---|
| 73 |
|
|---|
| 74 | unsigned text_expansion;
|
|---|
| 75 | unsigned literal_expansion;
|
|---|
| 76 | unsigned unreported_expansion;
|
|---|
| 77 | };
|
|---|
| 78 |
|
|---|
| 79 | typedef struct xtensa_block_info_struct
|
|---|
| 80 | {
|
|---|
| 81 | segT sec;
|
|---|
| 82 | bfd_vma offset;
|
|---|
| 83 | size_t size;
|
|---|
| 84 | struct xtensa_block_info_struct *next;
|
|---|
| 85 | } xtensa_block_info;
|
|---|
| 86 |
|
|---|
| 87 | typedef enum
|
|---|
| 88 | {
|
|---|
| 89 | xt_insn_sec,
|
|---|
| 90 | xt_literal_sec,
|
|---|
| 91 | max_xt_sec
|
|---|
| 92 | } xt_section_type;
|
|---|
| 93 |
|
|---|
| 94 | typedef struct xtensa_segment_info_struct
|
|---|
| 95 | {
|
|---|
| 96 | fragS *literal_pool_loc;
|
|---|
| 97 | xtensa_block_info *blocks[max_xt_sec];
|
|---|
| 98 | } xtensa_segment_info;
|
|---|
| 99 |
|
|---|
| 100 | typedef struct xtensa_symfield_type_struct
|
|---|
| 101 | {
|
|---|
| 102 | unsigned int plt : 1;
|
|---|
| 103 | } xtensa_symfield_type;
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 | /* Section renaming is only supported in Tensilica's version of GAS. */
|
|---|
| 107 | #define XTENSA_SECTION_RENAME 1
|
|---|
| 108 | #ifdef XTENSA_SECTION_RENAME
|
|---|
| 109 | extern const char *xtensa_section_rename
|
|---|
| 110 | PARAMS ((const char *));
|
|---|
| 111 | #else
|
|---|
| 112 | /* Tensilica's section renaming feature is not included here. */
|
|---|
| 113 | #define xtensa_section_rename(name) (name)
|
|---|
| 114 | #endif /* XTENSA_SECTION_RENAME */
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 | extern const char *xtensa_target_format
|
|---|
| 118 | PARAMS ((void));
|
|---|
| 119 | extern void xtensa_frag_init
|
|---|
| 120 | PARAMS ((fragS *));
|
|---|
| 121 | extern void xtensa_cons_fix_new
|
|---|
| 122 | PARAMS ((fragS *, int, int, expressionS *));
|
|---|
| 123 | extern void xtensa_frob_label
|
|---|
| 124 | PARAMS ((struct symbol *));
|
|---|
| 125 | extern void xtensa_end
|
|---|
| 126 | PARAMS ((void));
|
|---|
| 127 | extern void xtensa_post_relax_hook
|
|---|
| 128 | PARAMS ((void));
|
|---|
| 129 | extern void xtensa_file_arch_init
|
|---|
| 130 | PARAMS ((bfd *));
|
|---|
| 131 | extern void xtensa_flush_pending_output
|
|---|
| 132 | PARAMS ((void));
|
|---|
| 133 | extern bfd_boolean xtensa_fix_adjustable
|
|---|
| 134 | PARAMS ((struct fix *));
|
|---|
| 135 | extern void xtensa_symbol_new_hook
|
|---|
| 136 | PARAMS ((symbolS *));
|
|---|
| 137 | extern long xtensa_relax_frag
|
|---|
| 138 | PARAMS ((fragS *, long, int *));
|
|---|
| 139 |
|
|---|
| 140 | #define TARGET_FORMAT xtensa_target_format ()
|
|---|
| 141 | #define TARGET_ARCH bfd_arch_xtensa
|
|---|
| 142 | #define TC_SEGMENT_INFO_TYPE xtensa_segment_info
|
|---|
| 143 | #define TC_SYMFIELD_TYPE xtensa_symfield_type
|
|---|
| 144 | #define TC_FRAG_TYPE struct xtensa_frag_type
|
|---|
| 145 | #define TC_FRAG_INIT(frag) xtensa_frag_init (frag)
|
|---|
| 146 | #define TC_CONS_FIX_NEW xtensa_cons_fix_new
|
|---|
| 147 | #define tc_canonicalize_symbol_name(s) xtensa_section_rename (s)
|
|---|
| 148 | #define tc_init_after_args() xtensa_file_arch_init (stdoutput)
|
|---|
| 149 | #define tc_fix_adjustable(fix) xtensa_fix_adjustable (fix)
|
|---|
| 150 | #define tc_frob_label(sym) xtensa_frob_label (sym)
|
|---|
| 151 | #define tc_symbol_new_hook(s) xtensa_symbol_new_hook (s)
|
|---|
| 152 | #define md_elf_section_rename(name) xtensa_section_rename (name)
|
|---|
| 153 | #define md_end xtensa_end
|
|---|
| 154 | #define md_flush_pending_output() xtensa_flush_pending_output ()
|
|---|
| 155 | #define md_operand(x)
|
|---|
| 156 | #define TEXT_SECTION_NAME xtensa_section_rename (".text")
|
|---|
| 157 | #define DATA_SECTION_NAME xtensa_section_rename (".data")
|
|---|
| 158 | #define BSS_SECTION_NAME xtensa_section_rename (".bss")
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 | /* The renumber_section function must be mapped over all the sections
|
|---|
| 162 | after calling xtensa_post_relax_hook. That function is static in
|
|---|
| 163 | write.c so it cannot be called from xtensa_post_relax_hook itself. */
|
|---|
| 164 |
|
|---|
| 165 | #define md_post_relax_hook \
|
|---|
| 166 | do \
|
|---|
| 167 | { \
|
|---|
| 168 | int i = 0; \
|
|---|
| 169 | xtensa_post_relax_hook (); \
|
|---|
| 170 | bfd_map_over_sections (stdoutput, renumber_sections, &i); \
|
|---|
| 171 | } \
|
|---|
| 172 | while (0)
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 | /* Because xtensa relaxation can insert a new literal into the middle of
|
|---|
| 176 | fragment and thus require re-running the relaxation pass on the
|
|---|
| 177 | section, we need an explicit flag here. We explicitly use the name
|
|---|
| 178 | "stretched" here to avoid changing the source code in write.c. */
|
|---|
| 179 |
|
|---|
| 180 | #define md_relax_frag(segment, fragP, stretch) \
|
|---|
| 181 | xtensa_relax_frag (fragP, stretch, &stretched)
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 | #define LOCAL_LABELS_FB 1
|
|---|
| 185 | #define WORKING_DOT_WORD 1
|
|---|
| 186 | #define DOUBLESLASH_LINE_COMMENTS
|
|---|
| 187 | #define TC_HANDLES_FX_DONE
|
|---|
| 188 | #define TC_FINALIZE_SYMS_BEFORE_SIZE_SEG 0
|
|---|
| 189 |
|
|---|
| 190 | #define MD_APPLY_SYM_VALUE(FIX) 0
|
|---|
| 191 |
|
|---|
| 192 | /* The default literal sections should always be marked as "code" (i.e.,
|
|---|
| 193 | SHF_EXECINSTR). This is particularly important for the Linux kernel
|
|---|
| 194 | module loader so that the literals are not placed after the text. */
|
|---|
| 195 | #define ELF_TC_SPECIAL_SECTIONS \
|
|---|
| 196 | { ".literal", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, \
|
|---|
| 197 | { ".init.literal", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, \
|
|---|
| 198 | { ".fini.literal", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
|
|---|
| 199 |
|
|---|
| 200 | #endif /* TC_XTENSA */
|
|---|