OSDN Git Service

Fix -msdata init code; Make sure correct endian flag is defined
[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 Free Software Foundation, Inc.
3    Contributed by Cygnus Support.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 /* Small data support types */
23 enum rs6000_sdata_type {
24   SDATA_NONE,                   /* no small data support */
25   SDATA_DATA,                   /* just put data in .sbss/.sdata, don't use relocs */
26   SDATA_SYSV,                   /* Use r13 to point to .sdata/.sbss */
27   SDATA_EABI                    /* Use r13 like above, r2 points to .sdata2/.sbss2 */
28 };
29
30 extern enum rs6000_sdata_type rs6000_sdata;
31
32 /* V.4/eabi switches */
33 #define MASK_NO_BITFIELD_TYPE   0x40000000      /* Set PCC_BITFIELD_TYPE_MATTERS to 0 */
34 #define MASK_STRICT_ALIGN       0x20000000      /* Set STRICT_ALIGNMENT to 1.  */
35 #define MASK_RELOCATABLE        0x10000000      /* GOT pointers are PC relative */
36 #define MASK_SDATA              0x08000000      /* use small data areas */
37 #define MASK_LITTLE_ENDIAN      0x04000000      /* target is little endian */
38 #define MASK_REGNAMES           0x02000000      /* use alternate register names.  */
39 #define MASK_PROTOTYPE          0x01000000      /* Only prototyped fcns pass variable args */
40 #define MASK_EABI               0x00800000      /* Adhere to eabi, not System V spec */
41
42 #define TARGET_NO_BITFIELD_TYPE (target_flags & MASK_NO_BITFIELD_TYPE)
43 #define TARGET_STRICT_ALIGN     (target_flags & MASK_STRICT_ALIGN)
44 #define TARGET_RELOCATABLE      (target_flags & MASK_RELOCATABLE)
45 #define TARGET_SDATA            (target_flags & MASK_SDATA)
46 #define TARGET_LITTLE_ENDIAN    (target_flags & MASK_LITTLE_ENDIAN)
47 #define TARGET_REGNAMES         (target_flags & MASK_REGNAMES)
48 #define TARGET_PROTOTYPE        (target_flags & MASK_PROTOTYPE)
49 #define TARGET_EABI             (target_flags & MASK_EABI)
50 #define TARGET_TOC              ((target_flags & (MASK_64BIT            \
51                                                  | MASK_RELOCATABLE     \
52                                                  | MASK_MINIMAL_TOC))   \
53                                  || DEFAULT_ABI == ABI_AIX              \
54                                  || DEFAULT_ABI == ABI_NT)
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 /* Pseudo target to indicate whether the object format is ELF
63    (to get around not having conditional compilation in the md file)  */
64 #define TARGET_ELF              1
65
66 /* Note, V.4 no longer uses a normal TOC, so make -mfull-toc, be just
67    the same as -mminimal-toc.  */
68 #undef  SUBTARGET_SWITCHES
69 #define SUBTARGET_SWITCHES                                              \
70   { "bit-align",        -MASK_NO_BITFIELD_TYPE },                       \
71   { "no-bit-align",      MASK_NO_BITFIELD_TYPE },                       \
72   { "strict-align",      MASK_STRICT_ALIGN },                           \
73   { "no-strict-align",  -MASK_STRICT_ALIGN },                           \
74   { "relocatable",       MASK_RELOCATABLE | MASK_MINIMAL_TOC | MASK_NO_FP_IN_TOC }, \
75   { "relocatable",      -MASK_SDATA },                                  \
76   { "no-relocatable",   -MASK_RELOCATABLE },                            \
77   { "relocatable-lib",   MASK_RELOCATABLE | MASK_MINIMAL_TOC | MASK_NO_FP_IN_TOC }, \
78   { "relocatable-lib",  -MASK_SDATA },                                  \
79   { "no-relocatable-lib", -MASK_RELOCATABLE },                          \
80   { "sdata",             MASK_SDATA },                                  \
81   { "no-sdata",         -MASK_SDATA },                                  \
82   { "little-endian",     MASK_LITTLE_ENDIAN },                          \
83   { "little",            MASK_LITTLE_ENDIAN },                          \
84   { "big-endian",       -MASK_LITTLE_ENDIAN },                          \
85   { "big",              -MASK_LITTLE_ENDIAN },                          \
86   { "no-toc",            0 },                                           \
87   { "toc",               MASK_MINIMAL_TOC },                            \
88   { "full-toc",          MASK_MINIMAL_TOC },                            \
89   { "prototype",         MASK_PROTOTYPE },                              \
90   { "no-prototype",     -MASK_PROTOTYPE },                              \
91   { "no-traceback",      0 },                                           \
92   { "eabi",              MASK_EABI },                                   \
93   { "no-eabi",          -MASK_EABI },                                   \
94   { "regnames",           MASK_REGNAMES },                              \
95   { "no-regnames",       -MASK_REGNAMES },                              \
96   { "sim",               0 },                                           \
97   { "mvme",              0 },                                           \
98   { "emb",               0 },                                           \
99   { "solaris-cclib",     0 },                                           \
100   { "shlib",             0 },                                           \
101   { "newlib",            0 },
102
103 /* Default ABI to use */
104 #define RS6000_ABI_NAME "sysv"
105
106 /* Strings provided by SUBTARGET_OPTIONS */
107 extern char *rs6000_abi_name;
108 extern char *rs6000_sdata_name;
109
110 #define SUBTARGET_OPTIONS                                               \
111   { "call-",  &rs6000_abi_name},                                        \
112   { "sdata=", &rs6000_sdata_name}
113
114 /* Max # of bytes for variables to automatically be put into the .sdata
115    or .sdata2 sections.  */
116 extern int g_switch_value;              /* value of the -G xx switch */
117 extern int g_switch_set;                /* whether -G xx was passed.  */
118
119 #ifndef SDATA_DEFAULT_SIZE
120 #define SDATA_DEFAULT_SIZE 8
121 #endif
122
123 /* Sometimes certain combinations of command options do not make sense
124    on a particular target machine.  You can define a macro
125    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
126    defined, is executed once just after all the command options have
127    been parsed.
128
129    The macro SUBTARGET_OVERRIDE_OPTIONS is provided for subtargets, to
130    get control.  */
131
132 #define SUBTARGET_OVERRIDE_OPTIONS                                      \
133 do {                                                                    \
134   if (!g_switch_set)                                                    \
135     g_switch_value = SDATA_DEFAULT_SIZE;                                \
136                                                                         \
137   if (!strcmp (rs6000_abi_name, "sysv"))                                \
138     rs6000_current_abi = ABI_V4;                                        \
139   else if (!strcmp (rs6000_abi_name, "sysv-noeabi"))                    \
140     {                                                                   \
141       rs6000_current_abi = ABI_V4;                                      \
142       target_flags &= ~ MASK_EABI;                                      \
143     }                                                                   \
144   else if (!strcmp (rs6000_abi_name, "sysv-eabi")                       \
145            || !strcmp (rs6000_abi_name, "eabi"))                        \
146     {                                                                   \
147       rs6000_current_abi = ABI_V4;                                      \
148       target_flags |= MASK_EABI;                                        \
149     }                                                                   \
150   else if (!strcmp (rs6000_abi_name, "aix"))                            \
151     {                                                                   \
152       rs6000_current_abi = ABI_AIX_NODESC;                              \
153       target_flags |= MASK_EABI;                                        \
154     }                                                                   \
155   else if (!strcmp (rs6000_abi_name, "aixdesc"))                        \
156     rs6000_current_abi = ABI_AIX;                                       \
157   else if (!strcmp (rs6000_abi_name, "nt"))                             \
158     rs6000_current_abi = ABI_NT;                                        \
159   else if (!strcmp (rs6000_abi_name, "linux"))                          \
160     rs6000_current_abi = ABI_V4;                                        \
161   else if (!strcmp (rs6000_abi_name, "solaris"))                        \
162     rs6000_current_abi = ABI_SOLARIS;                                   \
163   else                                                                  \
164     {                                                                   \
165       rs6000_current_abi = ABI_V4;                                      \
166       error ("Bad value for -mcall-%s", rs6000_abi_name);               \
167     }                                                                   \
168                                                                         \
169   if (rs6000_sdata_name)                                                \
170     {                                                                   \
171       target_flags |= MASK_SDATA;                                       \
172       if (!strcmp (rs6000_sdata_name, "none"))                          \
173         {                                                               \
174           rs6000_sdata = SDATA_NONE;                                    \
175           target_flags &= ~MASK_SDATA;                                  \
176         }                                                               \
177       else if (!strcmp (rs6000_sdata_name, "data"))                     \
178         rs6000_sdata = SDATA_DATA;                                      \
179       else if (!strcmp (rs6000_sdata_name, "default"))                  \
180         rs6000_sdata = (TARGET_EABI) ? SDATA_EABI : SDATA_SYSV;         \
181       else if (!strcmp (rs6000_sdata_name, "sysv"))                     \
182         rs6000_sdata = SDATA_SYSV;                                      \
183       else if (!strcmp (rs6000_sdata_name, "eabi"))                     \
184         rs6000_sdata = SDATA_EABI;                                      \
185       else                                                              \
186         error ("Bad value for -msdata=%s", rs6000_sdata_name);          \
187     }                                                                   \
188   else if (TARGET_SDATA)                                                \
189     rs6000_sdata = (TARGET_EABI) ? SDATA_EABI : SDATA_SYSV;             \
190   else if (!TARGET_RELOCATABLE && !flag_pic && DEFAULT_ABI == ABI_V4)   \
191     {                                                                   \
192       rs6000_sdata = SDATA_DATA;                                        \
193       target_flags |= MASK_SDATA;                                       \
194     }                                                                   \
195   else                                                                  \
196     rs6000_sdata = SDATA_NONE;                                          \
197                                                                         \
198   if (TARGET_RELOCATABLE &&                                             \
199       (rs6000_sdata == SDATA_EABI || rs6000_sdata == SDATA_SYSV))       \
200     {                                                                   \
201       target_flags &= ~MASK_SDATA;                                      \
202       rs6000_sdata = SDATA_NONE;                                        \
203       error ("-mrelocatable and -msdata are incompatible.");            \
204     }                                                                   \
205                                                                         \
206   if (TARGET_RELOCATABLE && !TARGET_EABI)                               \
207     {                                                                   \
208       target_flags |= ~MASK_EABI;                                       \
209       error ("-mrelocatable and -mno-eabi are incompatible.");          \
210     }                                                                   \
211                                                                         \
212   if (TARGET_SDATA && DEFAULT_ABI != ABI_V4                             \
213       && DEFAULT_ABI != ABI_SOLARIS)                                    \
214     {                                                                   \
215       target_flags &= ~MASK_SDATA;                                      \
216       error ("-msdata and -mcall-aix are incompatible.");               \
217     }                                                                   \
218                                                                         \
219   if (TARGET_RELOCATABLE && !TARGET_MINIMAL_TOC)                        \
220     {                                                                   \
221       target_flags |= MASK_MINIMAL_TOC;                                 \
222       error ("-mrelocatable and -mno-minimal-toc are incompatible.");   \
223     }                                                                   \
224                                                                         \
225   if (TARGET_RELOCATABLE &&                                             \
226       (rs6000_current_abi == ABI_AIX || rs6000_current_abi == ABI_NT))  \
227     {                                                                   \
228       target_flags &= ~MASK_RELOCATABLE;                                \
229       error ("-mrelocatable and -mcall-%s are incompatible.",           \
230              rs6000_abi_name);                                          \
231     }                                                                   \
232                                                                         \
233   if (rs6000_current_abi == ABI_AIX && TARGET_LITTLE_ENDIAN)            \
234     {                                                                   \
235       target_flags &= ~MASK_LITTLE_ENDIAN;                              \
236       error ("-mcall-aixdesc must be big endian");                      \
237     }                                                                   \
238                                                                         \
239   if (rs6000_current_abi == ABI_NT && TARGET_BIG_ENDIAN)                \
240     {                                                                   \
241       target_flags |= MASK_LITTLE_ENDIAN;                               \
242       error ("-mcall-nt must be little endian");                        \
243     }                                                                   \
244 } while (0)
245
246 /* Default ABI to compile code for */
247 #define DEFAULT_ABI rs6000_current_abi
248
249 #include "rs6000/powerpc.h"
250
251 /* System V.4 uses register 13 as a pointer to the small data area,
252    so it is not available to the normal user.  */
253
254 #undef  FIXED_R13
255 #define FIXED_R13 1
256
257 /* System V.4 passes the first 8 floating arguments in registers,
258    instead of the first 13 like AIX does.  */
259 #undef  FP_ARG_MAX_REG
260 #define FP_ARG_MAX_REG ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_AIX_NODESC) \
261                         ? FP_ARG_AIX_MAX_REG : FP_ARG_V4_MAX_REG)
262
263 /* Size of the V.4 varargs area if needed */
264 #undef  RS6000_VARARGS_AREA
265 #define RS6000_VARARGS_AREA ((rs6000_sysv_varargs_p) ? RS6000_VARARGS_SIZE : 0)
266
267 /* Override default big endianism */
268 #undef  BYTES_BIG_ENDIAN
269 #undef  WORDS_BIG_ENDIAN
270 #define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN)
271 #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN)
272
273 /* Define this to set the endianness to use in libgcc2.c, which can
274    not depend on target_flags.  */
275 #if !defined(_LITTLE_ENDIAN) && !defined(__sun__)
276 #define LIBGCC2_WORDS_BIG_ENDIAN 1
277 #else
278 #define LIBGCC2_WORDS_BIG_ENDIAN 0
279 #endif
280
281 /* Size of the outgoing register save area */
282 #undef  RS6000_REG_SAVE
283 #define RS6000_REG_SAVE ((DEFAULT_ABI == ABI_AIX                        \
284                           || DEFAULT_ABI == ABI_AIX_NODESC)             \
285                          ? (TARGET_64BIT ? 64 : 32)                     \
286                          : 0)
287
288 /* Size of the fixed area on the stack.  For AIX, use the standard 6 word
289    area, otherwise use 2 words to store back chain & LR.  */
290 #undef  RS6000_SAVE_AREA
291 #define RS6000_SAVE_AREA \
292   (((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_AIX_NODESC) ? 24 : 8) << (TARGET_64BIT ? 1 : 0))
293
294 /* Define cutoff for using external functions to save floating point.
295    Currently on V.4, always use inline stores */
296 #undef  FP_SAVE_INLINE
297 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 64)
298
299 /* Don't generate XCOFF debugging information.  */
300
301 #undef XCOFF_DEBUGGING_INFO
302
303 /* Don't use the COFF object file format.  */
304
305 #undef OBJECT_FORMAT_COFF
306
307 /* Don't bother to output .extern pseudo-ops.  They are not needed by
308    ELF assemblers.  */
309
310 #undef ASM_OUTPUT_EXTERNAL
311
312 /* Undefine some things which are defined by the generic svr4.h.  */
313
314 #undef ASM_FILE_END
315 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
316 #undef READONLY_DATA_SECTION
317 #undef SELECT_SECTION
318 #undef ASM_DECLARE_FUNCTION_NAME
319 #undef ASM_OUTPUT_CONSTRUCTOR
320 #undef ASM_OUTPUT_DESTRUCTOR
321
322 /* Use the regular svr4 definitions.  */
323
324 #include "svr4.h"
325
326 /* Prefix and suffix to use to saving floating point */
327 #undef  SAVE_FP_PREFIX
328 #undef  SAVE_FP_SUFFIX
329 #define SAVE_FP_PREFIX "_savefpr_"
330 #define SAVE_FP_SUFFIX "_l"
331
332 /* Prefix and suffix to use to restoring floating point */
333 #undef  RESTORE_FP_PREFIX
334 #undef  RESTORE_FP_SUFFIX
335 #define RESTORE_FP_PREFIX "_restfpr_"
336 #define RESTORE_FP_SUFFIX "_l"
337
338 /* Type used for ptrdiff_t, as a string used in a declaration.  */
339 #undef  PTRDIFF_TYPE
340 #define PTRDIFF_TYPE "int"
341
342 /* Type used for wchar_t, as a string used in a declaration.  */
343 #undef  WCHAR_TYPE
344 #define WCHAR_TYPE "short unsigned int"
345
346 /* Width of wchar_t in bits.  */
347 #undef  WCHAR_TYPE_SIZE
348 #define WCHAR_TYPE_SIZE 16
349
350 /* Make int foo : 8 not cause structures to be aligned to an int boundary */
351
352 #undef  PCC_BITFIELD_TYPE_MATTERS
353 #define PCC_BITFIELD_TYPE_MATTERS (TARGET_BITFIELD_TYPE)
354
355 /* Define this macro to be the value 1 if instructions will fail to
356    work if given data not on the nominal alignment.  If instructions
357    will merely go slower in that case, define this macro as 0.
358
359    Note, little endian systems trap on unaligned addresses, so never
360    turn off strict alignment in that case. */
361 #undef  STRICT_ALIGNMENT
362 #define STRICT_ALIGNMENT (TARGET_STRICT_ALIGN || TARGET_LITTLE_ENDIAN)
363
364 /* Align stack to 8 byte boundaries for eabi, 16 byte boundaries for System V.4  */
365 #undef  STACK_BOUNDARY
366 #define STACK_BOUNDARY  ((TARGET_EABI) ? 64 : 128)
367
368 /* No data type wants to be aligned rounder than this.  */
369 #undef  BIGGEST_ALIGNMENT
370 #define BIGGEST_ALIGNMENT ((TARGET_EABI) ? 64 : 128)
371
372 #undef  BIGGEST_FIELD_ALIGNMENT
373 #undef  ADJUST_FIELD_ALIGN
374 #undef  ROUND_TYPE_ALIGN
375
376 /* Use ELF style section commands.  */
377
378 #undef TEXT_SECTION_ASM_OP
379 #define TEXT_SECTION_ASM_OP     "\t.section \".text\""
380
381 #undef DATA_SECTION_ASM_OP
382 #define DATA_SECTION_ASM_OP     "\t.section \".data\""
383
384 #undef BSS_SECTION_ASM_OP
385 #define BSS_SECTION_ASM_OP      "\t.section \".bss\""
386
387 #undef INIT_SECTION_ASM_OP
388 #define INIT_SECTION_ASM_OP "\t.section \".init\",\"ax\""
389
390 #undef FINI_SECTION_ASM_OP
391 #define FINI_SECTION_ASM_OP "\t.section \".fini\",\"ax\""
392
393 #define TOC_SECTION_ASM_OP "\t.section \".got\",\"aw\""
394
395 /* Put PC relative got entries in .got2 */
396 #define MINIMAL_TOC_SECTION_ASM_OP \
397   ((TARGET_RELOCATABLE) ? "\t.section\t\".got2\",\"aw\"" : "\t.section\t\".got1\",\"aw\"")
398
399 /* Put relocatable data in .data, not .rodata so initialized pointers can be updated */
400 #undef  CONST_SECTION_ASM_OP
401 #define CONST_SECTION_ASM_OP \
402   ((TARGET_RELOCATABLE) ? "\t.section\t\".data\"\t# .rodata" : "\t.section\t\".rodata\"")
403
404
405 #define SDATA_SECTION_ASM_OP "\t.section \".sdata\",\"aw\""
406 #define SDATA2_SECTION_ASM_OP "\t.section \".sdata2\",\"a\""
407 #define SBSS_SECTION_ASM_OP \
408   ((DEFAULT_ABI == ABI_SOLARIS) ? "\t.section \".sbss\",\"aw\"" : "\t.section \".sbss\",\"aw\",@nobits")
409
410
411 /* Besides the usual ELF sections, we need a toc section.  */
412 #undef EXTRA_SECTIONS
413 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_toc, in_sdata, in_sdata2, in_sbss, in_init, in_fini
414
415 #undef EXTRA_SECTION_FUNCTIONS
416 #define EXTRA_SECTION_FUNCTIONS                                         \
417   CONST_SECTION_FUNCTION                                                \
418   CTORS_SECTION_FUNCTION                                                \
419   DTORS_SECTION_FUNCTION                                                \
420   TOC_SECTION_FUNCTION                                                  \
421   SDATA_SECTION_FUNCTION                                                \
422   SDATA2_SECTION_FUNCTION                                               \
423   SBSS_SECTION_FUNCTION                                                 \
424   INIT_SECTION_FUNCTION                                                 \
425   FINI_SECTION_FUNCTION
426
427 extern void toc_section (), sdata_section (), sdata2_section ();
428 extern void sbss_section ();
429
430 #define TOC_SECTION_FUNCTION                                            \
431 void                                                                    \
432 toc_section ()                                                          \
433 {                                                                       \
434   static int toc_initialized = 0;                                       \
435                                                                         \
436   if (in_section != in_toc)                                             \
437     {                                                                   \
438       in_section = in_toc;                                              \
439       if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)             \
440           && TARGET_MINIMAL_TOC                                         \
441           && !TARGET_RELOCATABLE)                                       \
442         {                                                               \
443           if (! toc_initialized)                                        \
444             {                                                           \
445               toc_initialized = 1;                                      \
446               fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP);       \
447               ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LCTOC", 0);     \
448               fprintf (asm_out_file, "\t.tc ");                         \
449               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1[TC],"); \
450               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \
451               fprintf (asm_out_file, "\n");                             \
452                                                                         \
453               fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); \
454               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \
455               fprintf (asm_out_file, " = .+32768\n");                   \
456             }                                                           \
457           else                                                          \
458             fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); \
459         }                                                               \
460       else if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)        \
461                && !TARGET_RELOCATABLE)                                  \
462         fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP);             \
463       else                                                              \
464         {                                                               \
465           fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP);   \
466           if (! toc_initialized)                                        \
467             {                                                           \
468               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \
469               fprintf (asm_out_file, " = .+32768\n");                   \
470               toc_initialized = 1;                                      \
471             }                                                           \
472         }                                                               \
473     }                                                                   \
474 }
475
476 #define SDATA_SECTION_FUNCTION                                          \
477 void                                                                    \
478 sdata_section ()                                                        \
479 {                                                                       \
480   if (in_section != in_sdata)                                           \
481     {                                                                   \
482       in_section = in_sdata;                                            \
483       fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP);             \
484     }                                                                   \
485 }
486
487 #define SDATA2_SECTION_FUNCTION                                         \
488 void                                                                    \
489 sdata2_section ()                                                       \
490 {                                                                       \
491   if (in_section != in_sdata2)                                          \
492     {                                                                   \
493       in_section = in_sdata2;                                           \
494       fprintf (asm_out_file, "%s\n", SDATA2_SECTION_ASM_OP);            \
495     }                                                                   \
496 }
497
498 #define SBSS_SECTION_FUNCTION                                           \
499 void                                                                    \
500 sbss_section ()                                                         \
501 {                                                                       \
502   if (in_section != in_sbss)                                            \
503     {                                                                   \
504       in_section = in_sbss;                                             \
505       fprintf (asm_out_file, "%s\n", SBSS_SECTION_ASM_OP);              \
506     }                                                                   \
507 }
508
509 #define INIT_SECTION_FUNCTION                                           \
510 void                                                                    \
511 init_section ()                                                         \
512 {                                                                       \
513   if (in_section != in_init)                                            \
514     {                                                                   \
515       in_section = in_init;                                             \
516       fprintf (asm_out_file, "%s\n", INIT_SECTION_ASM_OP);              \
517     }                                                                   \
518 }
519
520 #define FINI_SECTION_FUNCTION                                           \
521 void                                                                    \
522 fini_section ()                                                         \
523 {                                                                       \
524   if (in_section != in_fini)                                            \
525     {                                                                   \
526       in_section = in_fini;                                             \
527       fprintf (asm_out_file, "%s\n", FINI_SECTION_ASM_OP);              \
528     }                                                                   \
529 }
530
531 /* A C statement or statements to switch to the appropriate section
532    for output of RTX in mode MODE.  You can assume that RTX is some
533    kind of constant in RTL.  The argument MODE is redundant except in
534    the case of a `const_int' rtx.  Select the section by calling
535    `text_section' or one of the alternatives for other sections.
536
537    Do not define this macro if you put all constants in the read-only
538    data section.  */
539
540 extern void rs6000_select_rtx_section (), rs6000_select_section ();
541
542 #undef SELECT_RTX_SECTION
543 #define SELECT_RTX_SECTION(MODE, X) rs6000_select_rtx_section (MODE, X)
544
545 /* A C statement or statements to switch to the appropriate
546    section for output of DECL.  DECL is either a `VAR_DECL' node
547    or a constant of some sort.  RELOC indicates whether forming
548    the initial value of DECL requires link-time relocations.  */
549
550 #undef SELECT_SECTION
551 #define SELECT_SECTION(DECL,RELOC) rs6000_select_section (DECL, RELOC)
552
553 /* Return non-zero if this entry is to be written into the constant pool
554    in a special way.  We do so if this is a SYMBOL_REF, LABEL_REF or a CONST
555    containing one of them.  If -mfp-in-toc (the default), we also do
556    this for floating-point constants.  We actually can only do this
557    if the FP formats of the target and host machines are the same, but
558    we can't check that since not every file that uses
559    GO_IF_LEGITIMATE_ADDRESS_P includes real.h.
560
561    Unlike AIX, we don't key off of -mmininal-toc, but instead do not
562    allow floating point constants in the TOC if -mrelocatable.  */
563
564 #undef  ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
565 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X)                              \
566   (TARGET_TOC                                                           \
567    && (GET_CODE (X) == SYMBOL_REF                                       \
568        || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS      \
569            && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF)           \
570        || GET_CODE (X) == LABEL_REF                                     \
571        || (!TARGET_NO_FP_IN_TOC                                         \
572            && !TARGET_RELOCATABLE                                       \
573            && GET_CODE (X) == CONST_DOUBLE                              \
574            && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT               \
575            && BITS_PER_WORD == HOST_BITS_PER_INT)))
576
577 /* These macros generate the special .type and .size directives which
578    are used to set the corresponding fields of the linker symbol table
579    entries in an ELF object file under SVR4.  These macros also output
580    the starting labels for the relevant functions/objects.  */
581
582 /* Write the extra assembler code needed to declare a function properly.
583    Some svr4 assemblers need to also have something extra said about the
584    function's return value.  We allow for that here.  */
585
586 extern int rs6000_pic_labelno;
587
588 #undef  ASM_DECLARE_FUNCTION_NAME
589 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
590   do {                                                                  \
591     char *orig_name;                                                    \
592     char *init_ptr = (TARGET_64BIT) ? ".quad" : ".long";                \
593     STRIP_NAME_ENCODING (orig_name, NAME);                              \
594                                                                         \
595     if (TARGET_RELOCATABLE && get_pool_size () != 0)                    \
596       {                                                                 \
597         char buf[256], *buf_ptr;                                        \
598                                                                         \
599         ASM_OUTPUT_INTERNAL_LABEL (FILE, "LCL", rs6000_pic_labelno);    \
600                                                                         \
601         ASM_GENERATE_INTERNAL_LABEL (buf, "LCTOC", 1);                  \
602         STRIP_NAME_ENCODING (buf_ptr, buf);                             \
603         fprintf (FILE, "\t%s %s-", init_ptr, buf_ptr);                  \
604                                                                         \
605         ASM_GENERATE_INTERNAL_LABEL (buf, "LCF", rs6000_pic_labelno);   \
606         fprintf (FILE, "%s\n", buf_ptr);                                \
607       }                                                                 \
608                                                                         \
609     fprintf (FILE, "\t%s\t %s,", TYPE_ASM_OP, orig_name);               \
610     fprintf (FILE, TYPE_OPERAND_FMT, "function");                       \
611     putc ('\n', FILE);                                                  \
612     ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));                      \
613                                                                         \
614     if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)                \
615       {                                                                 \
616         char *desc_name = orig_name;                                    \
617                                                                         \
618         while (*desc_name == '.')                                       \
619           desc_name++;                                                  \
620                                                                         \
621         if (TREE_PUBLIC (DECL))                                         \
622           fprintf (FILE, "\t.globl %s\n", desc_name);                   \
623                                                                         \
624         fprintf (FILE, "%s\n", MINIMAL_TOC_SECTION_ASM_OP);             \
625         fprintf (FILE, "%s:\n", desc_name);                             \
626         fprintf (FILE, "\t%s %s\n", init_ptr, orig_name);               \
627         fprintf (FILE, "\t%s _GLOBAL_OFFSET_TABLE_\n", init_ptr);       \
628         if (DEFAULT_ABI == ABI_AIX)                                     \
629           fprintf (FILE, "\t%s 0\n", init_ptr);                         \
630         fprintf (FILE, "\t.previous\n");                                \
631       }                                                                 \
632     fprintf (FILE, "%s:\n", orig_name);                                 \
633   } while (0)
634
635 /* How to renumber registers for dbx and gdb.  */
636
637 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
638
639 /* svr4.h overrides ASM_OUTPUT_INTERNAL_LABEL.  */
640
641 #undef ASM_OUTPUT_INTERNAL_LABEL_PREFIX
642 #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX)   \
643   fprintf (FILE, ".%s", PREFIX)
644
645 /* This is how to allocate empty space in some section.  Use .space
646    instead of .zero because the Solaris PowerPC assembler doesn't
647    like it, and gas accepts either syntax.  */
648
649 #undef  SKIP_ASM_OP
650 #define SKIP_ASM_OP     ".space"
651
652 /* This says how to output assembler code to declare an
653    uninitialized internal linkage data object.  Under SVR4,
654    the linker seems to want the alignment of data objects
655    to depend on their types.  We do exactly that here.  */
656
657 #ifndef LOCAL_ASM_OP
658 #define LOCAL_ASM_OP    ".local"
659 #endif
660
661 #ifndef LCOMM_ASM_OP
662 #define LCOMM_ASM_OP    ".lcomm"
663 #endif
664
665 #undef ASM_OUTPUT_ALIGNED_LOCAL
666 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)               \
667 do {                                                                    \
668   if (TARGET_SDATA && (SIZE) > 0 && (SIZE) <= g_switch_value)           \
669     {                                                                   \
670       sbss_section ();                                                  \
671       ASM_OUTPUT_ALIGN (FILE, exact_log2 (ALIGN / BITS_PER_UNIT));      \
672       ASM_OUTPUT_LABEL (FILE, NAME);                                    \
673       ASM_OUTPUT_SKIP (FILE, SIZE);                                     \
674       if (!flag_inhibit_size_directive && (SIZE) > 0)                   \
675         {                                                               \
676           fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);                       \
677           assemble_name (FILE, NAME);                                   \
678           fprintf (FILE, ",%d\n",  SIZE);                               \
679         }                                                               \
680     }                                                                   \
681   else                                                                  \
682     {                                                                   \
683       fprintf (FILE, "\t%s\t", LCOMM_ASM_OP);                           \
684       assemble_name ((FILE), (NAME));                                   \
685       fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT);    \
686     }                                                                   \
687 } while (0)
688
689 /* Describe how to emit unitialized external linkage items  */
690 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN)           \
691 do {                                                                    \
692   ASM_GLOBALIZE_LABEL (FILE, NAME);                                     \
693   ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN);                   \
694 } while (0)
695
696 /* Switch  Recognition by gcc.c.  Add -G xx support */
697
698 #undef SWITCH_TAKES_ARG
699 #define SWITCH_TAKES_ARG(CHAR)                                          \
700   ((CHAR) == 'D' || (CHAR) == 'U' || (CHAR) == 'o'                      \
701    || (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u'                   \
702    || (CHAR) == 'I' || (CHAR) == 'm' || (CHAR) == 'x'                   \
703    || (CHAR) == 'L' || (CHAR) == 'A' || (CHAR) == 'V'                   \
704    || (CHAR) == 'B' || (CHAR) == 'b' || (CHAR) == 'G')
705
706 /* Output .file.  */
707 #undef ASM_FILE_START
708 #define ASM_FILE_START(FILE)                                            \
709 do {                                                                    \
710   output_file_directive ((FILE), main_input_filename);                  \
711   rs6000_file_start (FILE, TARGET_CPU_DEFAULT);                         \
712 } while (0)
713
714
715 /* This is how to output an assembler line defining an `int' constant.
716    For -mrelocatable, we mark all addresses that need to be fixed up
717    in the .fixup section.  */
718 #undef  ASM_OUTPUT_INT
719 #define ASM_OUTPUT_INT(FILE,VALUE)                                      \
720 do {                                                                    \
721   static int recurse = 0;                                               \
722   if (TARGET_RELOCATABLE                                                \
723       && in_section != in_toc                                           \
724       && in_section != in_text                                          \
725       && in_section != in_ctors                                         \
726       && in_section != in_dtors                                         \
727       && !recurse                                                       \
728       && GET_CODE (VALUE) != CONST_INT                                  \
729       && GET_CODE (VALUE) != CONST_DOUBLE                               \
730       && CONSTANT_P (VALUE))                                            \
731     {                                                                   \
732       static int labelno = 0;                                           \
733       char buf[256], *p;                                                \
734                                                                         \
735       recurse = 1;                                                      \
736       ASM_GENERATE_INTERNAL_LABEL (buf, "LCP", labelno++);              \
737       STRIP_NAME_ENCODING (p, buf);                                     \
738       fprintf (FILE, "%s:\n", p);                                       \
739       fprintf (FILE, "\t.long (");                                      \
740       output_addr_const (FILE, (VALUE));                                \
741       fprintf (FILE, ")@fixup\n");                                      \
742       fprintf (FILE, "\t.section \".fixup\",\"aw\"\n");                 \
743       ASM_OUTPUT_ALIGN (FILE, 2);                                       \
744       fprintf (FILE, "\t.long\t%s\n", p);                               \
745       fprintf (FILE, "\t.previous\n");                                  \
746       recurse = 0;                                                      \
747     }                                                                   \
748   /* Remove initial .'s to turn a -mcall-aixdesc or -mcall-nt function  \
749      address into the address of the descriptor, not the function       \
750      itself.  */                                                        \
751   else if (GET_CODE (VALUE) == SYMBOL_REF                               \
752            && XSTR (VALUE, 0)[0] == '.'                                 \
753            && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT))        \
754     {                                                                   \
755       char *name = XSTR (VALUE, 0);                                     \
756       while (*name == '.')                                              \
757         name++;                                                         \
758                                                                         \
759       fprintf (FILE, "\t.long %s\n", name);                             \
760     }                                                                   \
761   else                                                                  \
762     {                                                                   \
763       fprintf (FILE, "\t.long ");                                       \
764       output_addr_const (FILE, (VALUE));                                \
765       fprintf (FILE, "\n");                                             \
766     }                                                                   \
767 } while (0)
768
769 /* This is the end of what might become sysv4.h.  */
770
771 /* Allow stabs and dwarf, for now, make stabs the default debugging type,
772    not dwarf since G++ doesn't support dwarf. */
773 #undef  PREFERRED_DEBUGGING_TYPE
774 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
775
776 #define DBX_DEBUGGING_INFO
777 #define DWARF_DEBUGGING_INFO
778
779 /* If we are referencing a function that is static or is known to be
780    in this file, make the SYMBOL_REF special.  We can use this to indicate
781    that we can branch to this function without emitting a no-op after the
782    call.  For real AIX and NT calling sequences, we also replace the
783    function name with the real name (1 or 2 leading .'s), rather than
784    the function descriptor name.  This saves a lot of overriding code
785    to readd the prefixes.  */
786
787 #undef  ENCODE_SECTION_INFO
788 #define ENCODE_SECTION_INFO(DECL) rs6000_encode_section_info (DECL)
789
790 extern void rs6000_encode_section_info ();
791
792 /* This macro gets just the user-specified name
793    out of the string in a SYMBOL_REF.  Discard
794    a leading * or @. */
795 #undef  STRIP_NAME_ENCODING
796 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME)                            \
797 do {                                                                    \
798   char *_name = SYMBOL_NAME;                                            \
799   while (*_name == '*' || *_name == '@')                                \
800     _name++;                                                            \
801   (VAR) = _name;                                                        \
802 } while (0)
803
804 /* This is how to output a reference to a user-level label named NAME.
805    `assemble_name' uses this.  */
806
807 #undef ASM_OUTPUT_LABELREF
808 #define ASM_OUTPUT_LABELREF(FILE,NAME)  \
809 do {                                                                    \
810   char *_name = NAME;                                                   \
811   while (*_name == '*' || *_name == '@')                                \
812     _name++;                                                            \
813   fputs (_name, FILE);                                                  \
814 } while (0)
815
816 /*
817  * Switch into a generic section.
818  *
819  * We make the section read-only and executable for a function decl,
820  * read-only for a const data decl, and writable for a non-const data decl.
821  *
822  * If the section has already been defined, we must not
823  * emit the attributes here. The SVR4 assembler does not
824  * recognize section redefinitions.
825  * If DECL is NULL, no attributes are emitted.
826  *
827  * Note, Solaris as doesn't like @nobits, and gas can handle .sbss without
828  * needing @nobits.
829  */
830
831 #undef  ASM_OUTPUT_SECTION_NAME
832 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME)                       \
833 do {                                                                    \
834   static struct section_info                                            \
835     {                                                                   \
836       struct section_info *next;                                        \
837       char *name;                                                       \
838       enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type;                \
839     } *sections;                                                        \
840   struct section_info *s;                                               \
841   char *mode;                                                           \
842   enum sect_enum type;                                                  \
843                                                                         \
844   for (s = sections; s; s = s->next)                                    \
845     if (!strcmp (NAME, s->name))                                        \
846       break;                                                            \
847                                                                         \
848   if (DECL && TREE_CODE (DECL) == FUNCTION_DECL)                        \
849     type = SECT_EXEC, mode = "ax";                                      \
850   else if (DECL && TREE_READONLY (DECL))                                \
851     type = SECT_RO, mode = "a";                                         \
852   else                                                                  \
853     type = SECT_RW, mode = "aw";                                        \
854                                                                         \
855   if (s == 0)                                                           \
856     {                                                                   \
857       s = (struct section_info *) xmalloc (sizeof (struct section_info));  \
858       s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME));         \
859       strcpy (s->name, NAME);                                           \
860       s->type = type;                                                   \
861       s->next = sections;                                               \
862       sections = s;                                                     \
863       fprintf (FILE, ".section\t%s,\"%s\"\n", NAME, mode);              \
864     }                                                                   \
865   else                                                                  \
866     {                                                                   \
867       if (DECL && s->type != type)                                      \
868         error_with_decl (DECL, "%s causes a section type conflict");    \
869                                                                         \
870       fprintf (FILE, ".section\t%s\n", NAME);                           \
871     }                                                                   \
872 } while (0)
873
874 #undef ASM_OUTPUT_CONSTRUCTOR
875 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)                               \
876   do {                                                                  \
877     if (DEFAULT_ABI != ABI_SOLARIS)                                     \
878       {                                                                 \
879         ctors_section ();                                               \
880         fprintf (FILE, "\t%s\t ", INT_ASM_OP);                          \
881         assemble_name (FILE, NAME);                                     \
882       }                                                                 \
883     else                                                                \
884       {                                                                 \
885         init_section ();                                                \
886         fputs ("\tbl ", FILE);                                          \
887         assemble_name (FILE, NAME);                                     \
888       }                                                                 \
889     fputs ("\n", FILE);                                                 \
890   } while (0)
891
892 /* A C statement (sans semicolon) to output an element in the table of
893    global destructors.  */
894 #undef ASM_OUTPUT_DESTRUCTOR
895 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                                \
896   do {                                                                  \
897     if (DEFAULT_ABI != ABI_SOLARIS)                                     \
898       {                                                                 \
899         dtors_section ();                                               \
900         fprintf (FILE, "\t%s\t ", INT_ASM_OP);                          \
901         assemble_name (FILE, NAME);                                     \
902       }                                                                 \
903     else                                                                \
904       {                                                                 \
905         fini_section ();                                                \
906         fputs ("\tbl ", FILE);                                          \
907         assemble_name (FILE, NAME);                                     \
908       }                                                                 \
909     fputs ("\n", FILE);                                                 \
910   } while (0)
911
912 /* But, to make this work, we have to output the stabs for the function
913    name *first*...  */
914
915 #define DBX_FUNCTION_FIRST
916
917 /* This is the end of what might become sysv4dbx.h.  */
918
919 #undef TARGET_VERSION
920 #define TARGET_VERSION fprintf (stderr, " (PowerPC System V.4)");
921 \f
922 #undef CPP_PREDEFINES
923 #define CPP_PREDEFINES \
924   "-DPPC -Dunix -D__svr4__ -Asystem(unix) -Asystem(svr4) -Acpu(powerpc) -Amachine(powerpc)"
925
926 /* Pass various options to the assembler */
927 #undef ASM_SPEC
928 #define ASM_SPEC "%(asm_cpu) %{mregnames} %{mno-regnames} \
929 %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
930 %{mrelocatable} %{mrelocatable-lib} \
931 %{memb} %{!memb: %{msdata: -memb} %{msdata=eabi: -memb}} \
932 %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian} \
933 %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
934     %{mcall-solaris: -mlittle} %{mcall-linux: -mbig} }}}}"
935
936 #undef CC1_SPEC
937 /* Pass -G xxx to the compiler and set correct endian mode */
938 #define CC1_SPEC "%{G*} \
939 %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
940     %{mcall-nt: -mlittle } \
941     %{mcall-aixdesc: -mbig } \
942     %{mcall-solaris: -mlittle } \
943     %{mcall-linux: -mbig} }}}} \
944 %{mcall-solaris: -mregnames } \
945 %{mno-sdata: -msdata=none } \
946 %{meabi: %{!mcall-*: -mcall-sysv }} \
947 %{!meabi: %{!mno-eabi: \
948     %{mrelocatable: -meabi } \
949     %{mcall-solaris: -mno-eabi } \
950     %{mcall-linux: -mno-eabi }}}"
951
952 /* Don't put -Y P,<path> for cross compilers */
953 #undef LINK_PATH_SPEC
954 #ifndef CROSS_COMPILE
955 #define LINK_PATH_SPEC "\
956 %{!R*:%{L*:-R %*}} \
957 %{!nostdlib: %{!YP,*: \
958     %{compat-bsd: \
959         %{p:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
960         %{!p:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}} \
961         %{!R*: %{!L*: -R /usr/ucblib}} \
962     %{!compat-bsd: \
963         %{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
964         %{!p:-Y P,/usr/ccs/lib:/usr/lib}}}}"
965
966 #else
967 #define LINK_PATH_SPEC ""
968 #endif
969
970 /* Default starting address if specified */
971 #ifndef LINK_START_SPEC
972 #define LINK_START_SPEC "\
973 %{mmvme: %(link_start_mvme) } \
974 %{msim: %(link_start_sim) } \
975 %{mcall-linux: %(link_start_linux) } \
976 %{mcall-solaris: %(link_start_solaris) } \
977 %{!mmvme: %{!msim: %{!mcall-linux: %{!mcall-solaris: %(link_start_default) }}}}"
978 #endif
979
980 #ifndef LINK_START_DEFAULT_SPEC
981 #define LINK_START_DEFAULT_SPEC ""
982 #endif
983
984 #undef LINK_SPEC
985 #define LINK_SPEC "\
986 %{h*} %{v:-V} %{G*} \
987 %{Wl,*:%*} %{YP,*} %{R*} \
988 %{Qy:} %{!Qn:-Qy} \
989 %(link_shlib) \
990 %{!Ttext*: %(link_start) } \
991 %(link_target) \
992 %(link_os)"
993
994 /* For now, turn off shared libraries by default.  */
995 #ifndef SHARED_LIB_SUPPORT
996 #define NO_SHARED_LIB_SUPPORT
997 #endif
998
999 #undef  LINK_SHLIB_SPEC
1000 #ifndef NO_SHARED_LIB_SUPPORT
1001 /* Shared libaries are default.  */
1002 #define LINK_SHLIB_SPEC "\
1003 %{!static: %(link_path) %{!R*:%{L*:-R %*}}} \
1004 %{mshlib: } \
1005 %{static:-dn -Bstatic} \
1006 %{shared:-G -dy -z text %{!h*:%{o*:-h %*}}} \
1007 %{symbolic:-Bsymbolic -G -dy -z text %{!h*:%{o*:-h %*}}}"
1008
1009 #else
1010 /* Shared libraries are not default.  */
1011 #define LINK_SHLIB_SPEC "\
1012 %{mshlib: %(link_path) } \
1013 %{!mshlib: %{!shared: %{!symbolic: -dn -Bstatic}}} \
1014 %{static: } \
1015 %{shared:-G -dy -z text %{!h*:%{o*:-h %*}} %(link_path) } \
1016 %{symbolic:-Bsymbolic -G -dy -z text %{!h*:%{o*:-h %*}} %(link_path) }"
1017 #endif
1018
1019 /* Override the default target of the linker.  */
1020 #undef  LINK_TARGET_SPEC
1021 #define LINK_TARGET_SPEC "\
1022 %{mlittle: -oformat elf32-powerpcle } %{mlittle-endian: -oformat elf32-powerpcle } \
1023 %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: %{mcall-solaris: -oformat elf32-powerpcle}}}}}"
1024
1025 /* Any specific OS flags */
1026 #ifndef LINK_OS_SPEC
1027 #define LINK_OS_SPEC "\
1028 %{mmvme: %(link_os_mvme) } \
1029 %{msim: %(link_os_sim) } \
1030 %{mcall-linux: %(link_os_linux) } \
1031 %{mcall-solaris: %(link_os_solaris) } \
1032 %{!mmvme: %{!msim: %{!mcall-linux: %{!mcall-solaris: %(link_os_default) }}}}"
1033 #endif
1034
1035 #ifndef LINK_OS_DEFAULT_SPEC
1036 #define LINK_OS_DEFAULT_SPEC ""
1037 #endif
1038
1039 #undef  CPP_SYSV_SPEC
1040 #define CPP_SYSV_SPEC \
1041 "%{mrelocatable*: -D_RELOCATABLE} \
1042 %{mcall-sysv: -D_CALL_SYSV} %{mcall-nt: -D_CALL_NT} \
1043 %{mcall-aix: -D_CALL_AIX} %{mcall-aixdesc: -D_CALL_AIX -D_CALL_AIXDESC} \
1044 %{!mcall-sysv: %{!mcall-aix: %{!mcall-aixdesc: %{!mcall-nt: %(cpp_sysv_default) }}}} \
1045 %{msoft-float: -D_SOFT_FLOAT} %{mcpu=403: -D_SOFT_FLOAT}"
1046
1047 #undef  CPP_SYSV_DEFAULT_SPEC
1048 #define CPP_SYSV_DEFAULT_SPEC "-D_CALL_SYSV"
1049
1050 /* For solaris, don't define _LITTLE_ENDIAN, it conflicts with a header file.  */
1051 #undef  CPP_ENDIAN_SPEC
1052 #define CPP_ENDIAN_SPEC \
1053 "%{mlittle: -D_LITTLE_ENDIAN -Amachine(littleendian)} \
1054 %{mlittle-endian: -D_LITTLE_ENDIAN -Amachine(littleendian)} \
1055 %{mbig: -D_BIG_ENDIAN -Amachine(bigendian)} \
1056 %{mbig-endian: -D_BIG_ENDIAN -Amachine(bigendian)} \
1057 %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
1058     %{mcall-solaris: -Amachine(littleendian)} \
1059     %{mcall-nt: -D_LITTLE_ENDIAN -Amachine(littleendian)} \
1060     %{mcall-linux: -D_BIG_ENDIAN -Amachine(bigendian)} \
1061     %{mcall-aixdesc:  -D_BIG_ENDIAN -Amachine(bigendian)} \
1062     %{!mcall-solaris: %{!mcall-linux: %{!mcall-nt: %{!mcall-aixdesc: %(cpp_endian_default) }}}}}}}}"
1063
1064 #undef  CPP_ENDIAN_DEFAULT_SPEC
1065 #define CPP_ENDIAN_DEFAULT_SPEC "-D_BIG_ENDIAN -Amachine(bigendian)"
1066
1067 #undef CPP_SPEC
1068 #define CPP_SPEC "%{posix: -D_POSIX_SOURCE} %(cpp_sysv) %(cpp_endian) %(cpp_cpu) \
1069 %{mmvme: %(cpp_os_mvme) } \
1070 %{msim: %(cpp_os_sim) } \
1071 %{mcall-linux: %(cpp_os_linux) } \
1072 %{mcall-solaris: %(cpp_os_solaris) } \
1073 %{!mmvme: %{!msim: %{!mcall-linux: %{!mcall-solaris: %(cpp_os_default) }}}}"
1074
1075 #ifndef CPP_OS_DEFAULT_SPEC
1076 #define CPP_OS_DEFAULT_SPEC ""
1077 #endif
1078
1079 #undef  STARTFILE_SPEC
1080 #define STARTFILE_SPEC "\
1081 %{mmvme: %(startfile_mvme) } \
1082 %{msim: %(startfile_sim) } \
1083 %{mcall-linux: %(startfile_linux) } \
1084 %{mcall-solaris: %(startfile_solaris) } \
1085 %{!mmvme: %{!msim: %{!mcall-linux: %{!mcall-solaris: %(startfile_default) }}}}"
1086
1087 #undef  STARTFILE_DEFAULT_SPEC
1088 #define STARTFILE_DEFAULT_SPEC ""
1089
1090 #undef  LIB_SPEC
1091 #define LIB_SPEC "\
1092 %{mmvme: %(lib_mvme) } \
1093 %{msim: %(lib_sim) } \
1094 %{mcall-linux: %(lib_linux) } \
1095 %{mcall-solaris: %(lib_solaris) } \
1096 %{!mmvme: %{!msim: %{!mcall-linux: %{!mcall-solaris: %(lib_default) }}}}"
1097
1098 #undef  LIBGCC_SPEC
1099 #define LIBGCC_SPEC "libgcc.a%s"
1100
1101 #ifndef LIB_DEFAULT_SPEC
1102 #define LIB_DEFAULT_SPEC ""
1103 #endif
1104
1105 #undef  ENDFILE_SPEC
1106 #define ENDFILE_SPEC "\
1107 %{mmvme: ecrtn.o%s} \
1108 %{msim: ecrtn.o%s} \
1109 %{mcall-linux: } \
1110 %{mcall-solaris: scrtn.o%s} \
1111 %{!mmvme: %{!msim: %{!mcall-linux: %{!mcall-solaris: %(endfile_default) }}}}"
1112
1113 #undef  ENDFILE_DEFAULT_SPEC
1114 #define ENDFILE_DEFAULT_SPEC ""
1115
1116 /* Motorola MVME support.  */
1117 #ifndef LIB_MVME_SPEC
1118 #define LIB_MVME_SPEC "-( -lmvme -lc -)"
1119 #endif
1120
1121 #ifndef STARTFILE_MVME_SPEC
1122 #define STARTFILE_MVME_SPEC "ecrti.o%s mvme-crt0.o%s"
1123 #endif
1124
1125 #ifndef ENDFILE_MVME_SPEC
1126 #define ENDFILE_MVME_SPEC "ecrtn.o%s"
1127 #endif
1128
1129 #ifndef LINK_START_MVME_SPEC
1130 #define LINK_START_MVME_SPEC ""
1131 #endif
1132
1133 #ifndef LINK_OS_MVME_SPEC
1134 #define LINK_OS_MVME_SPEC ""
1135 #endif
1136
1137 #ifndef CPP_OS_MVME_SPEC
1138 #define CPP_OS_MVME_SPEC ""
1139 #endif
1140
1141 /* PowerPC simulator based on netbsd system calls support.  */
1142 #ifndef LIB_SIM_SPEC
1143 #define LIB_SIM_SPEC "-( -lsim -lc -)"
1144 #endif
1145
1146 #ifndef STARTFILE_SIM_SPEC
1147 #define STARTFILE_SIM_SPEC "ecrti.o%s sim-crt0.o%s"
1148 #endif
1149
1150 #ifndef ENDFILE_SIM_SPEC
1151 #define ENDFILE_SIM_SPEC "ecrtn.o%s"
1152 #endif
1153
1154 #ifndef LINK_START_SIM_SPEC
1155 #define LINK_START_SIM_SPEC "-Ttext 0x10000074"
1156 #endif
1157
1158 #ifndef LINK_OS_SIM_SPEC
1159 #define LINK_OS_SIM_SPEC ""
1160 #endif
1161
1162 #ifndef CPP_OS_SIM_SPEC
1163 #define CPP_OS_SIM_SPEC ""
1164 #endif
1165
1166 /* Linux support.  */
1167 #ifndef LIB_LINUX_SPEC
1168 #define LIB_LINUX_SPEC "%{mnewlib: -( -llinux -lc -) } %{!mnewlib: -lc }"
1169 #endif
1170
1171 #ifndef STARTFILE_LINUX_SPEC
1172 #define STARTFILE_LINUX_SPEC "\
1173 %{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} \
1174 scrti.o%s"
1175 #endif
1176
1177 #ifndef ENDFILE_LINUX_SPEC
1178 #define ENDFILE_LINUX_SPEC "scrtn.o%s"
1179 #endif
1180
1181 #ifndef LINK_START_LINUX_SPEC
1182 #define LINK_START_LINUX_SPEC "-Ttext 0x400074"
1183 #endif
1184
1185 #ifndef LINK_OS_LINUX_SPEC
1186 #define LINK_OS_LINUX_SPEC ""
1187 #endif
1188
1189 #ifndef CPP_OS_LINUX_SPEC
1190 #define CPP_OS_LINUX_SPEC "-D__unix__ -D__linux__ \
1191 %{!ansi: -Dunix -Dlinux } \
1192 -Asystem(unix) -Asystem(linux)"
1193 #endif
1194
1195 #ifndef CPP_OS_LINUX_SPEC
1196 #define CPP_OS_LINUX_SPEC ""
1197 #endif
1198
1199 /* Solaris support.  */
1200 /* For Solaris, Gcc automatically adds in one of the files
1201    /usr/ccs/lib/values-Xc.o, /usr/ccs/lib/values-Xa.o, or
1202    /usr/ccs/lib/values-Xt.o for each final link step (depending upon the other
1203    gcc options selected, such as -traditional and -ansi).  These files each
1204    contain one (initialized) copy of a special variable called `_lib_version'.
1205    Each one of these files has `_lib_version' initialized to a different (enum)
1206    value.  The SVR4 library routines query the value of `_lib_version' at run
1207    to decide how they should behave.  Specifically, they decide (based upon the
1208    value of `_lib_version') if they will act in a strictly ANSI conforming
1209    manner or not.  */
1210
1211 #ifndef LIB_SOLARIS_SPEC
1212 #define LIB_SOLARIS_SPEC "\
1213 %{mnewlib: -( -lsolaris -lc -) } \
1214 %{!mnewlib: \
1215     %{ansi:values-Xc.o%s} \
1216     %{!ansi: \
1217         %{traditional:values-Xt.o%s} \
1218         %{!traditional:values-Xa.o%s}} \
1219         %{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \
1220     %{solaris-cclib: /opt/SUNWspro/SC4.0/lib/libabi.a} \
1221     %{!shared: %{!symbolic: -lc }}}"
1222 #endif
1223
1224 #ifndef STARTFILE_SOLARIS_SPEC
1225 #define STARTFILE_SOLARIS_SPEC "\
1226 %{!msolaris-cclib: scrti.o%s scrt0.o%s} \
1227 %{msolaris-cclib: /opt/SUNWspro/SC4.0/lib/crti.o%s /opt/SUNWspro/SC4.0/lib/crt1.o%s}"
1228 #endif
1229
1230 #ifndef ENDFILE_SOLARIS_SPEC
1231 #define ENDFILE_SOLARIS_SPEC "\
1232 %{!msolaris-cclib: scrtn.o%s} \
1233 %{msolaris-cclib: /opt/SUNWspro/SC4.0/lib/crtn.o%s}"
1234 #endif
1235
1236 #ifndef LINK_START_SOLARIS_SPEC
1237 #ifdef CROSS_COMPILER
1238 #define LINK_START_SOLARIS_SPEC "-Ttext 0x2000074"
1239 #else
1240 #define LINK_START_SOLARIS_SPEC ""
1241 #endif
1242 #endif
1243
1244 #ifndef LINK_OS_SOLARIS_SPEC
1245 #define LINK_OS_SOLARIS_SPEC ""
1246 #endif
1247
1248 #ifndef CPP_OS_SOLARIS_SPEC
1249 #define CPP_OS_SOLARIS_SPEC "-D__ppc -D__sun__=1 -D__unix__ -D__svr4__  -D__SVR4__ \
1250 %{!ansi: -Dsun=1 -Dunix -DSVR4 -D__EXTENSIONS__ } \
1251 -Amachine(prep)"
1252 #endif
1253
1254 /* Define any extra SPECS that the compiler needs to generate.  */
1255 #undef  SUBTARGET_EXTRA_SPECS
1256 #define SUBTARGET_EXTRA_SPECS                                           \
1257   { "lib_mvme",                 LIB_MVME_SPEC },                        \
1258   { "lib_sim",                  LIB_SIM_SPEC },                         \
1259   { "lib_linux",                LIB_LINUX_SPEC },                       \
1260   { "lib_solaris",              LIB_SOLARIS_SPEC },                     \
1261   { "lib_default",              LIB_DEFAULT_SPEC },                     \
1262   { "startfile_mvme",           STARTFILE_MVME_SPEC },                  \
1263   { "startfile_sim",            STARTFILE_SIM_SPEC },                   \
1264   { "startfile_linux",          STARTFILE_LINUX_SPEC },                 \
1265   { "startfile_solaris",        STARTFILE_SOLARIS_SPEC },               \
1266   { "startfile_default",        STARTFILE_DEFAULT_SPEC },               \
1267   { "endfile_mvme",             ENDFILE_MVME_SPEC },                    \
1268   { "endfile_sim",              ENDFILE_SIM_SPEC },                     \
1269   { "endfile_linux",            ENDFILE_LINUX_SPEC },                   \
1270   { "endfile_solaris",          ENDFILE_SOLARIS_SPEC },                 \
1271   { "endfile_default",          ENDFILE_DEFAULT_SPEC },                 \
1272   { "link_path",                LINK_PATH_SPEC },                       \
1273   { "link_shlib",               LINK_SHLIB_SPEC },                      \
1274   { "link_target",              LINK_TARGET_SPEC },                     \
1275   { "link_start",               LINK_START_SPEC },                      \
1276   { "link_start_mvme",          LINK_START_MVME_SPEC },                 \
1277   { "link_start_sim",           LINK_START_SIM_SPEC },                  \
1278   { "link_start_linux",         LINK_START_LINUX_SPEC },                \
1279   { "link_start_solaris",       LINK_START_SOLARIS_SPEC },              \
1280   { "link_start_default",       LINK_START_DEFAULT_SPEC },              \
1281   { "link_os",                  LINK_OS_SPEC },                         \
1282   { "link_os_mvme",             LINK_OS_MVME_SPEC },                    \
1283   { "link_os_sim",              LINK_OS_SIM_SPEC },                     \
1284   { "link_os_linux",            LINK_OS_LINUX_SPEC },                   \
1285   { "link_os_solaris",          LINK_OS_SOLARIS_SPEC },                 \
1286   { "link_os_default",          LINK_OS_DEFAULT_SPEC },                 \
1287   { "cpp_os_mvme",              CPP_OS_MVME_SPEC },                     \
1288   { "cpp_os_sim",               CPP_OS_SIM_SPEC },                      \
1289   { "cpp_os_linux",             CPP_OS_LINUX_SPEC },                    \
1290   { "cpp_os_solaris",           CPP_OS_SOLARIS_SPEC },                  \
1291   { "cpp_os_default",           CPP_OS_DEFAULT_SPEC },
1292
1293 /* Define this macro as a C expression for the initializer of an
1294    array of string to tell the driver program which options are
1295    defaults for this target and thus do not need to be handled
1296    specially when using `MULTILIB_OPTIONS'.
1297
1298    Do not define this macro if `MULTILIB_OPTIONS' is not defined in
1299    the target makefile fragment or if none of the options listed in
1300    `MULTILIB_OPTIONS' are set by default.  *Note Target Fragment::.  */
1301
1302 #undef  MULTILIB_DEFAULTS
1303 #define MULTILIB_DEFAULTS { "mbig", "mbig-endian", "mcall-sysv-noeabi", "mno-sdata" }