tc-arm.h revision 130562
1208946Sae/* This file is tc-arm.h 2208946Sae Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004 3208946Sae Free Software Foundation, Inc. 4208946Sae Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) 5208946Sae Modified by David Taylor (dtaylor@armltd.co.uk) 6208946Sae 7208946Sae This file is part of GAS, the GNU Assembler. 8208946Sae 9208946Sae GAS is free software; you can redistribute it and/or modify 10208946Sae it under the terms of the GNU General Public License as published by 11208946Sae the Free Software Foundation; either version 2, or (at your option) 12208946Sae any later version. 13208946Sae 14208946Sae GAS is distributed in the hope that it will be useful, 15208946Sae but WITHOUT ANY WARRANTY; without even the implied warranty of 16208946Sae MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17208946Sae GNU General Public License for more details. 18208946Sae 19208946Sae You should have received a copy of the GNU General Public License 20208946Sae along with GAS; see the file COPYING. If not, write to the Free 21208946Sae Software Foundation, 59 Temple Place - Suite 330, Boston, MA 22208946Sae 02111-1307, USA. */ 23208946Sae 24208946Sae#define TC_ARM 1 25208946Sae 26208946Sae#ifndef TARGET_BYTES_BIG_ENDIAN 27208946Sae#define TARGET_BYTES_BIG_ENDIAN 0 28232538Sglebius#endif 29208946Sae 30208946Sae#define WORKING_DOT_WORD 31208946Sae 32208946Sae#define COFF_MAGIC ARMMAGIC 33208946Sae#define TARGET_ARCH bfd_arch_arm 34208946Sae 35208946Sae#define AOUT_MACHTYPE 0 36208946Sae 37208946Sae#define DIFF_EXPR_OK 38208946Sae 39208946Sae#ifdef LITTLE_ENDIAN 40208946Sae#undef LITTLE_ENDIAN 41208946Sae#endif 42208946Sae 43208946Sae#ifdef BIG_ENDIAN 44208946Sae#undef BIG_ENDIAN 45208946Sae#endif 46208946Sae 47208946Sae#define LITTLE_ENDIAN 1234 48208946Sae#define BIG_ENDIAN 4321 49208946Sae 50208946Saestruct fix; 51208946Sae 52208946Sae#if defined OBJ_AOUT 53208946Sae# if defined TE_RISCIX 54208946Sae# define TARGET_FORMAT "a.out-riscix" 55208946Sae# elif defined TE_LINUX 56208946Sae# define ARM_BI_ENDIAN 57208946Sae# define TARGET_FORMAT "a.out-arm-linux" 58208946Sae# elif defined TE_NetBSD 59208946Sae# define TARGET_FORMAT "a.out-arm-netbsd" 60242997Sjoel# else 61208946Sae# define ARM_BI_ENDIAN 62208946Sae# define TARGET_FORMAT (target_big_endian ? "a.out-arm-big" : "a.out-arm-little") 63208946Sae# endif 64208946Sae#elif defined OBJ_AIF 65208946Sae# define TARGET_FORMAT "aif" 66208946Sae#elif defined OBJ_COFF 67208946Sae# define ARM_BI_ENDIAN 68208946Sae# if defined TE_PE 69208946Sae# if defined TE_EPOC 70208946Sae# define TARGET_FORMAT (target_big_endian ? "epoc-pe-arm-big" : "epoc-pe-arm-little") 71208946Sae# else 72208946Sae# define TARGET_FORMAT (target_big_endian ? "pe-arm-big" : "pe-arm-little") 73208946Sae# endif 74208946Sae# else 75208946Sae# define TARGET_FORMAT (target_big_endian ? "coff-arm-big" : "coff-arm-little") 76242997Sjoel# endif 77242997Sjoel#elif defined OBJ_ELF 78208946Sae# define ARM_BI_ENDIAN 79208946Sae# define TARGET_FORMAT elf32_arm_target_format () 80208946Sae#endif 81208946Sae 82208946Sae#define TC_FORCE_RELOCATION(FIX) arm_force_relocation (FIX) 83208946Sae 84208946Sae#define md_convert_frag(b, s, f) { as_fatal (_("arm convert_frag\n")); } 85208946Sae 86208946Sae#define md_cleanup() arm_cleanup () 87208946Sae 88208946Sae#define md_start_line_hook() arm_start_line_hook () 89208946Sae 90208946Sae#define tc_frob_label(S) arm_frob_label (S) 91208946Sae 92208946Sae/* We also need to mark assembler created symbols: */ 93208946Sae#define tc_frob_fake_label(S) arm_frob_label (S) 94208946Sae 95208946Sae/* NOTE: The fake label creation in stabs.c:s_stab_generic() has 96208946Sae deliberately not been updated to mark assembler created stabs 97208946Sae symbols as Thumb. */ 98208946Sae 99208946Sae#define TC_FIX_TYPE PTR 100208946Sae#define TC_INIT_FIX_DATA(FIX) ((FIX)->tc_fix_data = NULL) 101208946Sae 102208946Sae/* We need to keep some local information on symbols. */ 103208946Sae 104208946Sae#define TC_SYMFIELD_TYPE unsigned int 105208946Sae#define ARM_GET_FLAG(s) (*symbol_get_tc (s)) 106208946Sae#define ARM_SET_FLAG(s,v) (*symbol_get_tc (s) |= (v)) 107208946Sae#define ARM_RESET_FLAG(s,v) (*symbol_get_tc (s) &= ~(v)) 108208946Sae 109208946Sae#define ARM_FLAG_THUMB (1 << 0) /* The symbol is a Thumb symbol rather than an Arm symbol. */ 110208946Sae#define ARM_FLAG_INTERWORK (1 << 1) /* The symbol is attached to code that supports interworking. */ 111208946Sae#define THUMB_FLAG_FUNC (1 << 2) /* The symbol is attached to the start of a Thumb function. */ 112208946Sae 113208946Sae#define ARM_IS_THUMB(s) (ARM_GET_FLAG (s) & ARM_FLAG_THUMB) 114208946Sae#define ARM_IS_INTERWORK(s) (ARM_GET_FLAG (s) & ARM_FLAG_INTERWORK) 115208946Sae#define THUMB_IS_FUNC(s) (ARM_GET_FLAG (s) & THUMB_FLAG_FUNC) 116208946Sae 117208946Sae#define ARM_SET_THUMB(s,t) ((t) ? ARM_SET_FLAG (s, ARM_FLAG_THUMB) : ARM_RESET_FLAG (s, ARM_FLAG_THUMB)) 118242997Sjoel#define ARM_SET_INTERWORK(s,t) ((t) ? ARM_SET_FLAG (s, ARM_FLAG_INTERWORK) : ARM_RESET_FLAG (s, ARM_FLAG_INTERWORK)) 119208946Sae#define THUMB_SET_FUNC(s,t) ((t) ? ARM_SET_FLAG (s, THUMB_FLAG_FUNC) : ARM_RESET_FLAG (s, THUMB_FLAG_FUNC)) 120208946Sae 121208946Sae#define TC_START_LABEL(C,STR) (c == ':' || (c == '/' && arm_data_in_code ())) 122242997Sjoel#define tc_canonicalize_symbol_name(str) arm_canonicalize_symbol_name (str); 123208946Sae#define obj_adjust_symtab() arm_adjust_symtab () 124208946Sae#define tc_aout_pre_write_hook(x) {;} /* not used */ 125242997Sjoel 126208946Sae#define LISTING_HEADER "ARM GAS " 127242997Sjoel 128208946Sae#define OPTIONAL_REGISTER_PREFIX '%' 129208946Sae 130208946Sae#define LOCAL_LABEL(name) (name[0] == '.' && (name[1] == 'L')) 131208946Sae#define LOCAL_LABELS_FB 1 132208946Sae 133208946Sae/* This expression evaluates to true if the relocation is for a local 134208946Sae object for which we still want to do the relocation at runtime. 135208946Sae False if we are willing to perform this relocation while building 136208946Sae the .o file. GOTOFF does not need to be checked here because it is 137208946Sae not pcrel. I am not sure if some of the others are ever used with 138208946Sae pcrel, but it is easier to be safe than sorry. */ 139208946Sae 140208946Sae#define TC_FORCE_RELOCATION_LOCAL(FIX) \ 141208946Sae (!(FIX)->fx_pcrel \ 142208946Sae || (FIX)->fx_plt \ 143235319Sgjb || (FIX)->fx_r_type == BFD_RELOC_ARM_GOT12 \ 144208946Sae || (FIX)->fx_r_type == BFD_RELOC_ARM_GOT32 \ 145208946Sae || (FIX)->fx_r_type == BFD_RELOC_32 \ 146208946Sae || TC_FORCE_RELOCATION (FIX)) 147208946Sae 148208946Sae#define TC_CONS_FIX_NEW cons_fix_new_arm 149208946Sae 150208946Sae#define MAX_MEM_FOR_RS_ALIGN_CODE 31 151208946Sae 152208946Sae/* For frags in code sections we need to record whether they contain 153208946Sae ARM code or THUMB code. This is that if they have to be aligned, 154208946Sae they can contain the correct type of no-op instruction. */ 155208946Sae#define TC_FRAG_TYPE int 156208946Sae#define TC_FRAG_INIT(fragp) arm_init_frag (fragp) 157208946Sae#define HANDLE_ALIGN(fragp) arm_handle_align (fragp) 158208946Sae 159208946Sae#define md_do_align(N, FILL, LEN, MAX, LABEL) \ 160208946Sae if (FILL == NULL && (N) != 0 && ! need_pass_2 && subseg_text_p (now_seg)) \ 161208946Sae { \ 162208946Sae arm_frag_align_code (N, MAX); \ 163208946Sae goto LABEL; \ 164208946Sae } 165208946Sae 166208946Sae#ifdef OBJ_ELF 167233648Seadler# define DWARF2_LINE_MIN_INSN_LENGTH 2 168208946Sae# define obj_frob_symbol(sym, punt) armelf_frob_symbol ((sym), & (punt)) 169208946Sae# define md_elf_section_change_hook() arm_elf_change_section () 170208946Sae# define GLOBAL_OFFSET_TABLE_NAME "_GLOBAL_OFFSET_TABLE_" 171208946Sae# define LOCAL_LABEL_PREFIX '.' 172208946Sae# define TC_SEGMENT_INFO_TYPE enum mstate 173208946Sae 174208946Saeenum mstate 175208946Sae{ 176208946Sae MAP_UNDEFINED = 0, /* Must be zero, for seginfo in new sections. */ 177208946Sae MAP_DATA, 178208946Sae MAP_ARM, 179208946Sae MAP_THUMB 180208946Sae}; 181208946Sae 182208946Sae#else /* Not OBJ_ELF. */ 183208946Sae#define GLOBAL_OFFSET_TABLE_NAME "__GLOBAL_OFFSET_TABLE_" 184208946Sae#endif 185208946Sae 186208946Sae#if defined OBJ_ELF || defined OBJ_COFF 187208946Sae 188232538Sglebius# define EXTERN_FORCE_RELOC 1 189208946Sae# define tc_fix_adjustable(FIX) arm_fix_adjustable (FIX) 190208946Sae/* Values passed to md_apply_fix3 don't include the symbol value. */ 191208946Sae# define MD_APPLY_SYM_VALUE(FIX) 0 192208946Sae# define TC_VALIDATE_FIX(FIX, SEGTYPE, LABEL) arm_validate_fix (FIX) 193208946Sae 194208946Sae#endif 195208946Sae 196208946Saeextern void arm_frag_align_code (int, int); 197208946Saeextern void arm_validate_fix (struct fix *); 198208946Saeextern const char * elf32_arm_target_format (void); 199208946Saeextern void arm_elf_change_section (void); 200208946Saeextern int arm_force_relocation (struct fix *); 201208946Saeextern void arm_cleanup (void); 202208946Saeextern void arm_start_line_hook (void); 203208946Saeextern void arm_frob_label (symbolS *); 204208946Saeextern int arm_data_in_code (void); 205208946Saeextern char * arm_canonicalize_symbol_name (char *); 206208946Saeextern void arm_adjust_symtab (void); 207208946Saeextern void armelf_frob_symbol (symbolS *, int *); 208208946Saeextern void cons_fix_new_arm (fragS *, int, int, expressionS *); 209208946Saeextern void arm_init_frag (struct frag *); 210208946Saeextern void arm_handle_align (struct frag *); 211208946Saeextern bfd_boolean arm_fix_adjustable (struct fix *); 212208946Sae