OSDN Git Service

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