OSDN Git Service

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