]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rs6000/sysv4.h
1 /* Target definitions for GNU compiler for PowerPC running System V.4
2 Copyright (C) 1995-2016 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published
9 by the Free Software Foundation; either version 3, or (at your
10 option) any later version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
26 /* Header files should be C++ aware in general. */
27 #undef NO_IMPLICIT_EXTERN_C
28 #define NO_IMPLICIT_EXTERN_C
30 /* Yes! We are ELF. */
31 #define TARGET_OBJECT_FORMAT OBJECT_ELF
33 /* Default ABI to compile code for. */
34 #define DEFAULT_ABI rs6000_current_abi
36 /* Default ABI to use. */
37 #define RS6000_ABI_NAME "sysv"
39 /* Override rs6000.h definition. */
40 #undef ASM_DEFAULT_SPEC
41 #define ASM_DEFAULT_SPEC "-mppc"
43 #define TARGET_TOC (TARGET_64BIT \
44 || (TARGET_MINIMAL_TOC \
46 || DEFAULT_ABI != ABI_V4)
48 #define TARGET_BITFIELD_TYPE (! TARGET_NO_BITFIELD_TYPE)
49 #define TARGET_BIG_ENDIAN (! TARGET_LITTLE_ENDIAN)
50 #define TARGET_PROTOTYPE target_prototype
51 #define TARGET_NO_PROTOTYPE (! TARGET_PROTOTYPE)
52 #define TARGET_NO_TOC (! TARGET_TOC)
53 #define TARGET_NO_EABI (! TARGET_EABI)
54 #define TARGET_REGNAMES rs6000_regnames
57 #undef TARGET_SECURE_PLT
58 #define TARGET_SECURE_PLT secure_plt
61 #define SDATA_DEFAULT_SIZE 8
63 /* The macro SUBTARGET_OVERRIDE_OPTIONS is provided for subtargets, to
64 get control in TARGET_OPTION_OVERRIDE. */
66 #define SUBTARGET_OVERRIDE_OPTIONS \
68 if (!global_options_set.x_g_switch_value) \
69 g_switch_value = SDATA_DEFAULT_SIZE; \
71 if (rs6000_abi_name == NULL) \
72 rs6000_abi_name = RS6000_ABI_NAME; \
74 if (!strcmp (rs6000_abi_name, "sysv")) \
75 rs6000_current_abi = ABI_V4; \
76 else if (!strcmp (rs6000_abi_name, "sysv-noeabi")) \
78 rs6000_current_abi = ABI_V4; \
79 rs6000_isa_flags &= ~ OPTION_MASK_EABI; \
81 else if (!strcmp (rs6000_abi_name, "sysv-eabi") \
82 || !strcmp (rs6000_abi_name, "eabi")) \
84 rs6000_current_abi = ABI_V4; \
85 rs6000_isa_flags |= OPTION_MASK_EABI; \
87 else if (!strcmp (rs6000_abi_name, "aixdesc")) \
88 rs6000_current_abi = ABI_AIX; \
89 else if (!strcmp (rs6000_abi_name, "freebsd") \
90 || !strcmp (rs6000_abi_name, "linux")) \
93 rs6000_current_abi = ABI_AIX; \
95 rs6000_current_abi = ABI_V4; \
97 else if (!strcmp (rs6000_abi_name, "netbsd")) \
98 rs6000_current_abi = ABI_V4; \
99 else if (!strcmp (rs6000_abi_name, "openbsd")) \
100 rs6000_current_abi = ABI_V4; \
101 else if (!strcmp (rs6000_abi_name, "i960-old")) \
103 rs6000_current_abi = ABI_V4; \
104 rs6000_isa_flags |= (OPTION_MASK_LITTLE_ENDIAN | OPTION_MASK_EABI); \
105 rs6000_isa_flags &= ~OPTION_MASK_STRICT_ALIGN; \
106 TARGET_NO_BITFIELD_WORD = 1; \
110 rs6000_current_abi = ABI_V4; \
111 error ("bad value for -mcall-%s", rs6000_abi_name); \
114 if (rs6000_sdata_name) \
116 if (!strcmp (rs6000_sdata_name, "none")) \
117 rs6000_sdata = SDATA_NONE; \
118 else if (!strcmp (rs6000_sdata_name, "data")) \
119 rs6000_sdata = SDATA_DATA; \
120 else if (!strcmp (rs6000_sdata_name, "default")) \
121 rs6000_sdata = (TARGET_EABI) ? SDATA_EABI : SDATA_SYSV; \
122 else if (!strcmp (rs6000_sdata_name, "sysv")) \
123 rs6000_sdata = SDATA_SYSV; \
124 else if (!strcmp (rs6000_sdata_name, "eabi")) \
125 rs6000_sdata = SDATA_EABI; \
127 error ("bad value for -msdata=%s", rs6000_sdata_name); \
129 else if (DEFAULT_ABI == ABI_V4) \
131 rs6000_sdata = SDATA_DATA; \
132 rs6000_sdata_name = "data"; \
136 rs6000_sdata = SDATA_NONE; \
137 rs6000_sdata_name = "none"; \
140 if (TARGET_RELOCATABLE && \
141 (rs6000_sdata == SDATA_EABI || rs6000_sdata == SDATA_SYSV)) \
143 rs6000_sdata = SDATA_DATA; \
144 error ("-mrelocatable and -msdata=%s are incompatible", \
145 rs6000_sdata_name); \
148 else if (flag_pic && DEFAULT_ABI == ABI_V4 \
149 && (rs6000_sdata == SDATA_EABI \
150 || rs6000_sdata == SDATA_SYSV)) \
152 rs6000_sdata = SDATA_DATA; \
153 error ("-f%s and -msdata=%s are incompatible", \
154 (flag_pic > 1) ? "PIC" : "pic", \
155 rs6000_sdata_name); \
158 if ((rs6000_sdata != SDATA_NONE && DEFAULT_ABI != ABI_V4) \
159 || (rs6000_sdata == SDATA_EABI && !TARGET_EABI)) \
161 rs6000_sdata = SDATA_NONE; \
162 error ("-msdata=%s and -mcall-%s are incompatible", \
163 rs6000_sdata_name, rs6000_abi_name); \
166 targetm.have_srodata_section = rs6000_sdata == SDATA_EABI; \
168 if (TARGET_RELOCATABLE && !TARGET_MINIMAL_TOC) \
170 rs6000_isa_flags |= OPTION_MASK_MINIMAL_TOC; \
171 error ("-mrelocatable and -mno-minimal-toc are incompatible"); \
174 if (TARGET_RELOCATABLE && rs6000_current_abi != ABI_V4) \
176 rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \
177 error ("-mrelocatable and -mcall-%s are incompatible", \
181 if (!TARGET_64BIT && flag_pic > 1 && rs6000_current_abi != ABI_V4) \
184 error ("-fPIC and -mcall-%s are incompatible", \
188 if (TARGET_SECURE_PLT != secure_plt) \
190 error ("-msecure-plt not supported by your assembler"); \
193 /* Treat -fPIC the same as -mrelocatable. */ \
194 if (flag_pic > 1 && DEFAULT_ABI == ABI_V4) \
196 rs6000_isa_flags |= OPTION_MASK_RELOCATABLE | OPTION_MASK_MINIMAL_TOC; \
197 TARGET_NO_FP_IN_TOC = 1; \
200 else if (TARGET_RELOCATABLE) \
205 #ifndef RS6000_BI_ARCH
206 # define SUBSUBTARGET_OVERRIDE_OPTIONS \
208 if ((TARGET_DEFAULT ^ rs6000_isa_flags) & OPTION_MASK_64BIT) \
209 error ("-m%s not supported in this configuration", \
210 (rs6000_isa_flags & OPTION_MASK_64BIT) ? "64" : "32"); \
214 /* Override rs6000.h definition. */
215 #undef TARGET_DEFAULT
216 #define TARGET_DEFAULT 0
218 /* Override rs6000.h definition. */
219 #undef PROCESSOR_DEFAULT
220 #define PROCESSOR_DEFAULT PROCESSOR_PPC750
223 /* System V.4 uses register 13 as a pointer to the small data area,
224 so it is not available to the normal user. */
227 /* Override default big endianism definitions in rs6000.h. */
228 #undef BYTES_BIG_ENDIAN
229 #undef WORDS_BIG_ENDIAN
230 #define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN)
231 #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN)
233 /* Put jump tables in read-only memory, rather than in .text. */
234 #define JUMP_TABLES_IN_TEXT_SECTION 0
236 /* Prefix and suffix to use to saving floating point. */
237 #define SAVE_FP_PREFIX "_savefpr_"
238 #define SAVE_FP_SUFFIX ""
240 /* Prefix and suffix to use to restoring floating point. */
241 #define RESTORE_FP_PREFIX "_restfpr_"
242 #define RESTORE_FP_SUFFIX ""
244 /* Type used for size_t, as a string used in a declaration. */
246 #define SIZE_TYPE "unsigned int"
248 /* Type used for ptrdiff_t, as a string used in a declaration. */
249 #define PTRDIFF_TYPE "int"
252 #define WCHAR_TYPE "long int"
254 #undef WCHAR_TYPE_SIZE
255 #define WCHAR_TYPE_SIZE 32
257 /* Make int foo : 8 not cause structures to be aligned to an int boundary. */
258 /* Override elfos.h definition. */
259 #undef PCC_BITFIELD_TYPE_MATTERS
260 #define PCC_BITFIELD_TYPE_MATTERS (TARGET_BITFIELD_TYPE)
262 #undef BITFIELD_NBYTES_LIMITED
263 #define BITFIELD_NBYTES_LIMITED (TARGET_NO_BITFIELD_WORD)
265 /* Define this macro to be the value 1 if instructions will fail to
266 work if given data not on the nominal alignment. If instructions
267 will merely go slower in that case, define this macro as 0. */
268 #undef STRICT_ALIGNMENT
269 #define STRICT_ALIGNMENT (TARGET_STRICT_ALIGN)
271 /* Define this macro if you wish to preserve a certain alignment for
272 the stack pointer, greater than what the hardware enforces. The
273 definition is a C expression for the desired alignment (measured
274 in bits). This macro must evaluate to a value equal to or larger
276 For the SYSV ABI and variants the alignment of the stack pointer
277 is usually controlled manually in rs6000.c. However, to maintain
278 alignment across alloca () in all circumstances,
279 PREFERRED_STACK_BOUNDARY needs to be set as well.
280 This has the additional advantage of allowing a bigger maximum
281 alignment of user objects on the stack. */
283 #undef PREFERRED_STACK_BOUNDARY
284 #define PREFERRED_STACK_BOUNDARY 128
286 /* Real stack boundary as mandated by the appropriate ABI. */
287 #define ABI_STACK_BOUNDARY \
288 ((TARGET_EABI && !TARGET_ALTIVEC && !TARGET_ALTIVEC_ABI) ? 64 : 128)
290 /* An expression for the alignment of a structure field FIELD if the
291 alignment computed in the usual way is COMPUTED. */
292 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
293 (rs6000_special_adjust_field_align_p ((FIELD), (COMPUTED)) \
296 #undef BIGGEST_FIELD_ALIGNMENT
298 /* Use ELF style section commands. */
300 #define TEXT_SECTION_ASM_OP "\t.section\t\".text\""
302 #define DATA_SECTION_ASM_OP "\t.section\t\".data\""
304 #define BSS_SECTION_ASM_OP "\t.section\t\".bss\""
306 /* Override elfos.h definition. */
307 #undef INIT_SECTION_ASM_OP
308 #define INIT_SECTION_ASM_OP "\t.section\t\".init\",\"ax\""
310 /* Override elfos.h definition. */
311 #undef FINI_SECTION_ASM_OP
312 #define FINI_SECTION_ASM_OP "\t.section\t\".fini\",\"ax\""
314 #define TOC_SECTION_ASM_OP "\t.section\t\".got\",\"aw\""
316 /* Put PC relative got entries in .got2. */
317 #define MINIMAL_TOC_SECTION_ASM_OP \
318 (TARGET_RELOCATABLE || (flag_pic && DEFAULT_ABI == ABI_V4) \
319 ? "\t.section\t\".got2\",\"aw\"" : "\t.section\t\".got1\",\"aw\"")
321 #define SDATA_SECTION_ASM_OP "\t.section\t\".sdata\",\"aw\""
322 #define SDATA2_SECTION_ASM_OP "\t.section\t\".sdata2\",\"a\""
323 #define SBSS_SECTION_ASM_OP "\t.section\t\".sbss\",\"aw\",@nobits"
325 /* Override default elf definitions. */
326 #define TARGET_ASM_INIT_SECTIONS rs6000_elf_asm_init_sections
327 #undef TARGET_ASM_RELOC_RW_MASK
328 #define TARGET_ASM_RELOC_RW_MASK rs6000_elf_reloc_rw_mask
329 #undef TARGET_ASM_SELECT_RTX_SECTION
330 #define TARGET_ASM_SELECT_RTX_SECTION rs6000_elf_select_rtx_section
332 /* Return nonzero if this entry is to be written into the constant pool
333 in a special way. We do so if this is a SYMBOL_REF, LABEL_REF or a CONST
334 containing one of them. If -mfp-in-toc (the default), we also do
335 this for floating-point constants. We actually can only do this
336 if the FP formats of the target and host machines are the same, but
337 we can't check that since not every file that uses these target macros
340 Unlike AIX, we don't key off of -mminimal-toc, but instead do not
341 allow floating point constants in the TOC if -mrelocatable. */
343 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
344 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
346 && (GET_CODE (X) == SYMBOL_REF \
347 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
348 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
349 || GET_CODE (X) == LABEL_REF \
350 || (GET_CODE (X) == CONST_INT \
351 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
352 || (!TARGET_NO_FP_IN_TOC \
353 && !TARGET_RELOCATABLE \
354 && GET_CODE (X) == CONST_DOUBLE \
355 && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
356 && BITS_PER_WORD == HOST_BITS_PER_INT)))
358 /* These macros generate the special .type and .size directives which
359 are used to set the corresponding fields of the linker symbol table
360 entries in an ELF object file under SVR4. These macros also output
361 the starting labels for the relevant functions/objects. */
363 /* Write the extra assembler code needed to declare a function properly.
364 Some svr4 assemblers need to also have something extra said about the
365 function's return value. We allow for that here. */
367 /* Override elfos.h definition. */
368 #undef ASM_DECLARE_FUNCTION_NAME
369 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
370 rs6000_elf_declare_function_name ((FILE), (NAME), (DECL))
372 /* The USER_LABEL_PREFIX stuff is affected by the -fleading-underscore
373 flag. The LOCAL_LABEL_PREFIX variable is used by dbxelf.h. */
375 #define LOCAL_LABEL_PREFIX "."
376 #define USER_LABEL_PREFIX ""
378 #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX) \
379 asm_fprintf (FILE, "%L%s", PREFIX)
381 /* Globalizing directive for a label. */
382 #define GLOBAL_ASM_OP "\t.globl "
384 /* This says how to output assembler code to declare an
385 uninitialized internal linkage data object. Under SVR4,
386 the linker seems to want the alignment of data objects
387 to depend on their types. We do exactly that here. */
389 #define LOCAL_ASM_OP "\t.local\t"
391 #define LCOMM_ASM_OP "\t.lcomm\t"
393 /* Describe how to emit uninitialized local items. */
394 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
396 if ((DECL) && rs6000_elf_in_small_data_p (DECL)) \
398 switch_to_section (sbss_section); \
399 ASM_OUTPUT_ALIGN (FILE, exact_log2 (ALIGN / BITS_PER_UNIT)); \
400 ASM_OUTPUT_LABEL (FILE, NAME); \
401 ASM_OUTPUT_SKIP (FILE, SIZE); \
402 if (!flag_inhibit_size_directive && (SIZE) > 0) \
403 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
407 fprintf (FILE, "%s", LCOMM_ASM_OP); \
408 assemble_name ((FILE), (NAME)); \
409 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
410 (SIZE), (ALIGN) / BITS_PER_UNIT); \
412 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
415 /* Describe how to emit uninitialized external linkage items. */
416 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
418 ASM_OUTPUT_ALIGNED_DECL_LOCAL (FILE, DECL, NAME, SIZE, ALIGN); \
421 #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
422 /* To support -falign-* switches we need to use .p2align so
423 that alignment directives in code sections will be padded
424 with no-op instructions, rather than zeroes. */
425 #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \
428 if ((MAX_SKIP) == 0) \
429 fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
431 fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \
435 /* This is how to output code to push a register on the stack.
436 It need not be very fast code.
438 On the rs6000, we must keep the backchain up to date. In order
439 to simplify things, always allocate 16 bytes for a push (System V
440 wants to keep stack aligned to a 16 byte boundary). */
442 #define ASM_OUTPUT_REG_PUSH(FILE, REGNO) \
444 if (DEFAULT_ABI == ABI_V4) \
446 "\tstwu %s,-16(%s)\n\tstw %s,12(%s)\n", \
447 reg_names[1], reg_names[1], reg_names[REGNO], \
451 /* This is how to output an insn to pop a register from the stack.
452 It need not be very fast code. */
454 #define ASM_OUTPUT_REG_POP(FILE, REGNO) \
456 if (DEFAULT_ABI == ABI_V4) \
458 "\tlwz %s,12(%s)\n\taddi %s,%s,16\n", \
459 reg_names[REGNO], reg_names[1], reg_names[1], \
463 extern int fixuplabelno
;
465 /* Handle constructors specially for -mrelocatable. */
466 #define TARGET_ASM_CONSTRUCTOR rs6000_elf_asm_out_constructor
467 #define TARGET_ASM_DESTRUCTOR rs6000_elf_asm_out_destructor
469 /* This is the end of what might become sysv4.h. */
471 /* Use DWARF 2 debugging information by default. */
472 #undef PREFERRED_DEBUGGING_TYPE
473 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
475 /* Historically we have also supported stabs debugging. */
476 #define DBX_DEBUGGING_INFO 1
478 #define TARGET_ENCODE_SECTION_INFO rs6000_elf_encode_section_info
479 #define TARGET_IN_SMALL_DATA_P rs6000_elf_in_small_data_p
481 /* The ELF version doesn't encode [DS] or whatever at the end of symbols. */
483 #define RS6000_OUTPUT_BASENAME(FILE, NAME) \
484 assemble_name (FILE, NAME)
486 /* We have to output the stabs for the function name *first*, before
487 outputting its label. */
489 #define DBX_FUNCTION_FIRST
491 /* This is the end of what might become sysv4dbx.h. */
493 #define TARGET_OS_SYSV_CPP_BUILTINS() \
496 if (rs6000_isa_flags_explicit \
497 & OPTION_MASK_RELOCATABLE) \
498 builtin_define ("_RELOCATABLE"); \
502 #ifndef TARGET_OS_CPP_BUILTINS
503 #define TARGET_OS_CPP_BUILTINS() \
506 builtin_define_std ("PPC"); \
507 builtin_define_std ("unix"); \
508 builtin_define ("__svr4__"); \
509 builtin_assert ("system=unix"); \
510 builtin_assert ("system=svr4"); \
511 builtin_assert ("cpu=powerpc"); \
512 builtin_assert ("machine=powerpc"); \
513 TARGET_OS_SYSV_CPP_BUILTINS (); \
518 /* Select one of BIG_OPT, LITTLE_OPT or DEFAULT_OPT depending
519 on various -mbig, -mlittle and -mcall- options. */
520 #define ENDIAN_SELECT(BIG_OPT, LITTLE_OPT, DEFAULT_OPT) \
521 "%{mlittle|mlittle-endian:" LITTLE_OPT ";" \
522 "mbig|mbig-endian:" BIG_OPT ";" \
523 "mcall-i960-old:" LITTLE_OPT ";" \
526 #define DEFAULT_ASM_ENDIAN " -mbig"
529 #define ASM_SPEC "%(asm_cpu) \
530 %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}} \
531 %{mrelocatable} %{mrelocatable-lib} %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
532 %{memb|msdata=eabi: -memb}" \
533 ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
535 #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
536 #define CC1_SECURE_PLT_DEFAULT_SPEC ""
538 #ifndef LINK_SECURE_PLT_DEFAULT_SPEC
539 #define LINK_SECURE_PLT_DEFAULT_SPEC ""
542 /* Pass -G xxx to the compiler. */
544 #define CC1_SPEC "%{G*} %(cc1_cpu)" \
545 "%{meabi: %{!mcall-*: -mcall-sysv }} \
546 %{!meabi: %{!mno-eabi: \
547 %{mrelocatable: -meabi } \
548 %{mcall-freebsd: -mno-eabi } \
549 %{mcall-i960-old: -meabi } \
550 %{mcall-linux: -mno-eabi } \
551 %{mcall-netbsd: -mno-eabi } \
552 %{mcall-openbsd: -mno-eabi }}} \
553 %{msdata: -msdata=default} \
554 %{mno-sdata: -msdata=none} \
555 %{!mbss-plt: %{!msecure-plt: %(cc1_secure_plt_default)}} \
558 /* Default starting address if specified. */
559 #define LINK_START_SPEC "\
560 %{mads : %(link_start_ads) ; \
561 myellowknife : %(link_start_yellowknife) ; \
562 mmvme : %(link_start_mvme) ; \
563 msim : %(link_start_sim) ; \
564 mcall-freebsd: %(link_start_freebsd) ; \
565 mcall-linux : %(link_start_linux) ; \
566 mcall-netbsd : %(link_start_netbsd) ; \
567 mcall-openbsd: %(link_start_openbsd) ; \
568 : %(link_start_default) }"
570 #define LINK_START_DEFAULT_SPEC ""
571 #define LINK_SECURE_PLT_SPEC LINK_SECURE_PLT_DEFAULT_SPEC
575 %{h*} %{v:-V} %{!msdata=none:%{G*}} %{msdata=none:-G0} \
578 %{!T*: %(link_start) } \
579 %{!static: %{!mbss-plt: %(link_secure_plt)}} \
582 /* Shared libraries are not default. */
583 #define LINK_SHLIB_SPEC "\
584 %{!mshlib: %{!shared: %{!symbolic: -dn -Bstatic}}} \
586 %{shared:-G -dy -z text } \
587 %{symbolic:-Bsymbolic -G -dy -z text }"
589 /* Any specific OS flags. */
590 #define LINK_OS_SPEC "\
591 %{mads : %(link_os_ads) ; \
592 myellowknife : %(link_os_yellowknife) ; \
593 mmvme : %(link_os_mvme) ; \
594 msim : %(link_os_sim) ; \
595 mcall-freebsd: %(link_os_freebsd) ; \
596 mcall-linux : %(link_os_linux) ; \
597 mcall-netbsd : %(link_os_netbsd) ; \
598 mcall-openbsd: %(link_os_openbsd) ; \
599 : %(link_os_default) }"
601 #define LINK_OS_DEFAULT_SPEC ""
603 #define DRIVER_SELF_SPECS "%{mfpu=none: %<mfpu=* \
604 %<msingle-float %<mdouble-float}"
606 /* Override rs6000.h definition. */
608 #define CPP_SPEC "%{posix: -D_POSIX_SOURCE} \
609 %{mads : %(cpp_os_ads) ; \
610 myellowknife : %(cpp_os_yellowknife) ; \
611 mmvme : %(cpp_os_mvme) ; \
612 msim : %(cpp_os_sim) ; \
613 mcall-freebsd: %(cpp_os_freebsd) ; \
614 mcall-linux : %(cpp_os_linux) ; \
615 mcall-netbsd : %(cpp_os_netbsd) ; \
616 mcall-openbsd: %(cpp_os_openbsd) ; \
617 : %(cpp_os_default) }"
619 #define CPP_OS_DEFAULT_SPEC ""
621 #undef STARTFILE_SPEC
622 #define STARTFILE_SPEC "\
623 %{mads : %(startfile_ads) ; \
624 myellowknife : %(startfile_yellowknife) ; \
625 mmvme : %(startfile_mvme) ; \
626 msim : %(startfile_sim) ; \
627 mcall-freebsd: %(startfile_freebsd) ; \
628 mcall-linux : %(startfile_linux) ; \
629 mcall-netbsd : %(startfile_netbsd) ; \
630 mcall-openbsd: %(startfile_openbsd) ; \
631 : %(startfile_default) }"
633 #define STARTFILE_DEFAULT_SPEC "ecrti.o%s crtbegin.o%s"
637 %{mads : %(lib_ads) ; \
638 myellowknife : %(lib_yellowknife) ; \
639 mmvme : %(lib_mvme) ; \
640 msim : %(lib_sim) ; \
641 mcall-freebsd: %(lib_freebsd) ; \
642 mcall-linux : %(lib_linux) ; \
643 mcall-netbsd : %(lib_netbsd) ; \
644 mcall-openbsd: %(lib_openbsd) ; \
647 #define LIB_DEFAULT_SPEC "-lc"
650 #define ENDFILE_SPEC "\
651 %{mads : %(endfile_ads) ; \
652 myellowknife : %(endfile_yellowknife) ; \
653 mmvme : %(endfile_mvme) ; \
654 msim : %(endfile_sim) ; \
655 mcall-freebsd: %(endfile_freebsd) ; \
656 mcall-linux : %(endfile_linux) ; \
657 mcall-netbsd : %(endfile_netbsd) ; \
658 mcall-openbsd: %(endfile_openbsd) ; \
659 : %(crtsavres_default) %(endfile_default) }"
661 #define CRTSAVRES_DEFAULT_SPEC ""
663 #define ENDFILE_DEFAULT_SPEC "crtend.o%s ecrtn.o%s"
665 /* Motorola ADS support. */
666 #define LIB_ADS_SPEC "--start-group -lads -lc --end-group"
668 #define STARTFILE_ADS_SPEC "ecrti.o%s crt0.o%s crtbegin.o%s"
670 #define ENDFILE_ADS_SPEC "crtend.o%s ecrtn.o%s"
672 #define LINK_START_ADS_SPEC "-T ads.ld%s"
674 #define LINK_OS_ADS_SPEC ""
676 #define CPP_OS_ADS_SPEC ""
678 /* Motorola Yellowknife support. */
679 #define LIB_YELLOWKNIFE_SPEC "--start-group -lyk -lc --end-group"
681 #define STARTFILE_YELLOWKNIFE_SPEC "ecrti.o%s crt0.o%s crtbegin.o%s"
683 #define ENDFILE_YELLOWKNIFE_SPEC "crtend.o%s ecrtn.o%s"
685 #define LINK_START_YELLOWKNIFE_SPEC "-T yellowknife.ld%s"
687 #define LINK_OS_YELLOWKNIFE_SPEC ""
689 #define CPP_OS_YELLOWKNIFE_SPEC ""
691 /* Motorola MVME support. */
692 #define LIB_MVME_SPEC "--start-group -lmvme -lc --end-group"
694 #define STARTFILE_MVME_SPEC "ecrti.o%s crt0.o%s crtbegin.o%s"
696 #define ENDFILE_MVME_SPEC "crtend.o%s ecrtn.o%s"
698 #define LINK_START_MVME_SPEC "-Ttext 0x40000"
700 #define LINK_OS_MVME_SPEC ""
702 #define CPP_OS_MVME_SPEC ""
704 /* PowerPC simulator based on netbsd system calls support. */
705 #define LIB_SIM_SPEC "--start-group -lsim -lc --end-group"
707 #define STARTFILE_SIM_SPEC "ecrti.o%s sim-crt0.o%s crtbegin.o%s"
709 #define ENDFILE_SIM_SPEC "crtend.o%s ecrtn.o%s"
711 #define LINK_START_SIM_SPEC ""
713 #define LINK_OS_SIM_SPEC "-m elf32ppcsim"
715 #define CPP_OS_SIM_SPEC ""
717 /* FreeBSD support. */
719 #define CPP_OS_FREEBSD_SPEC "\
720 -D__PPC__ -D__ppc__ -D__PowerPC__ -D__powerpc__ \
721 -Acpu=powerpc -Amachine=powerpc"
723 #define STARTFILE_FREEBSD_SPEC FBSD_STARTFILE_SPEC
724 #define ENDFILE_FREEBSD_SPEC FBSD_ENDFILE_SPEC
725 #define LIB_FREEBSD_SPEC FBSD_LIB_SPEC
726 #define LINK_START_FREEBSD_SPEC ""
728 #define LINK_OS_FREEBSD_SPEC "\
729 %{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \
731 %{assert*} %{R*} %{rpath*} %{defsym*} \
732 %{shared:-Bshareable %{h*} %{soname*}} \
735 %{rdynamic: -export-dynamic} \
736 -dynamic-linker %(fbsd_dynamic_linker) } \
737 %{static:-Bstatic}} \
738 %{symbolic:-Bsymbolic}"
740 /* GNU/Linux support. */
741 #define LIB_LINUX_SPEC "%{mnewlib: --start-group -llinux -lc --end-group } \
742 %{!mnewlib: %{pthread:-lpthread} %{shared:-lc} \
743 %{!shared: %{profile:-lc_p} %{!profile:-lc}}}"
746 #define STARTFILE_LINUX_SPEC "\
747 %{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
748 %{mnewlib:ecrti.o%s;:crti.o%s} \
749 %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
751 #define STARTFILE_LINUX_SPEC "\
752 %{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
753 %{mnewlib:ecrti.o%s;:crti.o%s} \
754 %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
757 #define ENDFILE_LINUX_SPEC "\
758 %{shared|pie:crtendS.o%s;:crtend.o%s} \
759 %{mnewlib:ecrtn.o%s;:crtn.o%s}"
761 #define LINK_START_LINUX_SPEC ""
763 #define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","")
765 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
766 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
767 #define MUSL_DYNAMIC_LINKER \
768 "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
769 #if DEFAULT_LIBC == LIBC_UCLIBC
770 #define CHOOSE_DYNAMIC_LINKER(G, U, M) \
771 "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
772 #elif DEFAULT_LIBC == LIBC_MUSL
773 #define CHOOSE_DYNAMIC_LINKER(G, U, M) \
774 "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
775 #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
776 #define CHOOSE_DYNAMIC_LINKER(G, U, M) \
777 "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
779 #error "Unsupported DEFAULT_LIBC"
781 #define GNU_USER_DYNAMIC_LINKER \
782 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
785 #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
786 %{rdynamic:-export-dynamic} \
787 -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
789 #if defined(HAVE_LD_EH_FRAME_HDR)
790 # define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
793 #define CPP_OS_LINUX_SPEC "-D__unix__ -D__gnu_linux__ -D__linux__ \
796 %{!std=*:-Dunix -D__unix -Dlinux -D__linux} \
797 %{std=gnu*:-Dunix -D__unix -Dlinux -D__linux}}} \
798 -Asystem=linux -Asystem=unix -Asystem=posix %{pthread:-D_REENTRANT}"
800 /* NetBSD support. */
801 #define LIB_NETBSD_SPEC "\
804 #define STARTFILE_NETBSD_SPEC "\
806 %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
808 #define ENDFILE_NETBSD_SPEC "\
809 %{!shared:crtend.o%s} %{shared:crtendS.o%s} \
812 #define LINK_START_NETBSD_SPEC "\
815 #define LINK_OS_NETBSD_SPEC "\
816 %{!shared: %{!static: \
817 %{rdynamic:-export-dynamic} \
818 -dynamic-linker /usr/libexec/ld.elf_so}}"
820 #define CPP_OS_NETBSD_SPEC "\
821 -D__powerpc__ -D__NetBSD__ -D__KPRINTF_ATTRIBUTE__"
823 /* OpenBSD support. */
824 #ifndef LIB_OPENBSD_SPEC
825 #define LIB_OPENBSD_SPEC "%{!shared:%{pthread:-lpthread%{p:_p}%{!p:%{pg:_p}}}} %{!shared:-lc%{p:_p}%{!p:%{pg:_p}}}"
828 #ifndef STARTFILE_OPENBSD_SPEC
829 #define STARTFILE_OPENBSD_SPEC "\
830 %{!shared: %{pg:gcrt0.o%s} %{!pg:%{p:gcrt0.o%s} %{!p:crt0.o%s}}} \
831 %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
834 #ifndef ENDFILE_OPENBSD_SPEC
835 #define ENDFILE_OPENBSD_SPEC "\
836 %{!shared:crtend.o%s} %{shared:crtendS.o%s}"
839 #ifndef LINK_START_OPENBSD_SPEC
840 #define LINK_START_OPENBSD_SPEC "-Ttext 0x400074"
843 #ifndef LINK_OS_OPENBSD_SPEC
844 #define LINK_OS_OPENBSD_SPEC ""
847 #ifndef CPP_OS_OPENBSD_SPEC
848 #define CPP_OS_OPENBSD_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
851 /* Define any extra SPECS that the compiler needs to generate. */
852 /* Override rs6000.h definition. */
853 #undef SUBTARGET_EXTRA_SPECS
854 #define SUBTARGET_EXTRA_SPECS \
855 { "crtsavres_default", CRTSAVRES_DEFAULT_SPEC }, \
856 { "lib_ads", LIB_ADS_SPEC }, \
857 { "lib_yellowknife", LIB_YELLOWKNIFE_SPEC }, \
858 { "lib_mvme", LIB_MVME_SPEC }, \
859 { "lib_sim", LIB_SIM_SPEC }, \
860 { "lib_freebsd", LIB_FREEBSD_SPEC }, \
861 { "lib_linux", LIB_LINUX_SPEC }, \
862 { "lib_netbsd", LIB_NETBSD_SPEC }, \
863 { "lib_openbsd", LIB_OPENBSD_SPEC }, \
864 { "lib_default", LIB_DEFAULT_SPEC }, \
865 { "startfile_ads", STARTFILE_ADS_SPEC }, \
866 { "startfile_yellowknife", STARTFILE_YELLOWKNIFE_SPEC }, \
867 { "startfile_mvme", STARTFILE_MVME_SPEC }, \
868 { "startfile_sim", STARTFILE_SIM_SPEC }, \
869 { "startfile_freebsd", STARTFILE_FREEBSD_SPEC }, \
870 { "startfile_linux", STARTFILE_LINUX_SPEC }, \
871 { "startfile_netbsd", STARTFILE_NETBSD_SPEC }, \
872 { "startfile_openbsd", STARTFILE_OPENBSD_SPEC }, \
873 { "startfile_default", STARTFILE_DEFAULT_SPEC }, \
874 { "endfile_ads", ENDFILE_ADS_SPEC }, \
875 { "endfile_yellowknife", ENDFILE_YELLOWKNIFE_SPEC }, \
876 { "endfile_mvme", ENDFILE_MVME_SPEC }, \
877 { "endfile_sim", ENDFILE_SIM_SPEC }, \
878 { "endfile_freebsd", ENDFILE_FREEBSD_SPEC }, \
879 { "endfile_linux", ENDFILE_LINUX_SPEC }, \
880 { "endfile_netbsd", ENDFILE_NETBSD_SPEC }, \
881 { "endfile_openbsd", ENDFILE_OPENBSD_SPEC }, \
882 { "endfile_default", ENDFILE_DEFAULT_SPEC }, \
883 { "link_shlib", LINK_SHLIB_SPEC }, \
884 { "link_start", LINK_START_SPEC }, \
885 { "link_start_ads", LINK_START_ADS_SPEC }, \
886 { "link_start_yellowknife", LINK_START_YELLOWKNIFE_SPEC }, \
887 { "link_start_mvme", LINK_START_MVME_SPEC }, \
888 { "link_start_sim", LINK_START_SIM_SPEC }, \
889 { "link_start_freebsd", LINK_START_FREEBSD_SPEC }, \
890 { "link_start_linux", LINK_START_LINUX_SPEC }, \
891 { "link_start_netbsd", LINK_START_NETBSD_SPEC }, \
892 { "link_start_openbsd", LINK_START_OPENBSD_SPEC }, \
893 { "link_start_default", LINK_START_DEFAULT_SPEC }, \
894 { "link_os", LINK_OS_SPEC }, \
895 { "link_os_ads", LINK_OS_ADS_SPEC }, \
896 { "link_os_yellowknife", LINK_OS_YELLOWKNIFE_SPEC }, \
897 { "link_os_mvme", LINK_OS_MVME_SPEC }, \
898 { "link_os_sim", LINK_OS_SIM_SPEC }, \
899 { "link_os_freebsd", LINK_OS_FREEBSD_SPEC }, \
900 { "link_os_linux", LINK_OS_LINUX_SPEC }, \
901 { "link_os_netbsd", LINK_OS_NETBSD_SPEC }, \
902 { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
903 { "link_os_default", LINK_OS_DEFAULT_SPEC }, \
904 { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
905 { "link_secure_plt", LINK_SECURE_PLT_SPEC }, \
906 { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
907 { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
908 { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
909 { "cpp_os_sim", CPP_OS_SIM_SPEC }, \
910 { "cpp_os_freebsd", CPP_OS_FREEBSD_SPEC }, \
911 { "cpp_os_linux", CPP_OS_LINUX_SPEC }, \
912 { "cpp_os_netbsd", CPP_OS_NETBSD_SPEC }, \
913 { "cpp_os_openbsd", CPP_OS_OPENBSD_SPEC }, \
914 { "cpp_os_default", CPP_OS_DEFAULT_SPEC }, \
915 { "fbsd_dynamic_linker", FBSD_DYNAMIC_LINKER }, \
916 SUBSUBTARGET_EXTRA_SPECS
918 #define SUBSUBTARGET_EXTRA_SPECS
920 /* Define this macro as a C expression for the initializer of an
921 array of string to tell the driver program which options are
922 defaults for this target and thus do not need to be handled
923 specially when using `MULTILIB_OPTIONS'.
925 Do not define this macro if `MULTILIB_OPTIONS' is not defined in
926 the target makefile fragment or if none of the options listed in
927 `MULTILIB_OPTIONS' are set by default. *Note Target Fragment::. */
929 #define MULTILIB_DEFAULTS { "mbig", "mcall-sysv" }
931 /* Define this macro if the code for function profiling should come
932 before the function prologue. Normally, the profiling code comes
934 #define PROFILE_BEFORE_PROLOGUE 1
936 /* Function name to call to do profiling. */
937 #define RS6000_MCOUNT "_mcount"
939 /* Select a format to encode pointers in exception handling data. CODE
940 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
941 true if the symbol may be affected by dynamic relocations. */
942 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
943 ((flag_pic || TARGET_RELOCATABLE) \
944 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4) \
947 #define DOUBLE_INT_ASM_OP "\t.quad\t"
949 /* Generate entries in .fixup for relocatable addresses. */
950 #define RELOCATABLE_NEEDS_FIXUP 1
952 #define TARGET_ASM_FILE_END rs6000_elf_file_end
954 #undef TARGET_ASAN_SHADOW_OFFSET
955 #define TARGET_ASAN_SHADOW_OFFSET rs6000_asan_shadow_offset
957 /* This target uses the sysv4.opt file. */
958 #define TARGET_USES_SYSV4_OPT 1
960 /* Include order changes for musl, same as in generic linux.h. */
961 #if DEFAULT_LIBC == LIBC_MUSL
962 #define INCLUDE_DEFAULTS_MUSL_GPP \
963 { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
964 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
965 { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
966 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
967 { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
968 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
970 #ifdef LOCAL_INCLUDE_DIR
971 #define INCLUDE_DEFAULTS_MUSL_LOCAL \
972 { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
973 { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
975 #define INCLUDE_DEFAULTS_MUSL_LOCAL
978 #ifdef PREFIX_INCLUDE_DIR
979 #define INCLUDE_DEFAULTS_MUSL_PREFIX \
980 { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
982 #define INCLUDE_DEFAULTS_MUSL_PREFIX
985 #ifdef CROSS_INCLUDE_DIR
986 #define INCLUDE_DEFAULTS_MUSL_CROSS \
987 { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
989 #define INCLUDE_DEFAULTS_MUSL_CROSS
992 #ifdef TOOL_INCLUDE_DIR
993 #define INCLUDE_DEFAULTS_MUSL_TOOL \
994 { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
996 #define INCLUDE_DEFAULTS_MUSL_TOOL
999 #ifdef NATIVE_SYSTEM_HEADER_DIR
1000 #define INCLUDE_DEFAULTS_MUSL_NATIVE \
1001 { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
1002 { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
1004 #define INCLUDE_DEFAULTS_MUSL_NATIVE
1007 #if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
1008 # undef INCLUDE_DEFAULTS_MUSL_LOCAL
1009 # define INCLUDE_DEFAULTS_MUSL_LOCAL
1010 # undef INCLUDE_DEFAULTS_MUSL_NATIVE
1011 # define INCLUDE_DEFAULTS_MUSL_NATIVE
1013 # undef INCLUDE_DEFAULTS_MUSL_CROSS
1014 # define INCLUDE_DEFAULTS_MUSL_CROSS
1017 #undef INCLUDE_DEFAULTS
1018 #define INCLUDE_DEFAULTS \
1020 INCLUDE_DEFAULTS_MUSL_GPP \
1021 INCLUDE_DEFAULTS_MUSL_LOCAL \
1022 INCLUDE_DEFAULTS_MUSL_PREFIX \
1023 INCLUDE_DEFAULTS_MUSL_CROSS \
1024 INCLUDE_DEFAULTS_MUSL_TOOL \
1025 INCLUDE_DEFAULTS_MUSL_NATIVE \
1026 { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
1027 { 0, 0, 0, 0, 0, 0 } \