OSDN Git Service

* configure.ac: Add --enable-secureplt.
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / sysv4.h
1 /* Target definitions for GNU compiler for PowerPC running System V.4
2    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3    2004, 2005 Free Software Foundation, Inc.
4    Contributed by Cygnus Support.
5
6    This file is part of GCC.
7
8    GCC is free software; you can redistribute it and/or modify it
9    under the terms of the GNU General Public License as published
10    by the Free Software Foundation; either version 2, or (at your
11    option) any later version.
12
13    GCC is distributed in the hope that it will be useful, but WITHOUT
14    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16    License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with GCC; see the file COPYING.  If not, write to the
20    Free Software Foundation, 59 Temple Place - Suite 330, Boston,
21    MA 02111-1307, USA.  */
22
23 /* Header files should be C++ aware in general.  */
24 #undef  NO_IMPLICIT_EXTERN_C
25 #define NO_IMPLICIT_EXTERN_C
26
27 /* Yes!  We are ELF.  */
28 #define TARGET_OBJECT_FORMAT OBJECT_ELF
29
30 /* Default ABI to compile code for.  */
31 #define DEFAULT_ABI rs6000_current_abi
32
33 /* Default ABI to use.  */
34 #define RS6000_ABI_NAME "sysv"
35
36 /* Override rs6000.h definition.  */
37 #undef  ASM_DEFAULT_SPEC
38 #define ASM_DEFAULT_SPEC "-mppc"
39
40 /* Small data support types.  */
41 enum rs6000_sdata_type {
42   SDATA_NONE,                   /* No small data support.  */
43   SDATA_DATA,                   /* Just put data in .sbss/.sdata, don't use relocs.  */
44   SDATA_SYSV,                   /* Use r13 to point to .sdata/.sbss.  */
45   SDATA_EABI                    /* Use r13 like above, r2 points to .sdata2/.sbss2.  */
46 };
47
48 extern enum rs6000_sdata_type rs6000_sdata;
49
50 #define TARGET_TOC              ((target_flags & MASK_64BIT)            \
51                                  || ((target_flags & (MASK_RELOCATABLE  \
52                                                       | MASK_MINIMAL_TOC)) \
53                                      && flag_pic > 1)                   \
54                                  || DEFAULT_ABI == ABI_AIX)
55
56 #define TARGET_BITFIELD_TYPE    (! TARGET_NO_BITFIELD_TYPE)
57 #define TARGET_BIG_ENDIAN       (! TARGET_LITTLE_ENDIAN)
58 #define TARGET_NO_PROTOTYPE     (! TARGET_PROTOTYPE)
59 #define TARGET_NO_TOC           (! TARGET_TOC)
60 #define TARGET_NO_EABI          (! TARGET_EABI)
61
62 #ifdef HAVE_AS_REL16
63 #undef TARGET_SECURE_PLT
64 #define TARGET_SECURE_PLT       secure_plt
65 #endif
66
67 extern const char *rs6000_abi_name;
68 extern const char *rs6000_sdata_name;
69 extern const char *rs6000_tls_size_string; /* For -mtls-size= */
70
71 #define SDATA_DEFAULT_SIZE 8
72
73 /* Sometimes certain combinations of command options do not make sense
74    on a particular target machine.  You can define a macro
75    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
76    defined, is executed once just after all the command options have
77    been parsed.
78
79    The macro SUBTARGET_OVERRIDE_OPTIONS is provided for subtargets, to
80    get control.  */
81
82 #define SUBTARGET_OVERRIDE_OPTIONS                                      \
83 do {                                                                    \
84   if (!g_switch_set)                                                    \
85     g_switch_value = SDATA_DEFAULT_SIZE;                                \
86                                                                         \
87   if (rs6000_abi_name == NULL)                                          \
88     rs6000_abi_name = RS6000_ABI_NAME;                                  \
89                                                                         \
90   if (!strcmp (rs6000_abi_name, "sysv"))                                \
91     rs6000_current_abi = ABI_V4;                                        \
92   else if (!strcmp (rs6000_abi_name, "sysv-noeabi"))                    \
93     {                                                                   \
94       rs6000_current_abi = ABI_V4;                                      \
95       target_flags &= ~ MASK_EABI;                                      \
96     }                                                                   \
97   else if (!strcmp (rs6000_abi_name, "sysv-eabi")                       \
98            || !strcmp (rs6000_abi_name, "eabi"))                        \
99     {                                                                   \
100       rs6000_current_abi = ABI_V4;                                      \
101       target_flags |= MASK_EABI;                                        \
102     }                                                                   \
103   else if (!strcmp (rs6000_abi_name, "aixdesc"))                        \
104     rs6000_current_abi = ABI_AIX;                                       \
105   else if (!strcmp (rs6000_abi_name, "freebsd"))                        \
106     rs6000_current_abi = ABI_V4;                                        \
107   else if (!strcmp (rs6000_abi_name, "linux"))                          \
108     {                                                                   \
109       if (TARGET_64BIT)                                                 \
110         rs6000_current_abi = ABI_AIX;                                   \
111       else                                                              \
112         rs6000_current_abi = ABI_V4;                                    \
113     }                                                                   \
114   else if (!strcmp (rs6000_abi_name, "gnu"))                            \
115     rs6000_current_abi = ABI_V4;                                        \
116   else if (!strcmp (rs6000_abi_name, "netbsd"))                         \
117     rs6000_current_abi = ABI_V4;                                        \
118   else if (!strcmp (rs6000_abi_name, "openbsd"))                        \
119     rs6000_current_abi = ABI_V4;                                        \
120   else if (!strcmp (rs6000_abi_name, "i960-old"))                       \
121     {                                                                   \
122       rs6000_current_abi = ABI_V4;                                      \
123       target_flags |= (MASK_LITTLE_ENDIAN | MASK_EABI                   \
124                        | MASK_NO_BITFIELD_WORD);                        \
125       target_flags &= ~MASK_STRICT_ALIGN;                               \
126     }                                                                   \
127   else                                                                  \
128     {                                                                   \
129       rs6000_current_abi = ABI_V4;                                      \
130       error ("bad value for -mcall-%s", rs6000_abi_name);               \
131     }                                                                   \
132                                                                         \
133   if (rs6000_sdata_name)                                                \
134     {                                                                   \
135       if (!strcmp (rs6000_sdata_name, "none"))                          \
136         rs6000_sdata = SDATA_NONE;                                      \
137       else if (!strcmp (rs6000_sdata_name, "data"))                     \
138         rs6000_sdata = SDATA_DATA;                                      \
139       else if (!strcmp (rs6000_sdata_name, "default"))                  \
140         rs6000_sdata = (TARGET_EABI) ? SDATA_EABI : SDATA_SYSV;         \
141       else if (!strcmp (rs6000_sdata_name, "sysv"))                     \
142         rs6000_sdata = SDATA_SYSV;                                      \
143       else if (!strcmp (rs6000_sdata_name, "eabi"))                     \
144         rs6000_sdata = SDATA_EABI;                                      \
145       else                                                              \
146         error ("bad value for -msdata=%s", rs6000_sdata_name);          \
147     }                                                                   \
148   else if (DEFAULT_ABI == ABI_V4)                                       \
149     {                                                                   \
150       rs6000_sdata = SDATA_DATA;                                        \
151       rs6000_sdata_name = "data";                                       \
152     }                                                                   \
153   else                                                                  \
154     {                                                                   \
155       rs6000_sdata = SDATA_NONE;                                        \
156       rs6000_sdata_name = "none";                                       \
157     }                                                                   \
158                                                                         \
159   if (TARGET_RELOCATABLE &&                                             \
160       (rs6000_sdata == SDATA_EABI || rs6000_sdata == SDATA_SYSV))       \
161     {                                                                   \
162       rs6000_sdata = SDATA_DATA;                                        \
163       error ("-mrelocatable and -msdata=%s are incompatible",           \
164              rs6000_sdata_name);                                        \
165     }                                                                   \
166                                                                         \
167   else if (flag_pic && DEFAULT_ABI != ABI_AIX                           \
168            && (rs6000_sdata == SDATA_EABI                               \
169                || rs6000_sdata == SDATA_SYSV))                          \
170     {                                                                   \
171       rs6000_sdata = SDATA_DATA;                                        \
172       error ("-f%s and -msdata=%s are incompatible",                    \
173              (flag_pic > 1) ? "PIC" : "pic",                            \
174              rs6000_sdata_name);                                        \
175     }                                                                   \
176                                                                         \
177   if ((rs6000_sdata != SDATA_NONE && DEFAULT_ABI != ABI_V4)             \
178       || (rs6000_sdata == SDATA_EABI && !TARGET_EABI))                  \
179     {                                                                   \
180       rs6000_sdata = SDATA_NONE;                                        \
181       error ("-msdata=%s and -mcall-%s are incompatible",               \
182              rs6000_sdata_name, rs6000_abi_name);                       \
183     }                                                                   \
184                                                                         \
185   targetm.have_srodata_section = rs6000_sdata == SDATA_EABI;            \
186                                                                         \
187   if (TARGET_RELOCATABLE && !TARGET_MINIMAL_TOC)                        \
188     {                                                                   \
189       target_flags |= MASK_MINIMAL_TOC;                                 \
190       error ("-mrelocatable and -mno-minimal-toc are incompatible");    \
191     }                                                                   \
192                                                                         \
193   if (TARGET_RELOCATABLE && rs6000_current_abi == ABI_AIX)              \
194     {                                                                   \
195       target_flags &= ~MASK_RELOCATABLE;                                \
196       error ("-mrelocatable and -mcall-%s are incompatible",            \
197              rs6000_abi_name);                                          \
198     }                                                                   \
199                                                                         \
200   if (!TARGET_64BIT && flag_pic > 1 && rs6000_current_abi == ABI_AIX)   \
201     {                                                                   \
202       flag_pic = 0;                                                     \
203       error ("-fPIC and -mcall-%s are incompatible",                    \
204              rs6000_abi_name);                                          \
205     }                                                                   \
206                                                                         \
207   if (rs6000_current_abi == ABI_AIX && TARGET_LITTLE_ENDIAN)            \
208     {                                                                   \
209       target_flags &= ~MASK_LITTLE_ENDIAN;                              \
210       error ("-mcall-aixdesc must be big endian");                      \
211     }                                                                   \
212                                                                         \
213   if (TARGET_SECURE_PLT != secure_plt)                                  \
214     {                                                                   \
215       error ("-msecure-plt not supported by your assembler");           \
216     }                                                                   \
217                                                                         \
218   /* Treat -fPIC the same as -mrelocatable.  */                         \
219   if (flag_pic > 1 && DEFAULT_ABI != ABI_AIX)                           \
220     target_flags |= MASK_RELOCATABLE | MASK_MINIMAL_TOC | MASK_NO_FP_IN_TOC; \
221                                                                         \
222   else if (TARGET_RELOCATABLE)                                          \
223     flag_pic = 2;                                                       \
224 } while (0)
225
226 #ifndef RS6000_BI_ARCH
227 # define SUBSUBTARGET_OVERRIDE_OPTIONS                                  \
228 do {                                                                    \
229   if ((TARGET_DEFAULT ^ target_flags) & MASK_64BIT)                     \
230     error ("-m%s not supported in this configuration",                  \
231            (target_flags & MASK_64BIT) ? "64" : "32");                  \
232 } while (0)
233 #endif
234
235 /* Override rs6000.h definition.  */
236 #undef  TARGET_DEFAULT
237 #define TARGET_DEFAULT (MASK_POWERPC | MASK_NEW_MNEMONICS)
238
239 /* Override rs6000.h definition.  */
240 #undef  PROCESSOR_DEFAULT
241 #define PROCESSOR_DEFAULT PROCESSOR_PPC750
242
243 /* SVR4 only defined for PowerPC, so short-circuit POWER patterns.  */
244 #undef  TARGET_POWER
245 #define TARGET_POWER 0
246
247 #define FIXED_R2 1
248 /* System V.4 uses register 13 as a pointer to the small data area,
249    so it is not available to the normal user.  */
250 #define FIXED_R13 1
251
252 /* Size of the V.4 varargs area if needed.  */
253 /* Override rs6000.h definition.  */
254 #undef  RS6000_VARARGS_AREA
255 #define RS6000_VARARGS_AREA (current_function_stdarg ? RS6000_VARARGS_SIZE : 0)
256
257 /* Override default big endianism definitions in rs6000.h.  */
258 #undef  BYTES_BIG_ENDIAN
259 #undef  WORDS_BIG_ENDIAN
260 #define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN)
261 #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN)
262
263 /* Define this to set the endianness to use in libgcc2.c, which can
264    not depend on target_flags.  */
265 #if !defined(__LITTLE_ENDIAN__) && !defined(__sun__)
266 #define LIBGCC2_WORDS_BIG_ENDIAN 1
267 #else
268 #define LIBGCC2_WORDS_BIG_ENDIAN 0
269 #endif
270
271 /* Define cutoff for using external functions to save floating point.
272    Currently on V.4, always use inline stores.  */
273 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 64)
274
275 /* Put jump tables in read-only memory, rather than in .text.  */
276 #define JUMP_TABLES_IN_TEXT_SECTION 0
277
278 /* Prefix and suffix to use to saving floating point.  */
279 #define SAVE_FP_PREFIX "_savefpr_"
280 #define SAVE_FP_SUFFIX "_l"
281
282 /* Prefix and suffix to use to restoring floating point.  */
283 #define RESTORE_FP_PREFIX "_restfpr_"
284 #define RESTORE_FP_SUFFIX "_l"
285
286 /* Type used for ptrdiff_t, as a string used in a declaration.  */
287 #define PTRDIFF_TYPE "int"
288
289 /* Type used for wchar_t, as a string used in a declaration.  */
290 /* Override svr4.h definition.  */
291 #undef  WCHAR_TYPE
292 #define WCHAR_TYPE "long int"
293
294 /* Width of wchar_t in bits.  */
295 /* Override svr4.h definition.  */
296 #undef  WCHAR_TYPE_SIZE
297 #define WCHAR_TYPE_SIZE 32
298
299 /* Make int foo : 8 not cause structures to be aligned to an int boundary.  */
300 /* Override elfos.h definition.  */
301 #undef  PCC_BITFIELD_TYPE_MATTERS
302 #define PCC_BITFIELD_TYPE_MATTERS (TARGET_BITFIELD_TYPE)
303
304 #undef  BITFIELD_NBYTES_LIMITED
305 #define BITFIELD_NBYTES_LIMITED (TARGET_NO_BITFIELD_WORD)
306
307 /* Define this macro to be the value 1 if instructions will fail to
308    work if given data not on the nominal alignment.  If instructions
309    will merely go slower in that case, define this macro as 0.  */
310 #undef  STRICT_ALIGNMENT
311 #define STRICT_ALIGNMENT (TARGET_STRICT_ALIGN)
312
313 /* Define this macro if you wish to preserve a certain alignment for
314    the stack pointer, greater than what the hardware enforces.  The
315    definition is a C expression for the desired alignment (measured
316    in bits).  This macro must evaluate to a value equal to or larger
317    than STACK_BOUNDARY.
318    For the SYSV ABI and variants the alignment of the stack pointer
319    is usually controlled manually in rs6000.c. However, to maintain
320    alignment across alloca () in all circumstances,
321    PREFERRED_STACK_BOUNDARY needs to be set as well.
322    This has the additional advantage of allowing a bigger maximum
323    alignment of user objects on the stack.  */
324
325 #undef PREFERRED_STACK_BOUNDARY
326 #define PREFERRED_STACK_BOUNDARY 128
327
328 /* Real stack boundary as mandated by the appropriate ABI.  */
329 #define ABI_STACK_BOUNDARY \
330   ((TARGET_EABI && !TARGET_ALTIVEC && !TARGET_ALTIVEC_ABI) ? 64 : 128)
331
332 /* An expression for the alignment of a structure field FIELD if the
333    alignment computed in the usual way is COMPUTED.  */
334 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED)                                   \
335         ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE)     \
336          ? 128 : COMPUTED)
337
338 /* Define this macro as an expression for the alignment of a type
339    (given by TYPE as a tree node) if the alignment computed in the
340    usual way is COMPUTED and the alignment explicitly specified was
341    SPECIFIED.  */
342 #define ROUND_TYPE_ALIGN(TYPE, COMPUTED, SPECIFIED)                     \
343         ((TARGET_ALTIVEC  && TREE_CODE (TYPE) == VECTOR_TYPE)           \
344          ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128)                     \
345          : MAX (COMPUTED, SPECIFIED))
346
347 #undef  BIGGEST_FIELD_ALIGNMENT
348
349 /* Use ELF style section commands.  */
350
351 #define TEXT_SECTION_ASM_OP     "\t.section\t\".text\""
352
353 #define DATA_SECTION_ASM_OP     "\t.section\t\".data\""
354
355 #define BSS_SECTION_ASM_OP      "\t.section\t\".bss\""
356
357 /* Override elfos.h definition.  */
358 #undef  INIT_SECTION_ASM_OP
359 #define INIT_SECTION_ASM_OP "\t.section\t\".init\",\"ax\""
360
361 /* Override elfos.h definition.  */
362 #undef  FINI_SECTION_ASM_OP
363 #define FINI_SECTION_ASM_OP "\t.section\t\".fini\",\"ax\""
364
365 #define TOC_SECTION_ASM_OP "\t.section\t\".got\",\"aw\""
366
367 /* Put PC relative got entries in .got2.  */
368 #define MINIMAL_TOC_SECTION_ASM_OP \
369   (TARGET_RELOCATABLE || (flag_pic && DEFAULT_ABI != ABI_AIX)           \
370    ? "\t.section\t\".got2\",\"aw\"" : "\t.section\t\".got1\",\"aw\"")
371
372 #define SDATA_SECTION_ASM_OP "\t.section\t\".sdata\",\"aw\""
373 #define SDATA2_SECTION_ASM_OP "\t.section\t\".sdata2\",\"a\""
374 #define SBSS_SECTION_ASM_OP "\t.section\t\".sbss\",\"aw\",@nobits"
375
376 /* Besides the usual ELF sections, we need a toc section.  */
377 /* Override elfos.h definition.  */
378 #undef  EXTRA_SECTIONS
379 #define EXTRA_SECTIONS in_toc, in_sdata, in_sdata2, in_sbss, in_init, in_fini
380
381 /* Override elfos.h definition.  */
382 #undef  EXTRA_SECTION_FUNCTIONS
383 #define EXTRA_SECTION_FUNCTIONS                                         \
384   TOC_SECTION_FUNCTION                                                  \
385   SDATA_SECTION_FUNCTION                                                \
386   SDATA2_SECTION_FUNCTION                                               \
387   SBSS_SECTION_FUNCTION                                                 \
388   INIT_SECTION_FUNCTION                                                 \
389   FINI_SECTION_FUNCTION
390
391 #define TOC_SECTION_FUNCTION                                            \
392 void                                                                    \
393 toc_section (void)                                                      \
394 {                                                                       \
395   if (in_section != in_toc)                                             \
396     {                                                                   \
397       in_section = in_toc;                                              \
398       if (DEFAULT_ABI == ABI_AIX                                        \
399           && TARGET_MINIMAL_TOC                                         \
400           && !TARGET_RELOCATABLE)                                       \
401         {                                                               \
402           if (! toc_initialized)                                        \
403             {                                                           \
404               toc_initialized = 1;                                      \
405               fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP);       \
406               (*targetm.asm_out.internal_label) (asm_out_file, "LCTOC", 0); \
407               fprintf (asm_out_file, "\t.tc ");                         \
408               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1[TC],"); \
409               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \
410               fprintf (asm_out_file, "\n");                             \
411                                                                         \
412               fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); \
413               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \
414               fprintf (asm_out_file, " = .+32768\n");                   \
415             }                                                           \
416           else                                                          \
417             fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); \
418         }                                                               \
419       else if (DEFAULT_ABI == ABI_AIX && !TARGET_RELOCATABLE)           \
420         fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP);             \
421       else                                                              \
422         {                                                               \
423           fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP);   \
424           if (! toc_initialized)                                        \
425             {                                                           \
426               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \
427               fprintf (asm_out_file, " = .+32768\n");                   \
428               toc_initialized = 1;                                      \
429             }                                                           \
430         }                                                               \
431     }                                                                   \
432 }                                                                       \
433                                                                         \
434 extern int in_toc_section (void);                                       \
435 int in_toc_section (void)                                               \
436 {                                                                       \
437   return in_section == in_toc;                                          \
438 }
439
440 #define SDATA_SECTION_FUNCTION                                          \
441 void                                                                    \
442 sdata_section (void)                                                    \
443 {                                                                       \
444   if (in_section != in_sdata)                                           \
445     {                                                                   \
446       in_section = in_sdata;                                            \
447       fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP);             \
448     }                                                                   \
449 }
450
451 #define SDATA2_SECTION_FUNCTION                                         \
452 void                                                                    \
453 sdata2_section (void)                                                   \
454 {                                                                       \
455   if (in_section != in_sdata2)                                          \
456     {                                                                   \
457       in_section = in_sdata2;                                           \
458       fprintf (asm_out_file, "%s\n", SDATA2_SECTION_ASM_OP);            \
459     }                                                                   \
460 }
461
462 #define SBSS_SECTION_FUNCTION                                           \
463 void                                                                    \
464 sbss_section (void)                                                     \
465 {                                                                       \
466   if (in_section != in_sbss)                                            \
467     {                                                                   \
468       in_section = in_sbss;                                             \
469       fprintf (asm_out_file, "%s\n", SBSS_SECTION_ASM_OP);              \
470     }                                                                   \
471 }
472
473 #define INIT_SECTION_FUNCTION                                           \
474 void                                                                    \
475 init_section (void)                                                     \
476 {                                                                       \
477   if (in_section != in_init)                                            \
478     {                                                                   \
479       in_section = in_init;                                             \
480       fprintf (asm_out_file, "%s\n", INIT_SECTION_ASM_OP);              \
481     }                                                                   \
482 }
483
484 #define FINI_SECTION_FUNCTION                                           \
485 void                                                                    \
486 fini_section (void)                                                     \
487 {                                                                       \
488   if (in_section != in_fini)                                            \
489     {                                                                   \
490       in_section = in_fini;                                             \
491       fprintf (asm_out_file, "%s\n", FINI_SECTION_ASM_OP);              \
492     }                                                                   \
493 }
494
495 /* Override default elf definitions.  */
496 #undef  TARGET_ASM_SELECT_RTX_SECTION
497 #define TARGET_ASM_SELECT_RTX_SECTION rs6000_elf_select_rtx_section
498 #undef  TARGET_ASM_SELECT_SECTION
499 #define TARGET_ASM_SELECT_SECTION  rs6000_elf_select_section
500 #define TARGET_ASM_UNIQUE_SECTION  rs6000_elf_unique_section
501
502 /* Return nonzero if this entry is to be written into the constant pool
503    in a special way.  We do so if this is a SYMBOL_REF, LABEL_REF or a CONST
504    containing one of them.  If -mfp-in-toc (the default), we also do
505    this for floating-point constants.  We actually can only do this
506    if the FP formats of the target and host machines are the same, but
507    we can't check that since not every file that uses
508    GO_IF_LEGITIMATE_ADDRESS_P includes real.h.
509
510    Unlike AIX, we don't key off of -mminimal-toc, but instead do not
511    allow floating point constants in the TOC if -mrelocatable.  */
512
513 #undef  ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
514 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE)                        \
515   (TARGET_TOC                                                           \
516    && (GET_CODE (X) == SYMBOL_REF                                       \
517        || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS      \
518            && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF)           \
519        || GET_CODE (X) == LABEL_REF                                     \
520        || (GET_CODE (X) == CONST_INT                                    \
521            && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode))      \
522        || (!TARGET_NO_FP_IN_TOC                                         \
523            && !TARGET_RELOCATABLE                                       \
524            && GET_CODE (X) == CONST_DOUBLE                              \
525            && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT               \
526            && BITS_PER_WORD == HOST_BITS_PER_INT)))
527
528 /* These macros generate the special .type and .size directives which
529    are used to set the corresponding fields of the linker symbol table
530    entries in an ELF object file under SVR4.  These macros also output
531    the starting labels for the relevant functions/objects.  */
532
533 /* Write the extra assembler code needed to declare a function properly.
534    Some svr4 assemblers need to also have something extra said about the
535    function's return value.  We allow for that here.  */
536
537 extern int rs6000_pic_labelno;
538
539 /* Override elfos.h definition.  */
540 #undef  ASM_DECLARE_FUNCTION_NAME
541 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
542   rs6000_elf_declare_function_name ((FILE), (NAME), (DECL))
543
544 /* The USER_LABEL_PREFIX stuff is affected by the -fleading-underscore
545    flag.  The LOCAL_LABEL_PREFIX variable is used by dbxelf.h.  */
546
547 #define LOCAL_LABEL_PREFIX "."
548 #define USER_LABEL_PREFIX ""
549
550 /* svr4.h overrides (*targetm.asm_out.internal_label).  */
551
552 #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX)   \
553   asm_fprintf (FILE, "%L%s", PREFIX)
554
555 /* Globalizing directive for a label.  */
556 #define GLOBAL_ASM_OP "\t.globl "
557
558 /* This says how to output assembler code to declare an
559    uninitialized internal linkage data object.  Under SVR4,
560    the linker seems to want the alignment of data objects
561    to depend on their types.  We do exactly that here.  */
562
563 #define LOCAL_ASM_OP    "\t.local\t"
564
565 #define LCOMM_ASM_OP    "\t.lcomm\t"
566
567 /* Override elfos.h definition.  */
568 #undef  ASM_OUTPUT_ALIGNED_LOCAL
569 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)               \
570 do {                                                                    \
571   if (rs6000_sdata != SDATA_NONE && (SIZE) > 0                          \
572       && (SIZE) <= g_switch_value)                                      \
573     {                                                                   \
574       sbss_section ();                                                  \
575       ASM_OUTPUT_ALIGN (FILE, exact_log2 (ALIGN / BITS_PER_UNIT));      \
576       ASM_OUTPUT_LABEL (FILE, NAME);                                    \
577       ASM_OUTPUT_SKIP (FILE, SIZE);                                     \
578       if (!flag_inhibit_size_directive && (SIZE) > 0)                   \
579         ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE);                   \
580     }                                                                   \
581   else                                                                  \
582     {                                                                   \
583       fprintf (FILE, "%s", LCOMM_ASM_OP);                               \
584       assemble_name ((FILE), (NAME));                                   \
585       fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",          \
586                (SIZE), (ALIGN) / BITS_PER_UNIT);                        \
587     }                                                                   \
588   ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");                     \
589 } while (0)
590
591 /* Describe how to emit uninitialized external linkage items.  */
592 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN)           \
593 do {                                                                    \
594   ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN);                   \
595 } while (0)
596
597 #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
598 /* To support -falign-* switches we need to use .p2align so
599    that alignment directives in code sections will be padded
600    with no-op instructions, rather than zeroes.  */
601 #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)                    \
602   if ((LOG) != 0)                                                       \
603     {                                                                   \
604       if ((MAX_SKIP) == 0)                                              \
605         fprintf ((FILE), "\t.p2align %d\n", (LOG));                     \
606       else                                                              \
607         fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));     \
608     }
609 #endif
610
611 /* This is how to output code to push a register on the stack.
612    It need not be very fast code.
613
614    On the rs6000, we must keep the backchain up to date.  In order
615    to simplify things, always allocate 16 bytes for a push (System V
616    wants to keep stack aligned to a 16 byte boundary).  */
617
618 #define ASM_OUTPUT_REG_PUSH(FILE, REGNO)                                \
619 do {                                                                    \
620   if (DEFAULT_ABI == ABI_V4)                                            \
621     asm_fprintf (FILE,                                                  \
622                  "\t{stu|stwu} %s,-16(%s)\n\t{st|stw} %s,12(%s)\n",     \
623                  reg_names[1], reg_names[1], reg_names[REGNO],          \
624                  reg_names[1]);                                         \
625 } while (0)
626
627 /* This is how to output an insn to pop a register from the stack.
628    It need not be very fast code.  */
629
630 #define ASM_OUTPUT_REG_POP(FILE, REGNO)                                 \
631 do {                                                                    \
632   if (DEFAULT_ABI == ABI_V4)                                            \
633     asm_fprintf (FILE,                                                  \
634                  "\t{l|lwz} %s,12(%s)\n\t{ai|addic} %s,%s,16\n",        \
635                  reg_names[REGNO], reg_names[1], reg_names[1],          \
636                  reg_names[1]);                                         \
637 } while (0)
638
639 /* Switch  Recognition by gcc.c.  Add -G xx support.  */
640
641 /* Override svr4.h definition.  */
642 #undef  SWITCH_TAKES_ARG
643 #define SWITCH_TAKES_ARG(CHAR)                                          \
644   ((CHAR) == 'D' || (CHAR) == 'U' || (CHAR) == 'o'                      \
645    || (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u'                   \
646    || (CHAR) == 'I' || (CHAR) == 'm' || (CHAR) == 'x'                   \
647    || (CHAR) == 'L' || (CHAR) == 'A' || (CHAR) == 'V'                   \
648    || (CHAR) == 'B' || (CHAR) == 'b' || (CHAR) == 'G')
649
650 extern int fixuplabelno;
651
652 /* Handle constructors specially for -mrelocatable.  */
653 #define TARGET_ASM_CONSTRUCTOR  rs6000_elf_asm_out_constructor
654 #define TARGET_ASM_DESTRUCTOR   rs6000_elf_asm_out_destructor
655
656 /* This is the end of what might become sysv4.h.  */
657
658 /* Use DWARF 2 debugging information by default.  */
659 #undef  PREFERRED_DEBUGGING_TYPE
660 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
661
662 /* Historically we have also supported stabs debugging.  */
663 #define DBX_DEBUGGING_INFO 1
664
665 #define DBX_REGISTER_NUMBER(REGNO) rs6000_dbx_register_number (REGNO)
666
667 /* Map register numbers held in the call frame info that gcc has
668    collected using DWARF_FRAME_REGNUM to those that should be output in
669    .debug_frame and .eh_frame.  We continue to use gcc hard reg numbers
670    for .eh_frame, but use the numbers mandated by the various ABIs for
671    .debug_frame.  rs6000_emit_prologue has translated any combination of
672    CR2, CR3, CR4 saves to a save of CR2.  The actual code emitted saves
673    the whole of CR, so we map CR2_REGNO to the DWARF reg for CR.  */
674 #define DWARF2_FRAME_REG_OUT(REGNO, FOR_EH)     \
675   ((FOR_EH) ? (REGNO)                           \
676    : (REGNO) == CR2_REGNO ? 64                  \
677    : DBX_REGISTER_NUMBER (REGNO))
678
679 #define TARGET_ENCODE_SECTION_INFO  rs6000_elf_encode_section_info
680 #define TARGET_IN_SMALL_DATA_P  rs6000_elf_in_small_data_p
681 #define TARGET_SECTION_TYPE_FLAGS  rs6000_elf_section_type_flags
682
683 /* The ELF version doesn't encode [DS] or whatever at the end of symbols.  */
684
685 #define RS6000_OUTPUT_BASENAME(FILE, NAME)      \
686     assemble_name (FILE, NAME)
687
688 /* We have to output the stabs for the function name *first*, before
689    outputting its label.  */
690
691 #define DBX_FUNCTION_FIRST
692
693 /* This is the end of what might become sysv4dbx.h.  */
694
695 #ifndef TARGET_VERSION
696 #define TARGET_VERSION fprintf (stderr, " (PowerPC System V.4)");
697 #endif
698 \f
699 #define TARGET_OS_SYSV_CPP_BUILTINS()           \
700   do                                            \
701     {                                           \
702       if (flag_pic == 1)                        \
703         {                                       \
704           builtin_define ("__pic__=1");         \
705           builtin_define ("__PIC__=1");         \
706         }                                       \
707       else if (flag_pic == 2)                   \
708         {                                       \
709           builtin_define ("__pic__=2");         \
710           builtin_define ("__PIC__=2");         \
711         }                                       \
712       if (target_flags_explicit                 \
713           & MASK_RELOCATABLE)                   \
714         builtin_define ("_RELOCATABLE");        \
715     }                                           \
716   while (0)
717
718 #ifndef TARGET_OS_CPP_BUILTINS
719 #define TARGET_OS_CPP_BUILTINS()                \
720   do                                            \
721     {                                           \
722       builtin_define_std ("PPC");               \
723       builtin_define_std ("unix");              \
724       builtin_define ("__svr4__");              \
725       builtin_assert ("system=unix");           \
726       builtin_assert ("system=svr4");           \
727       builtin_assert ("cpu=powerpc");           \
728       builtin_assert ("machine=powerpc");       \
729       TARGET_OS_SYSV_CPP_BUILTINS ();           \
730     }                                           \
731   while (0)
732 #endif
733
734 /* Pass various options to the assembler.  */
735 /* Override svr4.h definition.  */
736 #undef  ASM_SPEC
737 #define ASM_SPEC "%(asm_cpu) \
738 %{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \
739 %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
740 %{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} \
741 %{memb|msdata|msdata=eabi: -memb} \
742 %{mlittle|mlittle-endian:-mlittle; \
743   mbig|mbig-endian      :-mbig;    \
744   mcall-aixdesc |                  \
745   mcall-freebsd |                  \
746   mcall-netbsd  |                  \
747   mcall-openbsd |                  \
748   mcall-linux   |                  \
749   mcall-gnu             :-mbig;    \
750   mcall-i960-old        :-mlittle}"
751
752 #define CC1_ENDIAN_BIG_SPEC ""
753
754 #define CC1_ENDIAN_LITTLE_SPEC "\
755 %{!mstrict-align: %{!mno-strict-align: \
756     %{!mcall-i960-old: \
757         -mstrict-align \
758     } \
759 }}"
760
761 #define CC1_ENDIAN_DEFAULT_SPEC "%(cc1_endian_big)"
762
763 #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
764 #define CC1_SECURE_PLT_DEFAULT_SPEC ""
765 #endif
766
767 /* Pass -G xxx to the compiler and set correct endian mode.  */
768 #define CC1_SPEC "%{G*} \
769 %{mlittle|mlittle-endian: %(cc1_endian_little);           \
770   mbig   |mbig-endian   : %(cc1_endian_big);              \
771   mcall-aixdesc |                                         \
772   mcall-freebsd |                                         \
773   mcall-netbsd  |                                         \
774   mcall-openbsd |                                         \
775   mcall-linux   |                                         \
776   mcall-gnu             : -mbig %(cc1_endian_big);        \
777   mcall-i960-old        : -mlittle %(cc1_endian_little);  \
778                         : %(cc1_endian_default)}          \
779 %{meabi: %{!mcall-*: -mcall-sysv }} \
780 %{!meabi: %{!mno-eabi: \
781     %{mrelocatable: -meabi } \
782     %{mcall-freebsd: -mno-eabi } \
783     %{mcall-i960-old: -meabi } \
784     %{mcall-linux: -mno-eabi } \
785     %{mcall-gnu: -mno-eabi } \
786     %{mcall-netbsd: -mno-eabi } \
787     %{mcall-openbsd: -mno-eabi }}} \
788 %{msdata: -msdata=default} \
789 %{mno-sdata: -msdata=none} \
790 %{!mbss-plt: %{!msecure-plt: %(cc1_secure_plt_default)}} \
791 %{profile: -p}"
792
793 /* Don't put -Y P,<path> for cross compilers.  */
794 #ifndef CROSS_COMPILE
795 #define LINK_PATH_SPEC "\
796 %{!R*:%{L*:-R %*}} \
797 %{!nostdlib: %{!YP,*: \
798     %{compat-bsd: \
799         %{p:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
800         %{!p:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}} \
801         %{!R*: %{!L*: -R /usr/ucblib}} \
802     %{!compat-bsd: \
803         %{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
804         %{!p:-Y P,/usr/ccs/lib:/usr/lib}}}}"
805
806 #else
807 #define LINK_PATH_SPEC ""
808 #endif
809
810 /* Default starting address if specified.  */
811 #define LINK_START_SPEC "\
812 %{mads         : %(link_start_ads)         ; \
813   myellowknife : %(link_start_yellowknife) ; \
814   mmvme        : %(link_start_mvme)        ; \
815   msim         : %(link_start_sim)         ; \
816   mwindiss     : %(link_start_windiss)     ; \
817   mcall-freebsd: %(link_start_freebsd)     ; \
818   mcall-linux  : %(link_start_linux)       ; \
819   mcall-gnu    : %(link_start_gnu)         ; \
820   mcall-netbsd : %(link_start_netbsd)      ; \
821   mcall-openbsd: %(link_start_openbsd)     ; \
822                : %(link_start_default)     }"
823
824 #define LINK_START_DEFAULT_SPEC ""
825
826 /* Override svr4.h definition.  */
827 #undef  LINK_SPEC
828 #define LINK_SPEC "\
829 %{h*} %{v:-V} %{!msdata=none:%{G*}} %{msdata=none:-G0} \
830 %{YP,*} %{R*} \
831 %{Qy:} %{!Qn:-Qy} \
832 %(link_shlib) \
833 %{!Wl,-T*: %{!T*: %(link_start) }} \
834 %(link_target) \
835 %(link_os)"
836
837 /* For now, turn off shared libraries by default.  */
838 #ifndef SHARED_LIB_SUPPORT
839 #define NO_SHARED_LIB_SUPPORT
840 #endif
841
842 #ifndef NO_SHARED_LIB_SUPPORT
843 /* Shared libraries are default.  */
844 #define LINK_SHLIB_SPEC "\
845 %{!static: %(link_path) %{!R*:%{L*:-R %*}}} \
846 %{mshlib: } \
847 %{static:-dn -Bstatic} \
848 %{shared:-G -dy -z text} \
849 %{symbolic:-Bsymbolic -G -dy -z text}"
850
851 #else
852 /* Shared libraries are not default.  */
853 #define LINK_SHLIB_SPEC "\
854 %{mshlib: %(link_path) } \
855 %{!mshlib: %{!shared: %{!symbolic: -dn -Bstatic}}} \
856 %{static: } \
857 %{shared:-G -dy -z text %(link_path) } \
858 %{symbolic:-Bsymbolic -G -dy -z text %(link_path) }"
859 #endif
860
861 /* Override the default target of the linker.  */
862 #define LINK_TARGET_SPEC "\
863 %{mlittle: --oformat elf32-powerpcle } %{mlittle-endian: --oformat elf32-powerpcle } \
864 %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
865     %{mcall-i960-old: --oformat elf32-powerpcle} \
866   }}}}"
867
868 /* Any specific OS flags.  */
869 #define LINK_OS_SPEC "\
870 %{mads         : %(link_os_ads)         ; \
871   myellowknife : %(link_os_yellowknife) ; \
872   mmvme        : %(link_os_mvme)        ; \
873   msim         : %(link_os_sim)         ; \
874   mwindiss     : %(link_os_windiss)     ; \
875   mcall-freebsd: %(link_os_freebsd)     ; \
876   mcall-linux  : %(link_os_linux)       ; \
877   mcall-gnu    : %(link_os_gnu)         ; \
878   mcall-netbsd : %(link_os_netbsd)      ; \
879   mcall-openbsd: %(link_os_openbsd)     ; \
880                : %(link_os_default)     }"
881
882 #define LINK_OS_DEFAULT_SPEC ""
883
884 /* Override rs6000.h definition.  */
885 #undef  CPP_SPEC
886 #define CPP_SPEC "%{posix: -D_POSIX_SOURCE} \
887 %{mads         : %(cpp_os_ads)         ; \
888   myellowknife : %(cpp_os_yellowknife) ; \
889   mmvme        : %(cpp_os_mvme)        ; \
890   msim         : %(cpp_os_sim)         ; \
891   mwindiss     : %(cpp_os_windiss)     ; \
892   mcall-freebsd: %(cpp_os_freebsd)     ; \
893   mcall-linux  : %(cpp_os_linux)       ; \
894   mcall-gnu    : %(cpp_os_gnu)         ; \
895   mcall-netbsd : %(cpp_os_netbsd)      ; \
896   mcall-openbsd: %(cpp_os_openbsd)     ; \
897                : %(cpp_os_default)     }"
898
899 #define CPP_OS_DEFAULT_SPEC ""
900
901 /* Override svr4.h definition.  */
902 #undef  STARTFILE_SPEC
903 #define STARTFILE_SPEC "\
904 %{mads         : %(startfile_ads)         ; \
905   myellowknife : %(startfile_yellowknife) ; \
906   mmvme        : %(startfile_mvme)        ; \
907   msim         : %(startfile_sim)         ; \
908   mwindiss     : %(startfile_windiss)     ; \
909   mcall-freebsd: %(startfile_freebsd)     ; \
910   mcall-linux  : %(startfile_linux)       ; \
911   mcall-gnu    : %(startfile_gnu)         ; \
912   mcall-netbsd : %(startfile_netbsd)      ; \
913   mcall-openbsd: %(startfile_openbsd)     ; \
914                : %(startfile_default)     }"
915
916 #define STARTFILE_DEFAULT_SPEC ""
917
918 /* Override svr4.h definition.  */
919 #undef  LIB_SPEC
920 #define LIB_SPEC "\
921 %{mads         : %(lib_ads)         ; \
922   myellowknife : %(lib_yellowknife) ; \
923   mmvme        : %(lib_mvme)        ; \
924   msim         : %(lib_sim)         ; \
925   mwindiss     : %(lib_windiss)     ; \
926   mcall-freebsd: %(lib_freebsd)     ; \
927   mcall-linux  : %(lib_linux)       ; \
928   mcall-gnu    : %(lib_gnu)         ; \
929   mcall-netbsd : %(lib_netbsd)      ; \
930   mcall-openbsd: %(lib_openbsd)     ; \
931                : %(lib_default)     }"
932
933 #define LIB_DEFAULT_SPEC ""
934
935 /* Override svr4.h definition.  */
936 #undef  ENDFILE_SPEC
937 #define ENDFILE_SPEC "\
938 %{mads         : crtsavres.o%s        %(endfile_ads)         ; \
939   myellowknife : crtsavres.o%s        %(endfile_yellowknife) ; \
940   mmvme        : crtsavres.o%s        %(endfile_mvme)        ; \
941   msim         : crtsavres.o%s        %(endfile_sim)         ; \
942   mwindiss     :                      %(endfile_windiss)     ; \
943   mcall-freebsd: crtsavres.o%s        %(endfile_freebsd)     ; \
944   mcall-linux  : crtsavres.o%s        %(endfile_linux)       ; \
945   mcall-gnu    : crtsavres.o%s        %(endfile_gnu)         ; \
946   mcall-netbsd : crtsavres.o%s        %(endfile_netbsd)      ; \
947   mcall-openbsd: crtsavres.o%s        %(endfile_openbsd)     ; \
948                : %(crtsavres_default) %(endfile_default)     }"
949
950 #define CRTSAVRES_DEFAULT_SPEC "crtsavres.o%s"
951
952 #define ENDFILE_DEFAULT_SPEC ""
953
954 /* Motorola ADS support.  */
955 #define LIB_ADS_SPEC "--start-group -lads -lc --end-group"
956
957 #define STARTFILE_ADS_SPEC "ecrti.o%s crt0.o%s crtbegin.o%s"
958
959 #define ENDFILE_ADS_SPEC "crtend.o%s ecrtn.o%s"
960
961 #define LINK_START_ADS_SPEC "-T ads.ld%s"
962
963 #define LINK_OS_ADS_SPEC ""
964
965 #define CPP_OS_ADS_SPEC ""
966
967 /* Motorola Yellowknife support.  */
968 #define LIB_YELLOWKNIFE_SPEC "--start-group -lyk -lc --end-group"
969
970 #define STARTFILE_YELLOWKNIFE_SPEC "ecrti.o%s crt0.o%s crtbegin.o%s"
971
972 #define ENDFILE_YELLOWKNIFE_SPEC "crtend.o%s ecrtn.o%s"
973
974 #define LINK_START_YELLOWKNIFE_SPEC "-T yellowknife.ld%s"
975
976 #define LINK_OS_YELLOWKNIFE_SPEC ""
977
978 #define CPP_OS_YELLOWKNIFE_SPEC ""
979
980 /* Motorola MVME support.  */
981 #define LIB_MVME_SPEC "--start-group -lmvme -lc --end-group"
982
983 #define STARTFILE_MVME_SPEC "ecrti.o%s crt0.o%s crtbegin.o%s"
984
985 #define ENDFILE_MVME_SPEC "crtend.o%s ecrtn.o%s"
986
987 #define LINK_START_MVME_SPEC "-Ttext 0x40000"
988
989 #define LINK_OS_MVME_SPEC ""
990
991 #define CPP_OS_MVME_SPEC ""
992
993 /* PowerPC simulator based on netbsd system calls support.  */
994 #define LIB_SIM_SPEC "--start-group -lsim -lc --end-group"
995
996 #define STARTFILE_SIM_SPEC "ecrti.o%s sim-crt0.o%s crtbegin.o%s"
997
998 #define ENDFILE_SIM_SPEC "crtend.o%s ecrtn.o%s"
999
1000 #define LINK_START_SIM_SPEC ""
1001
1002 #define LINK_OS_SIM_SPEC "-m elf32ppcsim"
1003
1004 #define CPP_OS_SIM_SPEC ""
1005
1006 /* FreeBSD support.  */
1007
1008 #define CPP_OS_FREEBSD_SPEC     "\
1009   -D__PPC__ -D__ppc__ -D__PowerPC__ -D__powerpc__ \
1010   -Acpu=powerpc -Amachine=powerpc"
1011
1012 #define STARTFILE_FREEBSD_SPEC  FBSD_STARTFILE_SPEC
1013 #define ENDFILE_FREEBSD_SPEC    FBSD_ENDFILE_SPEC
1014 #define LIB_FREEBSD_SPEC        FBSD_LIB_SPEC
1015 #define LINK_START_FREEBSD_SPEC ""
1016
1017 #define LINK_OS_FREEBSD_SPEC "\
1018   %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \
1019   %{Wl,*:%*} \
1020   %{v:-V} \
1021   %{assert*} %{R*} %{rpath*} %{defsym*} \
1022   %{shared:-Bshareable %{h*} %{soname*}} \
1023   %{!shared: \
1024     %{!static: \
1025       %{rdynamic: -export-dynamic} \
1026       %{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} \
1027     %{static:-Bstatic}} \
1028   %{symbolic:-Bsymbolic}"
1029
1030 /* GNU/Linux support.  */
1031 #define LIB_LINUX_SPEC "%{mnewlib: --start-group -llinux -lc --end-group } \
1032 %{!mnewlib: %{pthread:-lpthread} %{shared:-lc} \
1033 %{!shared: %{profile:-lc_p} %{!profile:-lc}}}"
1034
1035 #ifdef HAVE_LD_PIE
1036 #define STARTFILE_LINUX_SPEC "\
1037 %{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
1038 %{mnewlib:ecrti.o%s;:crti.o%s} \
1039 %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
1040 #else
1041 #define STARTFILE_LINUX_SPEC "\
1042 %{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
1043 %{mnewlib:ecrti.o%s;:crti.o%s} \
1044 %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
1045 #endif
1046
1047 #define ENDFILE_LINUX_SPEC "\
1048 %{shared|pie:crtendS.o%s;:crtend.o%s} \
1049 %{mnewlib:ecrtn.o%s;:crtn.o%s}"
1050
1051 #define LINK_START_LINUX_SPEC ""
1052
1053 #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
1054   %{rdynamic:-export-dynamic} \
1055   %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
1056
1057 #if defined(HAVE_LD_EH_FRAME_HDR)
1058 # define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
1059 #endif
1060
1061 #define CPP_OS_LINUX_SPEC "-D__unix__ -D__gnu_linux__ -D__linux__ \
1062 %{!undef:                                                         \
1063   %{!ansi:                                                        \
1064     %{!std=*:-Dunix -D__unix -Dlinux -D__linux}                   \
1065     %{std=gnu*:-Dunix -D__unix -Dlinux -D__linux}}}               \
1066 -Asystem=linux -Asystem=unix -Asystem=posix %{pthread:-D_REENTRANT}"
1067
1068 /* GNU/Hurd support.  */
1069 #define LIB_GNU_SPEC "%{mnewlib: --start-group -lgnu -lc --end-group } \
1070 %{!mnewlib: %{shared:-lc} %{!shared: %{pthread:-lpthread } \
1071 %{profile:-lc_p} %{!profile:-lc}}}"
1072
1073 #define STARTFILE_GNU_SPEC "\
1074 %{!shared: %{!static: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}} \
1075 %{static: %{pg:gcrt0.o%s} %{!pg:%{p:gcrt0.o%s} %{!p:crt0.o%s}}} \
1076 %{mnewlib: ecrti.o%s} %{!mnewlib: crti.o%s} \
1077 %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
1078
1079 #define ENDFILE_GNU_SPEC "%{!shared:crtend.o%s} %{shared:crtendS.o%s} \
1080 %{mnewlib: ecrtn.o%s} %{!mnewlib: crtn.o%s}"
1081
1082 #define LINK_START_GNU_SPEC ""
1083
1084 #define LINK_OS_GNU_SPEC "-m elf32ppclinux %{!shared: %{!static: \
1085   %{rdynamic:-export-dynamic} \
1086   %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
1087
1088 #define CPP_OS_GNU_SPEC "-D__unix__ -D__gnu_hurd__ -D__GNU__    \
1089 %{!undef:                                                       \
1090   %{!ansi: -Dunix -D__unix}}                                    \
1091 -Asystem=gnu -Asystem=unix -Asystem=posix %{pthread:-D_REENTRANT}"
1092
1093 /* NetBSD support.  */
1094 #define LIB_NETBSD_SPEC "\
1095 %{profile:-lgmon -lc_p} %{!profile:-lc}"
1096
1097 #define STARTFILE_NETBSD_SPEC "\
1098 ncrti.o%s crt0.o%s \
1099 %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
1100
1101 #define ENDFILE_NETBSD_SPEC "\
1102 %{!shared:crtend.o%s} %{shared:crtendS.o%s} \
1103 ncrtn.o%s"
1104
1105 #define LINK_START_NETBSD_SPEC "\
1106 "
1107
1108 #define LINK_OS_NETBSD_SPEC "\
1109 %{!shared: %{!static: \
1110   %{rdynamic:-export-dynamic} \
1111   %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}}}"
1112
1113 #define CPP_OS_NETBSD_SPEC "\
1114 -D__powerpc__ -D__NetBSD__ -D__KPRINTF_ATTRIBUTE__"
1115
1116 /* OpenBSD support.  */
1117 #ifndef LIB_OPENBSD_SPEC
1118 #define LIB_OPENBSD_SPEC "%{!shared:%{pthread:-lpthread%{p:_p}%{!p:%{pg:_p}}}} %{!shared:-lc%{p:_p}%{!p:%{pg:_p}}}"
1119 #endif
1120
1121 #ifndef STARTFILE_OPENBSD_SPEC
1122 #define STARTFILE_OPENBSD_SPEC "\
1123 %{!shared: %{pg:gcrt0.o%s} %{!pg:%{p:gcrt0.o%s} %{!p:crt0.o%s}}} \
1124 %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
1125 #endif
1126
1127 #ifndef ENDFILE_OPENBSD_SPEC
1128 #define ENDFILE_OPENBSD_SPEC "\
1129 %{!shared:crtend.o%s} %{shared:crtendS.o%s}"
1130 #endif
1131
1132 #ifndef LINK_START_OPENBSD_SPEC
1133 #define LINK_START_OPENBSD_SPEC "-Ttext 0x400074"
1134 #endif
1135
1136 #ifndef LINK_OS_OPENBSD_SPEC
1137 #define LINK_OS_OPENBSD_SPEC ""
1138 #endif
1139
1140 #ifndef CPP_OS_OPENBSD_SPEC
1141 #define CPP_OS_OPENBSD_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
1142 #endif
1143
1144 /* WindISS support.  */
1145
1146 #define LIB_WINDISS_SPEC "--start-group -li -lcfp -lwindiss -lram -limpl -limpfp --end-group"
1147
1148 #define CPP_OS_WINDISS_SPEC "\
1149 -D__rtasim \
1150 -D__EABI__ \
1151 -D__ppc \
1152 %{!msoft-float: -D__hardfp} \
1153 "
1154
1155 #define STARTFILE_WINDISS_SPEC "crt0.o%s crtbegin.o%s"
1156
1157 #define ENDFILE_WINDISS_SPEC "crtend.o%s"
1158
1159 #define LINK_START_WINDISS_SPEC ""
1160
1161 #define LINK_OS_WINDISS_SPEC ""
1162
1163 /* Define any extra SPECS that the compiler needs to generate.  */
1164 /* Override rs6000.h definition.  */
1165 #undef  SUBTARGET_EXTRA_SPECS
1166 #define SUBTARGET_EXTRA_SPECS                                           \
1167   { "crtsavres_default",        CRTSAVRES_DEFAULT_SPEC },               \
1168   { "lib_ads",                  LIB_ADS_SPEC },                         \
1169   { "lib_yellowknife",          LIB_YELLOWKNIFE_SPEC },                 \
1170   { "lib_mvme",                 LIB_MVME_SPEC },                        \
1171   { "lib_sim",                  LIB_SIM_SPEC },                         \
1172   { "lib_freebsd",              LIB_FREEBSD_SPEC },                     \
1173   { "lib_gnu",                  LIB_GNU_SPEC },                         \
1174   { "lib_linux",                LIB_LINUX_SPEC },                       \
1175   { "lib_netbsd",               LIB_NETBSD_SPEC },                      \
1176   { "lib_openbsd",              LIB_OPENBSD_SPEC },                     \
1177   { "lib_windiss",              LIB_WINDISS_SPEC },                     \
1178   { "lib_default",              LIB_DEFAULT_SPEC },                     \
1179   { "startfile_ads",            STARTFILE_ADS_SPEC },                   \
1180   { "startfile_yellowknife",    STARTFILE_YELLOWKNIFE_SPEC },           \
1181   { "startfile_mvme",           STARTFILE_MVME_SPEC },                  \
1182   { "startfile_sim",            STARTFILE_SIM_SPEC },                   \
1183   { "startfile_freebsd",        STARTFILE_FREEBSD_SPEC },               \
1184   { "startfile_gnu",            STARTFILE_GNU_SPEC },                   \
1185   { "startfile_linux",          STARTFILE_LINUX_SPEC },                 \
1186   { "startfile_netbsd",         STARTFILE_NETBSD_SPEC },                \
1187   { "startfile_openbsd",        STARTFILE_OPENBSD_SPEC },               \
1188   { "startfile_windiss",        STARTFILE_WINDISS_SPEC },               \
1189   { "startfile_default",        STARTFILE_DEFAULT_SPEC },               \
1190   { "endfile_ads",              ENDFILE_ADS_SPEC },                     \
1191   { "endfile_yellowknife",      ENDFILE_YELLOWKNIFE_SPEC },             \
1192   { "endfile_mvme",             ENDFILE_MVME_SPEC },                    \
1193   { "endfile_sim",              ENDFILE_SIM_SPEC },                     \
1194   { "endfile_freebsd",          ENDFILE_FREEBSD_SPEC },                 \
1195   { "endfile_gnu",              ENDFILE_GNU_SPEC },                     \
1196   { "endfile_linux",            ENDFILE_LINUX_SPEC },                   \
1197   { "endfile_netbsd",           ENDFILE_NETBSD_SPEC },                  \
1198   { "endfile_openbsd",          ENDFILE_OPENBSD_SPEC },                 \
1199   { "endfile_windiss",          ENDFILE_WINDISS_SPEC },                 \
1200   { "endfile_default",          ENDFILE_DEFAULT_SPEC },                 \
1201   { "link_path",                LINK_PATH_SPEC },                       \
1202   { "link_shlib",               LINK_SHLIB_SPEC },                      \
1203   { "link_target",              LINK_TARGET_SPEC },                     \
1204   { "link_start",               LINK_START_SPEC },                      \
1205   { "link_start_ads",           LINK_START_ADS_SPEC },                  \
1206   { "link_start_yellowknife",   LINK_START_YELLOWKNIFE_SPEC },          \
1207   { "link_start_mvme",          LINK_START_MVME_SPEC },                 \
1208   { "link_start_sim",           LINK_START_SIM_SPEC },                  \
1209   { "link_start_freebsd",       LINK_START_FREEBSD_SPEC },              \
1210   { "link_start_gnu",           LINK_START_GNU_SPEC },                  \
1211   { "link_start_linux",         LINK_START_LINUX_SPEC },                \
1212   { "link_start_netbsd",        LINK_START_NETBSD_SPEC },               \
1213   { "link_start_openbsd",       LINK_START_OPENBSD_SPEC },              \
1214   { "link_start_windiss",       LINK_START_WINDISS_SPEC },              \
1215   { "link_start_default",       LINK_START_DEFAULT_SPEC },              \
1216   { "link_os",                  LINK_OS_SPEC },                         \
1217   { "link_os_ads",              LINK_OS_ADS_SPEC },                     \
1218   { "link_os_yellowknife",      LINK_OS_YELLOWKNIFE_SPEC },             \
1219   { "link_os_mvme",             LINK_OS_MVME_SPEC },                    \
1220   { "link_os_sim",              LINK_OS_SIM_SPEC },                     \
1221   { "link_os_freebsd",          LINK_OS_FREEBSD_SPEC },                 \
1222   { "link_os_linux",            LINK_OS_LINUX_SPEC },                   \
1223   { "link_os_gnu",              LINK_OS_GNU_SPEC },                     \
1224   { "link_os_netbsd",           LINK_OS_NETBSD_SPEC },                  \
1225   { "link_os_openbsd",          LINK_OS_OPENBSD_SPEC },                 \
1226   { "link_os_windiss",          LINK_OS_WINDISS_SPEC },                 \
1227   { "link_os_default",          LINK_OS_DEFAULT_SPEC },                 \
1228   { "cc1_endian_big",           CC1_ENDIAN_BIG_SPEC },                  \
1229   { "cc1_endian_little",        CC1_ENDIAN_LITTLE_SPEC },               \
1230   { "cc1_endian_default",       CC1_ENDIAN_DEFAULT_SPEC },              \
1231   { "cc1_secure_plt_default",   CC1_SECURE_PLT_DEFAULT_SPEC },          \
1232   { "cpp_os_ads",               CPP_OS_ADS_SPEC },                      \
1233   { "cpp_os_yellowknife",       CPP_OS_YELLOWKNIFE_SPEC },              \
1234   { "cpp_os_mvme",              CPP_OS_MVME_SPEC },                     \
1235   { "cpp_os_sim",               CPP_OS_SIM_SPEC },                      \
1236   { "cpp_os_freebsd",           CPP_OS_FREEBSD_SPEC },                  \
1237   { "cpp_os_gnu",               CPP_OS_GNU_SPEC },                      \
1238   { "cpp_os_linux",             CPP_OS_LINUX_SPEC },                    \
1239   { "cpp_os_netbsd",            CPP_OS_NETBSD_SPEC },                   \
1240   { "cpp_os_openbsd",           CPP_OS_OPENBSD_SPEC },                  \
1241   { "cpp_os_windiss",           CPP_OS_WINDISS_SPEC },                  \
1242   { "cpp_os_default",           CPP_OS_DEFAULT_SPEC },                  \
1243   { "fbsd_dynamic_linker",      FBSD_DYNAMIC_LINKER },                  \
1244   SUBSUBTARGET_EXTRA_SPECS
1245
1246 #define SUBSUBTARGET_EXTRA_SPECS
1247
1248 /* Define this macro as a C expression for the initializer of an
1249    array of string to tell the driver program which options are
1250    defaults for this target and thus do not need to be handled
1251    specially when using `MULTILIB_OPTIONS'.
1252
1253    Do not define this macro if `MULTILIB_OPTIONS' is not defined in
1254    the target makefile fragment or if none of the options listed in
1255    `MULTILIB_OPTIONS' are set by default.  *Note Target Fragment::.  */
1256
1257 #define MULTILIB_DEFAULTS { "mbig", "mcall-sysv" }
1258
1259 /* Define this macro if the code for function profiling should come
1260    before the function prologue.  Normally, the profiling code comes
1261    after.  */
1262 #define PROFILE_BEFORE_PROLOGUE 1
1263
1264 /* Function name to call to do profiling.  */
1265 #define RS6000_MCOUNT "_mcount"
1266
1267 /* Define this macro (to a value of 1) if you want to support the
1268    Win32 style pragmas #pragma pack(push,<n>)' and #pragma
1269    pack(pop)'.  The pack(push,<n>) pragma specifies the maximum
1270    alignment (in bytes) of fields within a structure, in much the
1271    same way as the __aligned__' and __packed__' __attribute__'s
1272    do.  A pack value of zero resets the behavior to the default.
1273    Successive invocations of this pragma cause the previous values to
1274    be stacked, so that invocations of #pragma pack(pop)' will return
1275    to the previous value.  */
1276
1277 #define HANDLE_PRAGMA_PACK_PUSH_POP 1
1278
1279 /* Select a format to encode pointers in exception handling data.  CODE
1280    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
1281    true if the symbol may be affected by dynamic relocations.  */
1282 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)                            \
1283   ((flag_pic || TARGET_RELOCATABLE)                                          \
1284    ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4) \
1285    : DW_EH_PE_absptr)
1286
1287 #define TARGET_ASM_EXCEPTION_SECTION readonly_data_section
1288
1289 #define DOUBLE_INT_ASM_OP "\t.quad\t"
1290
1291 /* Generate entries in .fixup for relocatable addresses.  */
1292 #define RELOCATABLE_NEEDS_FIXUP 1
1293
1294 /* This target uses the sysv4.opt file.  */
1295 #define TARGET_USES_SYSV4_OPT 1