1 /* tc-ppc.h -- Header file for tc-ppc.c.
2 Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #ifdef ANSI_PROTOTYPES
28 /* Set the endianness we are using. Default to big endian. */
29 #ifndef TARGET_BYTES_BIG_ENDIAN
30 #define TARGET_BYTES_BIG_ENDIAN 1
34 #error PowerPC support requires BFD_ASSEMBLER
37 /* If OBJ_COFF is defined, and TE_PE is not defined, we are assembling
38 XCOFF for AIX or PowerMac. If TE_PE is defined, we are assembling
39 COFF for Windows NT. */
47 /* The target BFD architecture. */
48 #define TARGET_ARCH (ppc_arch ())
49 extern enum bfd_architecture ppc_arch PARAMS ((void));
51 /* Whether or not the target is big endian */
52 extern int target_big_endian;
54 /* The target BFD format. */
57 #define TARGET_FORMAT (target_big_endian ? "pe-powerpc" : "pe-powerpcle")
59 #define TARGET_FORMAT "aixcoff-rs6000"
63 /* PowerMac has a BFD slightly different from AIX's. */
68 #define TARGET_FORMAT "xcoff-powermac"
72 #define TARGET_FORMAT (target_big_endian ? "elf32-powerpc" : "elf32-powerpcle")
75 /* Permit temporary numeric labels. */
76 #define LOCAL_LABELS_FB 1
78 /* $ is used to refer to the current location. */
81 /* Strings do not use backslash escapes under COFF. */
83 #define NO_STRING_ESCAPES
87 #define DIFF_EXPR_OK /* .-foo gets turned into PC relative relocs */
90 #if TARGET_BYTES_BIG_ENDIAN
91 #define PPC_BIG_ENDIAN 1
93 #define PPC_BIG_ENDIAN 0
96 /* We don't need to handle .word strangely. */
97 #define WORKING_DOT_WORD
99 /* We set the fx_done field appropriately in md_apply_fix. */
100 #define TC_HANDLES_FX_DONE
104 /* Question marks are permitted in symbol names. */
107 /* Don't adjust TOC relocs. */
108 #define tc_fix_adjustable(fixp) ppc_pe_fix_adjustable (fixp)
109 extern int ppc_pe_fix_adjustable PARAMS ((struct fix *));
115 /* Declarations needed when generating XCOFF code. XCOFF is an
116 extension of COFF, used only on the RS/6000. Rather than create an
117 obj-xcoff, we just use obj-coff, and handle the extensions here in
120 /* We need to keep some information for symbols. */
123 /* We keep a few linked lists of symbols. */
125 /* Non-zero if the symbol should be output. The RS/6000 assembler
126 only outputs symbols that are external or are mentioned in a
127 .globl or .lglobl statement. */
129 /* The symbol class. */
131 /* The real name, if the symbol was renamed. */
133 /* For a csect symbol, the subsegment we are using. This is zero
134 for symbols that are not csects. */
136 /* For a csect or common symbol, the alignment to use. */
138 /* For a function symbol, a symbol whose value is the size. The
139 field is NULL if there is no size. */
141 /* For a csect symbol, the last symbol which has been defined in
142 this csect, or NULL if none have been defined so far. For a .bs
143 symbol, the referenced csect symbol. */
144 struct symbol *within;
147 #define TC_SYMFIELD_TYPE struct ppc_tc_sy
149 /* We need an additional auxent for function symbols. */
150 #define OBJ_COFF_MAX_AUXENTRIES 2
152 /* Square and curly brackets are permitted in symbol names. */
155 /* Canonicalize the symbol name. */
156 #define tc_canonicalize_symbol_name(name) ppc_canonicalize_symbol_name (name)
157 extern char *ppc_canonicalize_symbol_name PARAMS ((char *));
159 /* Get the symbol class from the name. */
160 #define tc_symbol_new_hook(sym) ppc_symbol_new_hook (sym)
161 extern void ppc_symbol_new_hook PARAMS ((struct symbol *));
163 /* Set the symbol class of a label based on the csect. */
164 #define tc_frob_label(sym) ppc_frob_label (sym)
165 extern void ppc_frob_label PARAMS ((struct symbol *));
167 /* TOC relocs requires special handling. */
168 #define tc_fix_adjustable(fixp) ppc_fix_adjustable (fixp)
169 extern int ppc_fix_adjustable PARAMS ((struct fix *));
171 /* A relocation from one csect to another must be kept. */
172 #define TC_FORCE_RELOCATION(FIXP) ppc_force_relocation (FIXP)
173 extern int ppc_force_relocation PARAMS ((struct fix *));
175 /* We need to set the section VMA. */
176 #define tc_frob_section(sec) ppc_frob_section (sec)
177 extern void ppc_frob_section PARAMS ((asection *));
179 /* Finish up the symbol. */
180 #define tc_frob_symbol(sym, punt) punt = ppc_frob_symbol (sym)
181 extern int ppc_frob_symbol PARAMS ((struct symbol *));
183 /* Finish up the entire symtab. */
184 #define tc_adjust_symtab() ppc_adjust_symtab ()
185 extern void ppc_adjust_symtab PARAMS ((void));
187 /* Niclas Andersson <nican@ida.liu.se> says this is needed. */
188 #define SUB_SEGMENT_ALIGN(SEG) 2
190 #endif /* OBJ_XCOFF */
193 /* The name of the global offset table generated by the compiler. Allow
194 this to be overridden if need be. */
195 #ifndef GLOBAL_OFFSET_TABLE_NAME
196 #define GLOBAL_OFFSET_TABLE_NAME "_GLOBAL_OFFSET_TABLE_"
199 /* Branch prediction relocations must force relocation */
200 #define TC_FORCE_RELOCATION_SECTION(FIXP,SEC) \
201 ((FIXP)->fx_r_type == BFD_RELOC_PPC_B16_BRTAKEN \
202 || (FIXP)->fx_r_type == BFD_RELOC_PPC_B16_BRNTAKEN \
203 || (FIXP)->fx_r_type == BFD_RELOC_PPC_BA16_BRTAKEN \
204 || (FIXP)->fx_r_type == BFD_RELOC_PPC_BA16_BRNTAKEN \
205 || ((FIXP)->fx_addsy && !(FIXP)->fx_subsy && (FIXP)->fx_addsy->bsym \
206 && (FIXP)->fx_addsy->bsym->section != SEC))
208 /* Support for SHF_EXCLUDE and SHT_ORDERED */
209 extern int ppc_section_letter PARAMS ((int, char **));
210 extern int ppc_section_type PARAMS ((char **));
211 extern int ppc_section_word PARAMS ((char **));
212 extern int ppc_section_flags PARAMS ((int, int, int));
214 #define md_elf_section_letter(LETTER, PTR_MSG) ppc_section_letter (LETTER, PTR_MSG)
215 #define md_elf_section_type(PTR_STR) ppc_section_type (PTR_STR)
216 #define md_elf_section_word(PTR_STR) ppc_section_word (PTR_STR)
217 #define md_elf_section_flags(FLAGS, ATTR, TYPE) ppc_section_flags (FLAGS, ATTR, TYPE)
219 /* Add extra PPC sections -- Note, for now, make .sbss2 and .PPC.EMB.sbss0 a
220 normal section, and not a bss section so that the linker doesn't crater
221 when trying to make more than 2 sections. */
222 #define ELF_TC_SPECIAL_SECTIONS \
223 { ".tags", SHT_ORDERED, SHF_ALLOC }, \
224 { ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, \
225 { ".sbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, \
226 { ".sdata2", SHT_PROGBITS, SHF_ALLOC }, \
227 { ".sbss2", SHT_PROGBITS, SHF_ALLOC }, \
228 { ".PPC.EMB.sdata0", SHT_PROGBITS, SHF_ALLOC }, \
229 { ".PPC.EMB.sbss0", SHT_PROGBITS, SHF_ALLOC },
231 #define tc_comment_chars ppc_comment_chars
232 extern const char *ppc_comment_chars;
234 /* Keep relocations relative to the GOT. */
235 #define tc_fix_adjustable(FIX) \
236 ((FIX)->fx_r_type != BFD_RELOC_16_GOTOFF \
237 && (FIX)->fx_r_type != BFD_RELOC_LO16_GOTOFF \
238 && (FIX)->fx_r_type != BFD_RELOC_HI16_GOTOFF \
239 && (FIX)->fx_r_type != BFD_RELOC_HI16_S_GOTOFF \
240 && (FIX)->fx_r_type != BFD_RELOC_GPREL16)
243 /* call md_apply_fix3 with segment instead of md_apply_fix */
244 #define MD_APPLY_FIX3
246 /* call md_pcrel_from_section, not md_pcrel_from */
247 #define MD_PCREL_FROM_SECTION(FIXP, SEC) md_pcrel_from_section(FIXP, SEC)
248 extern long md_pcrel_from_section PARAMS ((struct fix *, segT));
250 #define md_parse_name(name, exp) ppc_parse_name (name, exp)
251 extern int ppc_parse_name PARAMS ((const char *, struct expressionS *));
253 #define md_operand(x)