159024Sobrien/* tc-sparc.h - Macros and type defines for the sparc. 278828Sobrien Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 3218822Sdim 1999, 2000, 2001, 2002, 2003, 2005, 2007 4218822Sdim Free Software Foundation, Inc. 559024Sobrien 659024Sobrien This file is part of GAS, the GNU Assembler. 759024Sobrien 859024Sobrien GAS is free software; you can redistribute it and/or modify 959024Sobrien it under the terms of the GNU General Public License as 1059024Sobrien published by the Free Software Foundation; either version 2, 1159024Sobrien or (at your option) any later version. 1259024Sobrien 1359024Sobrien GAS is distributed in the hope that it will be useful, but 1459024Sobrien WITHOUT ANY WARRANTY; without even the implied warranty of 1559024Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 1659024Sobrien the GNU General Public License for more details. 1759024Sobrien 1859024Sobrien You should have received a copy of the GNU General Public 1959024Sobrien License along with GAS; see the file COPYING. If not, write 20218822Sdim to the Free Software Foundation, 51 Franklin Street - Fifth Floor, 21218822Sdim Boston, MA 02110-1301, USA. */ 2259024Sobrien 2359024Sobrien#ifndef TC_SPARC 2459024Sobrien#define TC_SPARC 1 2559024Sobrien 2659024Sobrienstruct frag; 2759024Sobrien 2859024Sobrien/* This is used to set the default value for `target_big_endian'. */ 2959024Sobrien#define TARGET_BYTES_BIG_ENDIAN 1 3059024Sobrien 3159024Sobrien#define LOCAL_LABELS_FB 1 3259024Sobrien 3359024Sobrien#define TARGET_ARCH bfd_arch_sparc 3459024Sobrien 35218822Sdim#ifdef TE_FreeBSD 36218822Sdim#define ELF_TARGET_FORMAT "elf32-sparc-freebsd" 37218822Sdim#define ELF64_TARGET_FORMAT "elf64-sparc-freebsd" 38218822Sdim#endif 39218822Sdim 40218822Sdim#ifndef ELF_TARGET_FORMAT 41218822Sdim#define ELF_TARGET_FORMAT "elf32-sparc" 42218822Sdim#endif 43218822Sdim 44218822Sdim#ifndef ELF64_TARGET_FORMAT 45218822Sdim#define ELF64_TARGET_FORMAT "elf64-sparc" 46218822Sdim#endif 47218822Sdim 4859024Sobrienextern const char *sparc_target_format PARAMS ((void)); 4959024Sobrien#define TARGET_FORMAT sparc_target_format () 5059024Sobrien 5160484Sobrien#define RELOC_EXPANSION_POSSIBLE 5260484Sobrien#define MAX_RELOC_EXPANSION 2 5360484Sobrien 5460484Sobrien/* Make it unconditional and check if -EL is valid after option parsing */ 5560484Sobrien#define SPARC_BIENDIAN 5659024Sobrien 5759024Sobrien#define WORKING_DOT_WORD 5859024Sobrien 5977298Sobrien#define md_convert_frag(b,s,f) \ 6077298Sobrien as_fatal (_("sparc convert_frag\n")) 6159024Sobrien#define md_estimate_size_before_relax(f,s) \ 6289857Sobrien (as_fatal (_("estimate_size_before_relax called")), 1) 6359024Sobrien 6459024Sobrien#define LISTING_HEADER "SPARC GAS " 6559024Sobrien 6659024Sobrienextern int sparc_pic_code; 6759024Sobrien 6859024Sobrien/* We require .word, et. al., to be aligned correctly. */ 6959024Sobrien#define md_cons_align(nbytes) sparc_cons_align (nbytes) 7059024Sobrienextern void sparc_cons_align PARAMS ((int)); 7177298Sobrien 7259024Sobrien#define HANDLE_ALIGN(fragp) sparc_handle_align (fragp) 7359024Sobrienextern void sparc_handle_align PARAMS ((struct frag *)); 7459024Sobrien 7577298Sobrien#define MAX_MEM_FOR_RS_ALIGN_CODE (3 + 4 + 4) 7677298Sobrien 7759024Sobrien/* I know that "call 0" fails in sparc-coff if this doesn't return 1. I 7859024Sobrien don't know about other relocation types, or other formats, yet. */ 7959024Sobrien#ifdef OBJ_COFF 80130561Sobrien#define TC_FORCE_RELOCATION_ABS(FIX) \ 81130561Sobrien ((FIX)->fx_r_type == BFD_RELOC_32_PCREL_S2 \ 82130561Sobrien || TC_FORCE_RELOCATION (FIX)) 83130561Sobrien 8459024Sobrien#define RELOC_REQUIRES_SYMBOL 8559024Sobrien#endif 8659024Sobrien 87130561Sobrien#ifdef OBJ_AOUT 88130561Sobrien/* This expression evaluates to true if the relocation is for a local 89130561Sobrien object for which we still want to do the relocation at runtime. 90130561Sobrien False if we are willing to perform this relocation while building 91130561Sobrien the .o file. */ 92130561Sobrien 93130561Sobrien#define TC_FORCE_RELOCATION_LOCAL(FIX) \ 94130561Sobrien (!(FIX)->fx_pcrel \ 95130561Sobrien || (sparc_pic_code \ 96130561Sobrien && S_IS_EXTERNAL ((FIX)->fx_addsy)) \ 97130561Sobrien || TC_FORCE_RELOCATION (FIX)) 9860484Sobrien#endif 9960484Sobrien 10059024Sobrien#ifdef OBJ_ELF 101130561Sobrien/* Don't turn certain relocs into relocations against sections. This 102130561Sobrien is required for the dynamic linker to operate properly. When 103130561Sobrien generating PIC, we need to keep any non PC relative reloc. The PIC 104130561Sobrien part of this test must be parallel to the code in tc_gen_reloc which 105130561Sobrien converts relocations to GOT relocations. */ 10659024Sobrien#define tc_fix_adjustable(FIX) \ 107130561Sobrien ((FIX)->fx_r_type != BFD_RELOC_VTABLE_INHERIT \ 10860484Sobrien && (FIX)->fx_r_type != BFD_RELOC_VTABLE_ENTRY \ 109130561Sobrien && ((FIX)->fx_r_type < BFD_RELOC_SPARC_TLS_GD_HI22 \ 110130561Sobrien || (FIX)->fx_r_type > BFD_RELOC_SPARC_TLS_TPOFF64) \ 11159024Sobrien && (! sparc_pic_code \ 11260484Sobrien || ((FIX)->fx_r_type != BFD_RELOC_HI22 \ 11360484Sobrien && (FIX)->fx_r_type != BFD_RELOC_LO10 \ 11460484Sobrien && (FIX)->fx_r_type != BFD_RELOC_SPARC13 \ 11560484Sobrien && ((FIX)->fx_r_type != BFD_RELOC_32_PCREL_S2 \ 116130561Sobrien || !generic_force_reloc (FIX)) \ 11760484Sobrien && ((FIX)->fx_pcrel \ 11860484Sobrien || ((FIX)->fx_subsy != NULL \ 11960484Sobrien && (S_GET_SEGMENT ((FIX)->fx_subsy) \ 12060484Sobrien == S_GET_SEGMENT ((FIX)->fx_addsy))) \ 12160484Sobrien || S_IS_LOCAL ((FIX)->fx_addsy))))) 12260484Sobrien 123218822Sdim/* Values passed to md_apply_fix don't include the symbol value. */ 124130561Sobrien#define MD_APPLY_SYM_VALUE(FIX) 0 125130561Sobrien 12660484Sobrien/* Finish up the entire symtab. */ 12760484Sobrien#define tc_adjust_symtab() sparc_adjust_symtab () 12860484Sobrienextern void sparc_adjust_symtab PARAMS ((void)); 12959024Sobrien#endif 13059024Sobrien 13159024Sobrien#ifdef OBJ_AOUT 13259024Sobrien/* When generating PIC code, we must not adjust any reloc which will 13360484Sobrien turn into a reloc against the global offset table, nor any reloc 13460484Sobrien which we will need if a symbol is overridden. */ 13560484Sobrien#define tc_fix_adjustable(FIX) \ 13660484Sobrien (! sparc_pic_code \ 13760484Sobrien || ((FIX)->fx_pcrel \ 13860484Sobrien && ((FIX)->fx_addsy == NULL \ 13960484Sobrien || (! S_IS_EXTERNAL ((FIX)->fx_addsy) \ 14060484Sobrien && ! S_IS_WEAK ((FIX)->fx_addsy)))) \ 14160484Sobrien || (FIX)->fx_r_type == BFD_RELOC_16 \ 14259024Sobrien || (FIX)->fx_r_type == BFD_RELOC_32) 14359024Sobrien#endif 14459024Sobrien 14559024Sobrien#define elf_tc_final_processing sparc_elf_final_processing 14659024Sobrienextern void sparc_elf_final_processing PARAMS ((void)); 14759024Sobrien 14859024Sobrien#define md_operand(x) 14959024Sobrien 15059024Sobrienextern void sparc_md_end PARAMS ((void)); 15159024Sobrien#define md_end() sparc_md_end () 15259024Sobrien 15359024Sobrien#endif 15459024Sobrien 15589857Sobrien#ifdef OBJ_ELF 15689857Sobrien#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) sparc_cons (EXP, NBYTES) 15789857Sobrienextern void sparc_cons PARAMS ((expressionS *, int)); 15889857Sobrien#endif 15989857Sobrien 16060484Sobrien#define TC_CONS_FIX_NEW cons_fix_new_sparc 16160484Sobrienextern void cons_fix_new_sparc 16260484Sobrien PARAMS ((struct frag *, int, unsigned int, struct expressionS *)); 16360484Sobrien 16460484Sobrien#define TC_FIX_TYPE valueT 16560484Sobrien 16660484Sobrien#define TC_INIT_FIX_DATA(X) \ 16760484Sobrien do \ 16860484Sobrien { \ 16960484Sobrien (X)->tc_fix_data = 0; \ 17060484Sobrien } \ 17177298Sobrien while (0) 17260484Sobrien 173130561Sobrien#define TC_FIX_DATA_PRINT(FILE, FIX) \ 17460484Sobrien do \ 17560484Sobrien { \ 17677298Sobrien fprintf ((FILE), "addend2=%ld\n", \ 177130561Sobrien (unsigned long) (FIX)->tc_fix_data); \ 17860484Sobrien } \ 17977298Sobrien while (0) 18060484Sobrien 181130561Sobrien#define TARGET_USE_CFIPOP 1 18277298Sobrien 183130561Sobrien#define tc_cfi_frame_initial_instructions sparc_cfi_frame_initial_instructions 184130561Sobrienextern void sparc_cfi_frame_initial_instructions PARAMS ((void)); 185130561Sobrien 186130561Sobrien#define tc_regname_to_dw2regnum sparc_regname_to_dw2regnum 187218822Sdimextern int sparc_regname_to_dw2regnum PARAMS ((char *regname)); 188130561Sobrien 189130561Sobrien#define tc_cfi_emit_pcrel_expr sparc_cfi_emit_pcrel_expr 190130561Sobrienextern void sparc_cfi_emit_pcrel_expr PARAMS ((expressionS *, unsigned int)); 191130561Sobrien 192130561Sobrienextern int sparc_cie_data_alignment; 193130561Sobrien 194130561Sobrien#define DWARF2_LINE_MIN_INSN_LENGTH 4 195130561Sobrien#define DWARF2_DEFAULT_RETURN_COLUMN 15 196130561Sobrien#define DWARF2_CIE_DATA_ALIGNMENT sparc_cie_data_alignment 197130561Sobrien 19859024Sobrien/* end of tc-sparc.h */ 199