]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gas/config/tc-ppc.h
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / gas / config / tc-ppc.h
1 /* tc-ppc.h -- Header file for tc-ppc.c.
2 Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support.
4
5 This file is part of GAS, the GNU Assembler.
6
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)
10 any later version.
11
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.
16
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
20 02111-1307, USA. */
21
22 #define TC_PPC
23
24 #ifdef ANSI_PROTOTYPES
25 struct fix;
26 #endif
27
28 /* Set the endianness we are using. Default to big endian. */
29 #ifndef TARGET_BYTES_BIG_ENDIAN
30 #define TARGET_BYTES_BIG_ENDIAN 1
31 #endif
32
33 #ifndef BFD_ASSEMBLER
34 #error PowerPC support requires BFD_ASSEMBLER
35 #endif
36
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. */
40
41 #ifdef OBJ_COFF
42 #ifndef TE_PE
43 #define OBJ_XCOFF
44 #endif
45 #endif
46
47 /* The target BFD architecture. */
48 #define TARGET_ARCH (ppc_arch ())
49 extern enum bfd_architecture ppc_arch PARAMS ((void));
50
51 /* Whether or not the target is big endian */
52 extern int target_big_endian;
53
54 /* The target BFD format. */
55 #ifdef OBJ_COFF
56 #ifdef TE_PE
57 #define TARGET_FORMAT (target_big_endian ? "pe-powerpc" : "pe-powerpcle")
58 #else
59 #define TARGET_FORMAT "aixcoff-rs6000"
60 #endif
61 #endif
62
63 /* PowerMac has a BFD slightly different from AIX's. */
64 #ifdef TE_POWERMAC
65 #ifdef TARGET_FORMAT
66 #undef TARGET_FORMAT
67 #endif
68 #define TARGET_FORMAT "xcoff-powermac"
69 #endif
70
71 #ifdef OBJ_ELF
72 #define TARGET_FORMAT (target_big_endian ? "elf32-powerpc" : "elf32-powerpcle")
73 #endif
74
75 /* Permit temporary numeric labels. */
76 #define LOCAL_LABELS_FB 1
77
78 /* $ is used to refer to the current location. */
79 #define DOLLAR_DOT
80
81 /* Strings do not use backslash escapes under COFF. */
82 #ifdef OBJ_COFF
83 #define NO_STRING_ESCAPES
84 #endif
85
86 #ifdef OBJ_ELF
87 #define DIFF_EXPR_OK /* foo-. gets turned into PC relative relocs */
88 #endif
89
90 #if TARGET_BYTES_BIG_ENDIAN
91 #define PPC_BIG_ENDIAN 1
92 #else
93 #define PPC_BIG_ENDIAN 0
94 #endif
95
96 /* We don't need to handle .word strangely. */
97 #define WORKING_DOT_WORD
98
99 /* We set the fx_done field appropriately in md_apply_fix. */
100 #define TC_HANDLES_FX_DONE
101 \f
102 #ifdef TE_PE
103
104 /* Question marks are permitted in symbol names. */
105 #define LEX_QM 1
106
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 *));
110
111 #endif
112
113 #ifdef OBJ_XCOFF
114
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
118 tc-ppc. */
119
120 /* We need to keep some information for symbols. */
121 struct ppc_tc_sy
122 {
123 /* We keep a few linked lists of symbols. */
124 struct symbol *next;
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. */
128 int output;
129 /* The symbol class. */
130 int class;
131 /* The real name, if the symbol was renamed. */
132 char *real_name;
133 /* For a csect symbol, the subsegment we are using. This is zero
134 for symbols that are not csects. */
135 subsegT subseg;
136 /* For a csect or common symbol, the alignment to use. */
137 int align;
138 /* For a function symbol, a symbol whose value is the size. The
139 field is NULL if there is no size. */
140 struct symbol *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;
145 };
146
147 #define TC_SYMFIELD_TYPE struct ppc_tc_sy
148
149 /* We need an additional auxent for function symbols. */
150 #define OBJ_COFF_MAX_AUXENTRIES 2
151
152 /* Square and curly brackets are permitted in symbol names. */
153 #define LEX_BR 3
154
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 *));
158
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 *));
162
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 *));
166
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 *));
170
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 *));
174
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 *));
178
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 *));
182
183 /* Finish up the entire symtab. */
184 #define tc_adjust_symtab() ppc_adjust_symtab ()
185 extern void ppc_adjust_symtab PARAMS ((void));
186
187 /* Niclas Andersson <nican@ida.liu.se> says this is needed. */
188 #define SUB_SEGMENT_ALIGN(SEG) 2
189
190 #endif /* OBJ_XCOFF */
191
192 #ifdef OBJ_ELF
193
194 /* Branch prediction relocations must force relocation. */
195 #define TC_FORCE_RELOCATION_SECTION(FIXP,SEC) \
196 ((FIXP)->fx_r_type == BFD_RELOC_PPC_B16_BRTAKEN \
197 || (FIXP)->fx_r_type == BFD_RELOC_PPC_B16_BRNTAKEN \
198 || (FIXP)->fx_r_type == BFD_RELOC_PPC_BA16_BRTAKEN \
199 || (FIXP)->fx_r_type == BFD_RELOC_PPC_BA16_BRNTAKEN \
200 || ((FIXP)->fx_addsy && !(FIXP)->fx_subsy && (FIXP)->fx_addsy->bsym \
201 && (FIXP)->fx_addsy->bsym->section != SEC))
202
203 /* Support for SHF_EXCLUDE and SHT_ORDERED */
204 extern int ppc_section_letter PARAMS ((int, char **));
205 extern int ppc_section_type PARAMS ((char **));
206 extern int ppc_section_word PARAMS ((char **));
207 extern int ppc_section_flags PARAMS ((int, int, int));
208
209 #define md_elf_section_letter(LETTER, PTR_MSG) ppc_section_letter (LETTER, PTR_MSG)
210 #define md_elf_section_type(PTR_STR) ppc_section_type (PTR_STR)
211 #define md_elf_section_word(PTR_STR) ppc_section_word (PTR_STR)
212 #define md_elf_section_flags(FLAGS, ATTR, TYPE) ppc_section_flags (FLAGS, ATTR, TYPE)
213
214 /* Add extra PPC sections -- Note, for now, make .sbss2 and .PPC.EMB.sbss0 a
215 normal section, and not a bss section so that the linker doesn't crater
216 when trying to make more than 2 sections. */
217 #define ELF_TC_SPECIAL_SECTIONS \
218 { ".tags", SHT_ORDERED, SHF_ALLOC }, \
219 { ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, \
220 { ".sbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, \
221 { ".sdata2", SHT_PROGBITS, SHF_ALLOC }, \
222 { ".sbss2", SHT_PROGBITS, SHF_ALLOC }, \
223 { ".PPC.EMB.sdata0", SHT_PROGBITS, SHF_ALLOC }, \
224 { ".PPC.EMB.sbss0", SHT_PROGBITS, SHF_ALLOC },
225
226 #define tc_comment_chars ppc_comment_chars
227 extern const char *ppc_comment_chars;
228
229 /* Keep relocations relative to the GOT, or non-PC relative. */
230 #define tc_fix_adjustable(FIX) \
231 ((FIX)->fx_r_type != BFD_RELOC_16_GOTOFF \
232 && (FIX)->fx_r_type != BFD_RELOC_LO16_GOTOFF \
233 && (FIX)->fx_r_type != BFD_RELOC_HI16_GOTOFF \
234 && (FIX)->fx_r_type != BFD_RELOC_HI16_S_GOTOFF \
235 && (FIX)->fx_r_type != BFD_RELOC_GPREL16 \
236 && ! S_IS_EXTERNAL ((FIX)->fx_addsy) \
237 && ! S_IS_WEAK ((FIX)->fx_addsy) \
238 && ((FIX)->fx_pcrel \
239 || ((FIX)->fx_subsy != NULL \
240 && (S_GET_SEGMENT ((FIX)->fx_subsy) \
241 == S_GET_SEGMENT ((FIX)->fx_addsy)))))
242
243 /* We must never ever try to resolve references to externally visible
244 symbols in the assembler, because the .o file might go into a shared
245 library, and some other shared library might override that symbol. */
246 #define TC_RELOC_RTSYM_LOC_FIXUP(FIX) \
247 ((FIX)->fx_addsy == NULL \
248 || (! S_IS_EXTERNAL ((FIX)->fx_addsy) \
249 && ! S_IS_WEAK ((FIX)->fx_addsy) \
250 && S_IS_DEFINED ((FIX)->fx_addsy) \
251 && ! S_IS_COMMON ((FIX)->fx_addsy)))
252
253 #endif /* OBJ_ELF */
254
255 /* call md_apply_fix3 with segment instead of md_apply_fix */
256 #define MD_APPLY_FIX3
257
258 /* call md_pcrel_from_section, not md_pcrel_from */
259 #define MD_PCREL_FROM_SECTION(FIXP, SEC) md_pcrel_from_section(FIXP, SEC)
260 extern long md_pcrel_from_section PARAMS ((struct fix *, segT));
261
262 #define md_parse_name(name, exp) ppc_parse_name (name, exp)
263 extern int ppc_parse_name PARAMS ((const char *, struct expressionS *));
264
265 #define md_operand(x)
266