11556Srgrimes/* tc-sparc.h - Macros and type defines for the sparc.
21556Srgrimes   Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
31556Srgrimes   1999, 2000, 2001, 2002, 2003, 2005, 2007
41556Srgrimes   Free Software Foundation, Inc.
51556Srgrimes
61556Srgrimes   This file is part of GAS, the GNU Assembler.
71556Srgrimes
81556Srgrimes   GAS is free software; you can redistribute it and/or modify
91556Srgrimes   it under the terms of the GNU General Public License as
101556Srgrimes   published by the Free Software Foundation; either version 2,
111556Srgrimes   or (at your option) any later version.
121556Srgrimes
131556Srgrimes   GAS is distributed in the hope that it will be useful, but
141556Srgrimes   WITHOUT ANY WARRANTY; without even the implied warranty of
151556Srgrimes   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
161556Srgrimes   the GNU General Public License for more details.
171556Srgrimes
181556Srgrimes   You should have received a copy of the GNU General Public
191556Srgrimes   License along with GAS; see the file COPYING.  If not, write
201556Srgrimes   to the Free Software Foundation, 51 Franklin Street - Fifth Floor,
211556Srgrimes   Boston, MA 02110-1301, USA.  */
221556Srgrimes
231556Srgrimes#ifndef TC_SPARC
241556Srgrimes#define TC_SPARC 1
251556Srgrimes
261556Srgrimesstruct frag;
271556Srgrimes
281556Srgrimes/* This is used to set the default value for `target_big_endian'.  */
291556Srgrimes#define TARGET_BYTES_BIG_ENDIAN 1
301556Srgrimes
311556Srgrimes#define LOCAL_LABELS_FB 1
321556Srgrimes
331556Srgrimes#define TARGET_ARCH bfd_arch_sparc
341556Srgrimes
3536049Scharnier#ifdef TE_FreeBSD
3636049Scharnier#define ELF_TARGET_FORMAT	"elf32-sparc-freebsd"
3736049Scharnier#define ELF64_TARGET_FORMAT	"elf64-sparc-freebsd"
381556Srgrimes#endif
3999110Sobrien
4099110Sobrien#ifndef ELF_TARGET_FORMAT
411556Srgrimes#define ELF_TARGET_FORMAT	"elf32-sparc"
421556Srgrimes#endif
431556Srgrimes
441556Srgrimes#ifndef ELF64_TARGET_FORMAT
451556Srgrimes#define ELF64_TARGET_FORMAT	"elf64-sparc"
4676351Skris#endif
471556Srgrimes
481556Srgrimesextern const char *sparc_target_format PARAMS ((void));
491556Srgrimes#define TARGET_FORMAT sparc_target_format ()
501556Srgrimes
511556Srgrimes#define RELOC_EXPANSION_POSSIBLE
521556Srgrimes#define MAX_RELOC_EXPANSION 2
531556Srgrimes
541556Srgrimes/* Make it unconditional and check if -EL is valid after option parsing */
551556Srgrimes#define SPARC_BIENDIAN
5676019Skris
571556Srgrimes#define WORKING_DOT_WORD
581556Srgrimes
591556Srgrimes#define md_convert_frag(b,s,f) \
601556Srgrimes  as_fatal (_("sparc convert_frag\n"))
611556Srgrimes#define md_estimate_size_before_relax(f,s) \
621556Srgrimes  (as_fatal (_("estimate_size_before_relax called")), 1)
631556Srgrimes
641556Srgrimes#define LISTING_HEADER "SPARC GAS "
651556Srgrimes
661556Srgrimesextern int sparc_pic_code;
6776019Skris
6876019Skris/* We require .word, et. al., to be aligned correctly.  */
691556Srgrimes#define md_cons_align(nbytes) sparc_cons_align (nbytes)
701556Srgrimesextern void sparc_cons_align PARAMS ((int));
711556Srgrimes
721556Srgrimes#define HANDLE_ALIGN(fragp) sparc_handle_align (fragp)
731556Srgrimesextern void sparc_handle_align PARAMS ((struct frag *));
741556Srgrimes
751556Srgrimes#define MAX_MEM_FOR_RS_ALIGN_CODE  (3 + 4 + 4)
761556Srgrimes
771556Srgrimes/* I know that "call 0" fails in sparc-coff if this doesn't return 1.  I
781556Srgrimes   don't know about other relocation types, or other formats, yet.  */
791556Srgrimes#ifdef OBJ_COFF
801556Srgrimes#define TC_FORCE_RELOCATION_ABS(FIX)		\
811556Srgrimes  ((FIX)->fx_r_type == BFD_RELOC_32_PCREL_S2	\
821556Srgrimes   || TC_FORCE_RELOCATION (FIX))
831556Srgrimes
841556Srgrimes#define RELOC_REQUIRES_SYMBOL
851556Srgrimes#endif
861556Srgrimes
871556Srgrimes#ifdef OBJ_AOUT
881556Srgrimes/* This expression evaluates to true if the relocation is for a local
891556Srgrimes   object for which we still want to do the relocation at runtime.
901556Srgrimes   False if we are willing to perform this relocation while building
911556Srgrimes   the .o file.  */
921556Srgrimes
938855Srgrimes#define TC_FORCE_RELOCATION_LOCAL(FIX)		\
941556Srgrimes  (!(FIX)->fx_pcrel				\
951556Srgrimes   || (sparc_pic_code				\
9676017Skris       && S_IS_EXTERNAL ((FIX)->fx_addsy))	\
971556Srgrimes   || TC_FORCE_RELOCATION (FIX))
981556Srgrimes#endif
991556Srgrimes
1001556Srgrimes#ifdef OBJ_ELF
10176017Skris/* Don't turn certain relocs into relocations against sections.  This
1021556Srgrimes   is required for the dynamic linker to operate properly.  When
1031556Srgrimes   generating PIC, we need to keep any non PC relative reloc.  The PIC
1041556Srgrimes   part of this test must be parallel to the code in tc_gen_reloc which
10576351Skris   converts relocations to GOT relocations.  */
10676351Skris#define tc_fix_adjustable(FIX)						\
10776351Skris  ((FIX)->fx_r_type != BFD_RELOC_VTABLE_INHERIT				\
10876351Skris   && (FIX)->fx_r_type != BFD_RELOC_VTABLE_ENTRY			\
10976351Skris   && ((FIX)->fx_r_type < BFD_RELOC_SPARC_TLS_GD_HI22			\
1101556Srgrimes       || (FIX)->fx_r_type > BFD_RELOC_SPARC_TLS_TPOFF64)		\
1111556Srgrimes   && (! sparc_pic_code							\
1128855Srgrimes       || ((FIX)->fx_r_type != BFD_RELOC_HI22				\
1131556Srgrimes	   && (FIX)->fx_r_type != BFD_RELOC_LO10			\
1141556Srgrimes	   && (FIX)->fx_r_type != BFD_RELOC_SPARC13			\
1151556Srgrimes	   && ((FIX)->fx_r_type != BFD_RELOC_32_PCREL_S2		\
1161556Srgrimes	       || !generic_force_reloc (FIX))				\
1171556Srgrimes	   && ((FIX)->fx_pcrel						\
1181556Srgrimes	       || ((FIX)->fx_subsy != NULL				\
1191556Srgrimes		   && (S_GET_SEGMENT ((FIX)->fx_subsy)			\
1201556Srgrimes		       == S_GET_SEGMENT ((FIX)->fx_addsy)))		\
1211556Srgrimes	       || S_IS_LOCAL ((FIX)->fx_addsy)))))
1221556Srgrimes
1231556Srgrimes/* Values passed to md_apply_fix don't include the symbol value.  */
1241556Srgrimes#define MD_APPLY_SYM_VALUE(FIX) 0
1251556Srgrimes
1261556Srgrimes/* Finish up the entire symtab.  */
1271556Srgrimes#define tc_adjust_symtab() sparc_adjust_symtab ()
1281556Srgrimesextern void sparc_adjust_symtab PARAMS ((void));
1291556Srgrimes#endif
1301556Srgrimes
1311556Srgrimes#ifdef OBJ_AOUT
1321556Srgrimes/* When generating PIC code, we must not adjust any reloc which will
1331556Srgrimes   turn into a reloc against the global offset table, nor any reloc
1341556Srgrimes   which we will need if a symbol is overridden.  */
1351556Srgrimes#define tc_fix_adjustable(FIX)						\
1361556Srgrimes  (! sparc_pic_code							\
1371556Srgrimes   || ((FIX)->fx_pcrel							\
1381556Srgrimes       && ((FIX)->fx_addsy == NULL					\
1391556Srgrimes	   || (! S_IS_EXTERNAL ((FIX)->fx_addsy)			\
1401556Srgrimes	       && ! S_IS_WEAK ((FIX)->fx_addsy))))			\
14176017Skris   || (FIX)->fx_r_type == BFD_RELOC_16					\
1421556Srgrimes   || (FIX)->fx_r_type == BFD_RELOC_32)
1431556Srgrimes#endif
1441556Srgrimes
1451556Srgrimes#define elf_tc_final_processing sparc_elf_final_processing
14676017Skrisextern void sparc_elf_final_processing PARAMS ((void));
147222177Suqs
1481556Srgrimes#define md_operand(x)
1491556Srgrimes
1501556Srgrimesextern void sparc_md_end PARAMS ((void));
1511556Srgrimes#define md_end() sparc_md_end ()
1521556Srgrimes
1531556Srgrimes#endif
1541556Srgrimes
1551556Srgrimes#ifdef OBJ_ELF
1561556Srgrimes#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) sparc_cons (EXP, NBYTES)
1571556Srgrimesextern void sparc_cons PARAMS ((expressionS *, int));
1581556Srgrimes#endif
1591556Srgrimes
1601556Srgrimes#define TC_CONS_FIX_NEW cons_fix_new_sparc
1611556Srgrimesextern void cons_fix_new_sparc
1621556Srgrimes  PARAMS ((struct frag *, int, unsigned int, struct expressionS *));
1631556Srgrimes
1641556Srgrimes#define TC_FIX_TYPE	valueT
165102230Strhodes
1661556Srgrimes#define TC_INIT_FIX_DATA(X)			\
1671556Srgrimes  do						\
1681556Srgrimes     {						\
1691556Srgrimes       (X)->tc_fix_data = 0;			\
1701556Srgrimes     }						\
1711556Srgrimes  while (0)
1721556Srgrimes
1731556Srgrimes#define TC_FIX_DATA_PRINT(FILE, FIX)					\
1741556Srgrimes  do									\
1751556Srgrimes    {									\
1761556Srgrimes      fprintf ((FILE), "addend2=%ld\n",   				\
1771556Srgrimes	      (unsigned long) (FIX)->tc_fix_data);			\
1781556Srgrimes    }									\
1791556Srgrimes  while (0)
1801556Srgrimes
1811556Srgrimes#define TARGET_USE_CFIPOP 1
1821556Srgrimes
1831556Srgrimes#define tc_cfi_frame_initial_instructions sparc_cfi_frame_initial_instructions
184222177Suqsextern void sparc_cfi_frame_initial_instructions PARAMS ((void));
1851556Srgrimes
1861556Srgrimes#define tc_regname_to_dw2regnum sparc_regname_to_dw2regnum
1871556Srgrimesextern int sparc_regname_to_dw2regnum PARAMS ((char *regname));
1881556Srgrimes
1891556Srgrimes#define tc_cfi_emit_pcrel_expr sparc_cfi_emit_pcrel_expr
190222177Suqsextern void sparc_cfi_emit_pcrel_expr PARAMS ((expressionS *, unsigned int));
1911556Srgrimes
1921556Srgrimesextern int sparc_cie_data_alignment;
1931556Srgrimes
1941556Srgrimes#define DWARF2_LINE_MIN_INSN_LENGTH     4
1951556Srgrimes#define DWARF2_DEFAULT_RETURN_COLUMN    15
1961556Srgrimes#define DWARF2_CIE_DATA_ALIGNMENT       sparc_cie_data_alignment
1971556Srgrimes
198222177Suqs/* end of tc-sparc.h */
1991556Srgrimes