160484Sobrien/* tc-ppc.h -- Header file for tc-ppc.c.
2218822Sdim   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3218822Sdim   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
460484Sobrien   Written by Ian Lance Taylor, Cygnus Support.
560484Sobrien
660484Sobrien   This file is part of GAS, the GNU Assembler.
760484Sobrien
860484Sobrien   GAS is free software; you can redistribute it and/or modify
960484Sobrien   it under the terms of the GNU General Public License as published by
1060484Sobrien   the Free Software Foundation; either version 2, or (at your option)
1160484Sobrien   any later version.
1260484Sobrien
1360484Sobrien   GAS is distributed in the hope that it will be useful,
1460484Sobrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
1560484Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1660484Sobrien   GNU General Public License for more details.
1760484Sobrien
1860484Sobrien   You should have received a copy of the GNU General Public License
1960484Sobrien   along with GAS; see the file COPYING.  If not, write to the Free
20218822Sdim   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
21218822Sdim   02110-1301, USA.  */
2260484Sobrien
2360484Sobrien#define TC_PPC
2460484Sobrien
2560484Sobrienstruct fix;
2660484Sobrien
2760484Sobrien/* Set the endianness we are using.  Default to big endian.  */
2860484Sobrien#ifndef TARGET_BYTES_BIG_ENDIAN
2960484Sobrien#define TARGET_BYTES_BIG_ENDIAN 1
3060484Sobrien#endif
3160484Sobrien
3260484Sobrien/* If OBJ_COFF is defined, and TE_PE is not defined, we are assembling
3360484Sobrien   XCOFF for AIX or PowerMac.  If TE_PE is defined, we are assembling
3460484Sobrien   COFF for Windows NT.  */
3560484Sobrien
3660484Sobrien#ifdef OBJ_COFF
3760484Sobrien#ifndef TE_PE
3860484Sobrien#define OBJ_XCOFF
3960484Sobrien#endif
4060484Sobrien#endif
4160484Sobrien
4260484Sobrien/* The target BFD architecture.  */
4360484Sobrien#define TARGET_ARCH (ppc_arch ())
4477298Sobrien#define TARGET_MACH (ppc_mach ())
45218822Sdimextern enum bfd_architecture ppc_arch (void);
46218822Sdimextern unsigned long ppc_mach (void);
4760484Sobrien
4860484Sobrien/* Whether or not the target is big endian */
4960484Sobrienextern int target_big_endian;
5060484Sobrien
5160484Sobrien/* The target BFD format.  */
5277298Sobrien#define TARGET_FORMAT (ppc_target_format ())
53218822Sdimextern char *ppc_target_format (void);
5460484Sobrien
5560484Sobrien/* Permit temporary numeric labels.  */
5660484Sobrien#define LOCAL_LABELS_FB 1
5760484Sobrien
5860484Sobrien/* $ is used to refer to the current location.  */
5960484Sobrien#define DOLLAR_DOT
6060484Sobrien
6160484Sobrien/* Strings do not use backslash escapes under COFF.  */
6260484Sobrien#ifdef OBJ_COFF
6360484Sobrien#define NO_STRING_ESCAPES
6460484Sobrien#endif
6560484Sobrien
6660484Sobrien#ifdef OBJ_ELF
6760484Sobrien#define DIFF_EXPR_OK		/* foo-. gets turned into PC relative relocs */
6860484Sobrien#endif
6960484Sobrien
7060484Sobrien#if TARGET_BYTES_BIG_ENDIAN
7160484Sobrien#define PPC_BIG_ENDIAN 1
7260484Sobrien#else
7360484Sobrien#define PPC_BIG_ENDIAN 0
7460484Sobrien#endif
7560484Sobrien
7660484Sobrien/* We don't need to handle .word strangely.  */
7760484Sobrien#define WORKING_DOT_WORD
7860484Sobrien
7989857Sobrien#define MAX_MEM_FOR_RS_ALIGN_CODE 4
8089857Sobrien#define HANDLE_ALIGN(FRAGP)						\
81218822Sdim  if ((FRAGP)->fr_type == rs_align_code)				\
82218822Sdim    ppc_handle_align (FRAGP);
8389857Sobrien
84218822Sdimextern void ppc_handle_align (struct frag *);
85218822Sdim
86218822Sdim#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
87218822Sdim
88218822Sdim#define md_frag_check(FRAGP) \
89218822Sdim  if ((FRAGP)->has_code							\
90218822Sdim      && (((FRAGP)->fr_address + (FRAGP)->insn_addr) & 3) != 0)		\
91218822Sdim    as_bad_where ((FRAGP)->fr_file, (FRAGP)->fr_line,			\
92218822Sdim		  _("instruction address is not a multiple of 4"));
9360484Sobrien
9460484Sobrien#ifdef TE_PE
9560484Sobrien
9660484Sobrien/* Question marks are permitted in symbol names.  */
9760484Sobrien#define LEX_QM 1
9860484Sobrien
9960484Sobrien/* Don't adjust TOC relocs.  */
100130561Sobrien#define tc_fix_adjustable(FIX) ppc_pe_fix_adjustable (FIX)
101218822Sdimextern int ppc_pe_fix_adjustable (struct fix *);
10260484Sobrien
10360484Sobrien#endif
10460484Sobrien
10560484Sobrien#ifdef OBJ_XCOFF
10660484Sobrien
10760484Sobrien/* Declarations needed when generating XCOFF code.  XCOFF is an
10860484Sobrien   extension of COFF, used only on the RS/6000.  Rather than create an
10960484Sobrien   obj-xcoff, we just use obj-coff, and handle the extensions here in
11060484Sobrien   tc-ppc.  */
11160484Sobrien
11260484Sobrien/* We need to keep some information for symbols.  */
11360484Sobrienstruct ppc_tc_sy
11460484Sobrien{
11560484Sobrien  /* We keep a few linked lists of symbols.  */
11660484Sobrien  symbolS *next;
11760484Sobrien  /* Non-zero if the symbol should be output.  The RS/6000 assembler
11860484Sobrien     only outputs symbols that are external or are mentioned in a
11960484Sobrien     .globl or .lglobl statement.  */
12060484Sobrien  int output;
12160484Sobrien  /* The symbol class.  */
12260484Sobrien  int class;
12360484Sobrien  /* The real name, if the symbol was renamed.  */
12460484Sobrien  char *real_name;
12560484Sobrien  /* For a csect symbol, the subsegment we are using.  This is zero
12660484Sobrien     for symbols that are not csects.  */
12760484Sobrien  subsegT subseg;
12860484Sobrien  /* For a csect or common symbol, the alignment to use.  */
12960484Sobrien  int align;
13060484Sobrien  /* For a function symbol, a symbol whose value is the size.  The
13160484Sobrien     field is NULL if there is no size.  */
13260484Sobrien  symbolS *size;
13360484Sobrien  /* For a csect symbol, the last symbol which has been defined in
13460484Sobrien     this csect, or NULL if none have been defined so far.  For a .bs
13560484Sobrien     symbol, the referenced csect symbol.  */
13660484Sobrien  symbolS *within;
13760484Sobrien};
13860484Sobrien
13960484Sobrien#define TC_SYMFIELD_TYPE struct ppc_tc_sy
14060484Sobrien
14160484Sobrien/* We need an additional auxent for function symbols.  */
14260484Sobrien#define OBJ_COFF_MAX_AUXENTRIES 2
14360484Sobrien
14460484Sobrien/* Square and curly brackets are permitted in symbol names.  */
14560484Sobrien#define LEX_BR 3
14660484Sobrien
14760484Sobrien/* Canonicalize the symbol name.  */
14860484Sobrien#define tc_canonicalize_symbol_name(name) ppc_canonicalize_symbol_name (name)
149218822Sdimextern char *ppc_canonicalize_symbol_name (char *);
15060484Sobrien
15160484Sobrien/* Get the symbol class from the name.  */
15260484Sobrien#define tc_symbol_new_hook(sym) ppc_symbol_new_hook (sym)
153218822Sdimextern void ppc_symbol_new_hook (symbolS *);
15460484Sobrien
15560484Sobrien/* Set the symbol class of a label based on the csect.  */
15660484Sobrien#define tc_frob_label(sym) ppc_frob_label (sym)
157218822Sdimextern void ppc_frob_label (symbolS *);
15860484Sobrien
15960484Sobrien/* TOC relocs requires special handling.  */
160130561Sobrien#define tc_fix_adjustable(FIX) ppc_fix_adjustable (FIX)
161218822Sdimextern int ppc_fix_adjustable (struct fix *);
16260484Sobrien
16360484Sobrien/* We need to set the section VMA.  */
16460484Sobrien#define tc_frob_section(sec) ppc_frob_section (sec)
165218822Sdimextern void ppc_frob_section (asection *);
16660484Sobrien
16760484Sobrien/* Finish up the symbol.  */
16860484Sobrien#define tc_frob_symbol(sym, punt) punt = ppc_frob_symbol (sym)
169218822Sdimextern int ppc_frob_symbol (symbolS *);
17060484Sobrien
17160484Sobrien/* Finish up the entire symtab.  */
17260484Sobrien#define tc_adjust_symtab() ppc_adjust_symtab ()
173218822Sdimextern void ppc_adjust_symtab (void);
17460484Sobrien
17560484Sobrien/* We also need to copy, in particular, the class of the symbol,
17660484Sobrien   over what obj-coff would otherwise have copied.  */
17760484Sobrien#define OBJ_COPY_SYMBOL_ATTRIBUTES(dest,src)			\
17860484Sobriendo {								\
17960484Sobrien  if (SF_GET_GET_SEGMENT (dest))				\
18060484Sobrien    S_SET_SEGMENT (dest, S_GET_SEGMENT (src));			\
18160484Sobrien  symbol_get_tc (dest)->size = symbol_get_tc (src)->size;	\
18260484Sobrien  symbol_get_tc (dest)->align = symbol_get_tc (src)->align;	\
18360484Sobrien  symbol_get_tc (dest)->class = symbol_get_tc (src)->class;	\
18460484Sobrien  symbol_get_tc (dest)->within = symbol_get_tc (src)->within;	\
18560484Sobrien} while (0)
18660484Sobrien
18760484Sobrien#endif /* OBJ_XCOFF */
18860484Sobrien
189130561Sobrienextern const char       ppc_symbol_chars[];
190130561Sobrien#define tc_symbol_chars ppc_symbol_chars
191130561Sobrien
19260484Sobrien#ifdef OBJ_ELF
19360484Sobrien
19460484Sobrien/* Support for SHF_EXCLUDE and SHT_ORDERED */
195218822Sdimextern int ppc_section_letter (int, char **);
196218822Sdimextern int ppc_section_type (char *, size_t);
197218822Sdimextern int ppc_section_word (char *, size_t);
198218822Sdimextern int ppc_section_flags (int, int, int);
19960484Sobrien
20060484Sobrien#define md_elf_section_letter(LETTER, PTR_MSG)	ppc_section_letter (LETTER, PTR_MSG)
20160484Sobrien#define md_elf_section_type(STR, LEN)		ppc_section_type (STR, LEN)
20260484Sobrien#define md_elf_section_word(STR, LEN)		ppc_section_word (STR, LEN)
20360484Sobrien#define md_elf_section_flags(FLAGS, ATTR, TYPE)	ppc_section_flags (FLAGS, ATTR, TYPE)
20460484Sobrien
20560484Sobrien#define tc_comment_chars ppc_comment_chars
20660484Sobrienextern const char *ppc_comment_chars;
20760484Sobrien
20877298Sobrien/* Keep relocations relative to the GOT, or non-PC relative.  */
209130561Sobrien#define tc_fix_adjustable(FIX) ppc_fix_adjustable (FIX)
210218822Sdimextern int ppc_fix_adjustable (struct fix *);
21160484Sobrien
212218822Sdim/* Values passed to md_apply_fix don't include symbol values.  */
213130561Sobrien#define MD_APPLY_SYM_VALUE(FIX) 0
21460484Sobrien
215104834Sobrien#define tc_frob_file_before_adjust ppc_frob_file_before_adjust
216218822Sdimextern void ppc_frob_file_before_adjust (void);
21789857Sobrien
21860484Sobrien#endif /* OBJ_ELF */
21960484Sobrien
220130561Sobrien#if defined (OBJ_ELF) || defined (OBJ_XCOFF)
221130561Sobrien#define TC_FORCE_RELOCATION(FIX) ppc_force_relocation (FIX)
222218822Sdimextern int ppc_force_relocation (struct fix *);
223130561Sobrien#endif
224130561Sobrien
22560484Sobrien/* call md_pcrel_from_section, not md_pcrel_from */
226130561Sobrien#define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from_section(FIX, SEC)
227218822Sdimextern long md_pcrel_from_section (struct fix *, segT);
22860484Sobrien
229218822Sdim#define md_parse_name(name, exp, mode, c) ppc_parse_name (name, exp)
230218822Sdimextern int ppc_parse_name (const char *, struct expressionS *);
23160484Sobrien
23260484Sobrien#define md_operand(x)
233130561Sobrien
234130561Sobrien#define md_cleanup() ppc_cleanup ()
235218822Sdimextern void ppc_cleanup (void);
236130561Sobrien
237130561Sobrien#define TARGET_USE_CFIPOP 1
238130561Sobrien
239130561Sobrien#define tc_cfi_frame_initial_instructions ppc_cfi_frame_initial_instructions
240218822Sdimextern void ppc_cfi_frame_initial_instructions (void);
241130561Sobrien
242130561Sobrien#define tc_regname_to_dw2regnum tc_ppc_regname_to_dw2regnum
243218822Sdimextern int tc_ppc_regname_to_dw2regnum (char *);
244130561Sobrien
245130561Sobrienextern int ppc_cie_data_alignment;
246130561Sobrien
247130561Sobrien#define DWARF2_LINE_MIN_INSN_LENGTH     4
248130561Sobrien#define DWARF2_DEFAULT_RETURN_COLUMN    0x41
249130561Sobrien#define DWARF2_CIE_DATA_ALIGNMENT       ppc_cie_data_alignment
250