tc-sparc.h revision 78828
159024Sobrien/* tc-sparc.h - Macros and type defines for the sparc.
278828Sobrien   Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
378828Sobrien   1999, 2000 Free Software Foundation, Inc.
459024Sobrien
559024Sobrien   This file is part of GAS, the GNU Assembler.
659024Sobrien
759024Sobrien   GAS is free software; you can redistribute it and/or modify
859024Sobrien   it under the terms of the GNU General Public License as
959024Sobrien   published by the Free Software Foundation; either version 2,
1059024Sobrien   or (at your option) any later version.
1159024Sobrien
1259024Sobrien   GAS is distributed in the hope that it will be useful, but
1359024Sobrien   WITHOUT ANY WARRANTY; without even the implied warranty of
1459024Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
1559024Sobrien   the GNU General Public License for more details.
1659024Sobrien
1759024Sobrien   You should have received a copy of the GNU General Public
1859024Sobrien   License along with GAS; see the file COPYING.  If not, write
1959024Sobrien   to the Free Software Foundation, 59 Temple Place - Suite 330,
2059024Sobrien   Boston, MA 02111-1307, USA.  */
2159024Sobrien
2259024Sobrien#ifndef TC_SPARC
2359024Sobrien#define TC_SPARC 1
2459024Sobrien
2559024Sobrien#ifdef ANSI_PROTOTYPES
2659024Sobrienstruct frag;
2759024Sobrien#endif
2859024Sobrien
2959024Sobrien/* This is used to set the default value for `target_big_endian'.  */
3059024Sobrien#define TARGET_BYTES_BIG_ENDIAN 1
3159024Sobrien
3259024Sobrien#define LOCAL_LABELS_FB 1
3359024Sobrien
3459024Sobrien#define TARGET_ARCH bfd_arch_sparc
3559024Sobrien
3659024Sobrienextern const char *sparc_target_format PARAMS ((void));
3759024Sobrien#define TARGET_FORMAT sparc_target_format ()
3859024Sobrien
3960484Sobrien#define RELOC_EXPANSION_POSSIBLE
4060484Sobrien#define MAX_RELOC_EXPANSION 2
4160484Sobrien
4260484Sobrien#if 0
4359024Sobrien#ifdef TE_SPARCAOUT
4459024Sobrien/* Bi-endian support may eventually be unconditional, but until things are
4559024Sobrien   working well it's only provided for targets that need it.  */
4659024Sobrien#define SPARC_BIENDIAN
4759024Sobrien#endif
4860484Sobrien#endif
4960484Sobrien/* Make it unconditional and check if -EL is valid after option parsing */
5060484Sobrien#define SPARC_BIENDIAN
5159024Sobrien
5259024Sobrien#define WORKING_DOT_WORD
5359024Sobrien
5477298Sobrien#define md_convert_frag(b,s,f) \
5577298Sobrien  as_fatal (_("sparc convert_frag\n"))
5659024Sobrien#define md_estimate_size_before_relax(f,s) \
5777298Sobrien  (as_fatal(_("estimate_size_before_relax called")), 1)
5859024Sobrien
5959024Sobrien#define LISTING_HEADER "SPARC GAS "
6059024Sobrien
6159024Sobrienextern int sparc_pic_code;
6259024Sobrien
6359024Sobrien/* We require .word, et. al., to be aligned correctly.  */
6459024Sobrien#define md_cons_align(nbytes) sparc_cons_align (nbytes)
6559024Sobrienextern void sparc_cons_align PARAMS ((int));
6677298Sobrien
6759024Sobrien#define HANDLE_ALIGN(fragp) sparc_handle_align (fragp)
6859024Sobrienextern void sparc_handle_align PARAMS ((struct frag *));
6959024Sobrien
7077298Sobrien#define MAX_MEM_FOR_RS_ALIGN_CODE  (3 + 4 + 4)
7177298Sobrien
7259024Sobrien#if defined (OBJ_ELF) || defined (OBJ_AOUT)
7359024Sobrien
7459024Sobrien/* This expression evaluates to false if the relocation is for a local
7559024Sobrien   object for which we still want to do the relocation at runtime.
7659024Sobrien   True if we are willing to perform this relocation while building
7759024Sobrien   the .o file.
7859024Sobrien
7959024Sobrien   If the reloc is against an externally visible symbol, then the
8059024Sobrien   a.out assembler should not do the relocation if generating PIC, and
8159024Sobrien   the ELF assembler should never do the relocation.  */
8259024Sobrien
8359024Sobrien#ifdef OBJ_ELF
8459024Sobrien#define obj_relocate_extern 0
8559024Sobrien#else
8659024Sobrien#define obj_relocate_extern (! sparc_pic_code)
8759024Sobrien#endif
8859024Sobrien
8959024Sobrien#define TC_RELOC_RTSYM_LOC_FIXUP(FIX)  \
9059024Sobrien  (obj_relocate_extern \
9159024Sobrien   || (FIX)->fx_addsy == NULL \
9259024Sobrien   || (! S_IS_EXTERNAL ((FIX)->fx_addsy) \
9359024Sobrien       && ! S_IS_WEAK ((FIX)->fx_addsy) \
9459024Sobrien       && S_IS_DEFINED ((FIX)->fx_addsy) \
9559024Sobrien       && ! S_IS_COMMON ((FIX)->fx_addsy)))
9659024Sobrien#endif
9759024Sobrien
9859024Sobrien/* I know that "call 0" fails in sparc-coff if this doesn't return 1.  I
9959024Sobrien   don't know about other relocation types, or other formats, yet.  */
10059024Sobrien#ifdef OBJ_COFF
10159024Sobrien#define TC_FORCE_RELOCATION(FIXP)	\
10259024Sobrien	((FIXP)->fx_r_type == BFD_RELOC_32_PCREL_S2 \
10359024Sobrien	 && ((FIXP)->fx_addsy == 0 \
10459024Sobrien	     || S_GET_SEGMENT ((FIXP)->fx_addsy) == absolute_section))
10559024Sobrien#define RELOC_REQUIRES_SYMBOL
10659024Sobrien#endif
10759024Sobrien
10860484Sobrien#ifdef OBJ_ELF
10960484Sobrien#define TC_FORCE_RELOCATION(fixp) elf32_sparc_force_relocation(fixp)
11060484Sobrienextern int elf32_sparc_force_relocation PARAMS ((struct fix *));
11160484Sobrien#endif
11260484Sobrien
11359024Sobrien#define MD_APPLY_FIX3
11459024Sobrien#define TC_HANDLES_FX_DONE
11559024Sobrien
11659024Sobrien#ifdef OBJ_ELF
11759024Sobrien/* Keep relocations against global symbols.  Don't turn them into
11859024Sobrien   relocations against sections.  This is required for the dynamic
11959024Sobrien   linker to operate properly.  When generating PIC, we need to keep
12060484Sobrien   any non PC relative reloc.  The PIC part of this test must be
12160484Sobrien   parallel to the code in tc_gen_reloc which converts relocations to
12260484Sobrien   GOT relocations.  */
12359024Sobrien#define tc_fix_adjustable(FIX)						\
12459024Sobrien  (! S_IS_EXTERNAL ((FIX)->fx_addsy)					\
12559024Sobrien   && ! S_IS_WEAK ((FIX)->fx_addsy)					\
12660484Sobrien   && (FIX)->fx_r_type != BFD_RELOC_VTABLE_INHERIT			\
12760484Sobrien   && (FIX)->fx_r_type != BFD_RELOC_VTABLE_ENTRY			\
12859024Sobrien   && (! sparc_pic_code							\
12960484Sobrien       || ((FIX)->fx_r_type != BFD_RELOC_HI22				\
13060484Sobrien	   && (FIX)->fx_r_type != BFD_RELOC_LO10			\
13160484Sobrien	   && (FIX)->fx_r_type != BFD_RELOC_SPARC13			\
13260484Sobrien	   && ((FIX)->fx_r_type != BFD_RELOC_32_PCREL_S2		\
13360484Sobrien	       || (S_IS_DEFINED ((FIX)->fx_addsy)			\
13460484Sobrien		   && ! S_IS_COMMON ((FIX)->fx_addsy)			\
13560484Sobrien		   && ! S_IS_EXTERNAL ((FIX)->fx_addsy)			\
13660484Sobrien		   && ! S_IS_WEAK ((FIX)->fx_addsy)))			\
13760484Sobrien	   && ((FIX)->fx_pcrel						\
13860484Sobrien	       || ((FIX)->fx_subsy != NULL				\
13960484Sobrien		   && (S_GET_SEGMENT ((FIX)->fx_subsy)			\
14060484Sobrien		       == S_GET_SEGMENT ((FIX)->fx_addsy)))		\
14160484Sobrien	       || S_IS_LOCAL ((FIX)->fx_addsy)))))
14260484Sobrien
14360484Sobrien/* Finish up the entire symtab.  */
14460484Sobrien#define tc_adjust_symtab() sparc_adjust_symtab ()
14560484Sobrienextern void sparc_adjust_symtab PARAMS ((void));
14659024Sobrien#endif
14759024Sobrien
14859024Sobrien#ifdef OBJ_AOUT
14959024Sobrien/* When generating PIC code, we must not adjust any reloc which will
15060484Sobrien   turn into a reloc against the global offset table, nor any reloc
15160484Sobrien   which we will need if a symbol is overridden.  */
15260484Sobrien#define tc_fix_adjustable(FIX)						\
15360484Sobrien  (! sparc_pic_code							\
15460484Sobrien   || ((FIX)->fx_pcrel							\
15560484Sobrien       && ((FIX)->fx_addsy == NULL					\
15660484Sobrien	   || (! S_IS_EXTERNAL ((FIX)->fx_addsy)			\
15760484Sobrien	       && ! S_IS_WEAK ((FIX)->fx_addsy))))			\
15860484Sobrien   || (FIX)->fx_r_type == BFD_RELOC_16					\
15959024Sobrien   || (FIX)->fx_r_type == BFD_RELOC_32)
16059024Sobrien#endif
16159024Sobrien
16259024Sobrien#define elf_tc_final_processing sparc_elf_final_processing
16359024Sobrienextern void sparc_elf_final_processing PARAMS ((void));
16459024Sobrien
16559024Sobrien#define md_operand(x)
16659024Sobrien
16759024Sobrienextern void sparc_md_end PARAMS ((void));
16859024Sobrien#define md_end() sparc_md_end ()
16959024Sobrien
17059024Sobrien#endif
17159024Sobrien
17260484Sobrien#define TC_CONS_FIX_NEW cons_fix_new_sparc
17360484Sobrienextern void cons_fix_new_sparc
17460484Sobrien  PARAMS ((struct frag *, int, unsigned int, struct expressionS *));
17560484Sobrien
17660484Sobrien#define TC_FIX_TYPE	valueT
17760484Sobrien
17860484Sobrien#define TC_INIT_FIX_DATA(X)			\
17960484Sobrien  do						\
18060484Sobrien     {						\
18160484Sobrien       (X)->tc_fix_data = 0;			\
18260484Sobrien     }						\
18377298Sobrien  while (0)
18460484Sobrien
18560484Sobrien#define TC_FIX_DATA_PRINT(FILE, FIXP)					\
18660484Sobrien  do									\
18760484Sobrien    {									\
18877298Sobrien      fprintf ((FILE), "addend2=%ld\n",   				\
18960484Sobrien	      (unsigned long) (FIXP)->tc_fix_data);			\
19060484Sobrien    }									\
19177298Sobrien  while (0)
19260484Sobrien
19377298Sobrien#define DWARF2_LINE_MIN_INSN_LENGTH 4
19477298Sobrien
19559024Sobrien/* end of tc-sparc.h */
196