1 /* Target definitions for GNU compiler for PowerPC running System V.4 2 Copyright (C) 1995-2014 Free Software Foundation, Inc. 3 Contributed by Cygnus Support. 4 5 This file is part of GCC. 6 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. 11 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. 16 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. 20 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/>. */ 25 26 /* Header files should be C++ aware in general. */ 27 #undef NO_IMPLICIT_EXTERN_C 28 #define NO_IMPLICIT_EXTERN_C 29 30 /* Yes! We are ELF. */ 31 #define TARGET_OBJECT_FORMAT OBJECT_ELF 32 33 /* Default ABI to compile code for. */ 34 #define DEFAULT_ABI rs6000_current_abi 35 36 /* Default ABI to use. */ 37 #define RS6000_ABI_NAME "sysv" 38 39 /* Override rs6000.h definition. */ 40 #undef ASM_DEFAULT_SPEC 41 #define ASM_DEFAULT_SPEC "-mppc" 42 43 #define TARGET_TOC ((rs6000_isa_flags & OPTION_MASK_64BIT) \ 44 || ((rs6000_isa_flags \ 45 & (OPTION_MASK_RELOCATABLE \ 46 | OPTION_MASK_MINIMAL_TOC)) \ 47 && flag_pic > 1) \ 48 || DEFAULT_ABI != ABI_V4) 49 50 #define TARGET_BITFIELD_TYPE (! TARGET_NO_BITFIELD_TYPE) 51 #define TARGET_BIG_ENDIAN (! TARGET_LITTLE_ENDIAN) 52 #define TARGET_PROTOTYPE target_prototype 53 #define TARGET_NO_PROTOTYPE (! TARGET_PROTOTYPE) 54 #define TARGET_NO_TOC (! TARGET_TOC) 55 #define TARGET_NO_EABI (! TARGET_EABI) 56 #define TARGET_REGNAMES rs6000_regnames 57 58 #ifdef HAVE_AS_REL16 59 #undef TARGET_SECURE_PLT 60 #define TARGET_SECURE_PLT secure_plt 61 #endif 62 63 #define SDATA_DEFAULT_SIZE 8 64 65 /* The macro SUBTARGET_OVERRIDE_OPTIONS is provided for subtargets, to 66 get control in TARGET_OPTION_OVERRIDE. */ 67 68 #define SUBTARGET_OVERRIDE_OPTIONS \ 69 do { \ 70 if (!global_options_set.x_g_switch_value) \ 71 g_switch_value = SDATA_DEFAULT_SIZE; \ 72 \ 73 if (rs6000_abi_name == NULL) \ 74 rs6000_abi_name = RS6000_ABI_NAME; \ 75 \ 76 if (!strcmp (rs6000_abi_name, "sysv")) \ 77 rs6000_current_abi = ABI_V4; \ 78 else if (!strcmp (rs6000_abi_name, "sysv-noeabi")) \ 79 { \ 80 rs6000_current_abi = ABI_V4; \ 81 rs6000_isa_flags &= ~ OPTION_MASK_EABI; \ 82 } \ 83 else if (!strcmp (rs6000_abi_name, "sysv-eabi") \ 84 || !strcmp (rs6000_abi_name, "eabi")) \ 85 { \ 86 rs6000_current_abi = ABI_V4; \ 87 rs6000_isa_flags |= OPTION_MASK_EABI; \ 88 } \ 89 else if (!strcmp (rs6000_abi_name, "aixdesc")) \ 90 rs6000_current_abi = ABI_AIX; \ 91 else if (!strcmp (rs6000_abi_name, "freebsd") \ 92 || !strcmp (rs6000_abi_name, "linux")) \ 93 { \ 94 if (TARGET_64BIT) \ 95 rs6000_current_abi = ABI_AIX; \ 96 else \ 97 rs6000_current_abi = ABI_V4; \ 98 } \ 99 else if (!strcmp (rs6000_abi_name, "netbsd")) \ 100 rs6000_current_abi = ABI_V4; \ 101 else if (!strcmp (rs6000_abi_name, "openbsd")) \ 102 rs6000_current_abi = ABI_V4; \ 103 else if (!strcmp (rs6000_abi_name, "i960-old")) \ 104 { \ 105 rs6000_current_abi = ABI_V4; \ 106 rs6000_isa_flags |= (OPTION_MASK_LITTLE_ENDIAN | OPTION_MASK_EABI); \ 107 rs6000_isa_flags &= ~OPTION_MASK_STRICT_ALIGN; \ 108 TARGET_NO_BITFIELD_WORD = 1; \ 109 } \ 110 else \ 111 { \ 112 rs6000_current_abi = ABI_V4; \ 113 error ("bad value for -mcall-%s", rs6000_abi_name); \ 114 } \ 115 \ 116 if (rs6000_sdata_name) \ 117 { \ 118 if (!strcmp (rs6000_sdata_name, "none")) \ 119 rs6000_sdata = SDATA_NONE; \ 120 else if (!strcmp (rs6000_sdata_name, "data")) \ 121 rs6000_sdata = SDATA_DATA; \ 122 else if (!strcmp (rs6000_sdata_name, "default")) \ 123 rs6000_sdata = (TARGET_EABI) ? SDATA_EABI : SDATA_SYSV; \ 124 else if (!strcmp (rs6000_sdata_name, "sysv")) \ 125 rs6000_sdata = SDATA_SYSV; \ 126 else if (!strcmp (rs6000_sdata_name, "eabi")) \ 127 rs6000_sdata = SDATA_EABI; \ 128 else \ 129 error ("bad value for -msdata=%s", rs6000_sdata_name); \ 130 } \ 131 else if (DEFAULT_ABI == ABI_V4) \ 132 { \ 133 rs6000_sdata = SDATA_DATA; \ 134 rs6000_sdata_name = "data"; \ 135 } \ 136 else \ 137 { \ 138 rs6000_sdata = SDATA_NONE; \ 139 rs6000_sdata_name = "none"; \ 140 } \ 141 \ 142 if (TARGET_RELOCATABLE && \ 143 (rs6000_sdata == SDATA_EABI || rs6000_sdata == SDATA_SYSV)) \ 144 { \ 145 rs6000_sdata = SDATA_DATA; \ 146 error ("-mrelocatable and -msdata=%s are incompatible", \ 147 rs6000_sdata_name); \ 148 } \ 149 \ 150 else if (flag_pic && DEFAULT_ABI == ABI_V4 \ 151 && (rs6000_sdata == SDATA_EABI \ 152 || rs6000_sdata == SDATA_SYSV)) \ 153 { \ 154 rs6000_sdata = SDATA_DATA; \ 155 error ("-f%s and -msdata=%s are incompatible", \ 156 (flag_pic > 1) ? "PIC" : "pic", \ 157 rs6000_sdata_name); \ 158 } \ 159 \ 160 if ((rs6000_sdata != SDATA_NONE && DEFAULT_ABI != ABI_V4) \ 161 || (rs6000_sdata == SDATA_EABI && !TARGET_EABI)) \ 162 { \ 163 rs6000_sdata = SDATA_NONE; \ 164 error ("-msdata=%s and -mcall-%s are incompatible", \ 165 rs6000_sdata_name, rs6000_abi_name); \ 166 } \ 167 \ 168 targetm.have_srodata_section = rs6000_sdata == SDATA_EABI; \ 169 \ 170 if (TARGET_RELOCATABLE && !TARGET_MINIMAL_TOC) \ 171 { \ 172 rs6000_isa_flags |= OPTION_MASK_MINIMAL_TOC; \ 173 error ("-mrelocatable and -mno-minimal-toc are incompatible"); \ 174 } \ 175 \ 176 if (TARGET_RELOCATABLE && rs6000_current_abi != ABI_V4) \ 177 { \ 178 rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \ 179 error ("-mrelocatable and -mcall-%s are incompatible", \ 180 rs6000_abi_name); \ 181 } \ 182 \ 183 if (!TARGET_64BIT && flag_pic > 1 && rs6000_current_abi != ABI_V4) \ 184 { \ 185 flag_pic = 0; \ 186 error ("-fPIC and -mcall-%s are incompatible", \ 187 rs6000_abi_name); \ 188 } \ 189 \ 190 if (TARGET_SECURE_PLT != secure_plt) \ 191 { \ 192 error ("-msecure-plt not supported by your assembler"); \ 193 } \ 194 \ 195 /* Treat -fPIC the same as -mrelocatable. */ \ 196 if (flag_pic > 1 && DEFAULT_ABI == ABI_V4) \ 197 { \ 198 rs6000_isa_flags |= OPTION_MASK_RELOCATABLE | OPTION_MASK_MINIMAL_TOC; \ 199 TARGET_NO_FP_IN_TOC = 1; \ 200 } \ 201 \ 202 else if (TARGET_RELOCATABLE) \ 203 if (!flag_pic) \ 204 flag_pic = 2; \ 205 } while (0) 206 207 #ifndef RS6000_BI_ARCH 208 # define SUBSUBTARGET_OVERRIDE_OPTIONS \ 209 do { \ 210 if ((TARGET_DEFAULT ^ rs6000_isa_flags) & OPTION_MASK_64BIT) \ 211 error ("-m%s not supported in this configuration", \ 212 (rs6000_isa_flags & OPTION_MASK_64BIT) ? "64" : "32"); \ 213 } while (0) 214 #endif 215 216 /* Override rs6000.h definition. */ 217 #undef TARGET_DEFAULT 218 #define TARGET_DEFAULT 0 219 220 /* Override rs6000.h definition. */ 221 #undef PROCESSOR_DEFAULT 222 #define PROCESSOR_DEFAULT PROCESSOR_PPC750 223 224 #define FIXED_R2 1 225 /* System V.4 uses register 13 as a pointer to the small data area, 226 so it is not available to the normal user. */ 227 #define FIXED_R13 1 228 229 /* Override default big endianism definitions in rs6000.h. */ 230 #undef BYTES_BIG_ENDIAN 231 #undef WORDS_BIG_ENDIAN 232 #define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN) 233 #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN) 234 235 /* Put jump tables in read-only memory, rather than in .text. */ 236 #define JUMP_TABLES_IN_TEXT_SECTION 0 237 238 /* Prefix and suffix to use to saving floating point. */ 239 #define SAVE_FP_PREFIX "_savefpr_" 240 #define SAVE_FP_SUFFIX "" 241 242 /* Prefix and suffix to use to restoring floating point. */ 243 #define RESTORE_FP_PREFIX "_restfpr_" 244 #define RESTORE_FP_SUFFIX "" 245 246 /* Type used for size_t, as a string used in a declaration. */ 247 #undef SIZE_TYPE 248 #define SIZE_TYPE "unsigned int" 249 250 /* Type used for ptrdiff_t, as a string used in a declaration. */ 251 #define PTRDIFF_TYPE "int" 252 253 #undef WCHAR_TYPE 254 #define WCHAR_TYPE "long int" 255 256 #undef WCHAR_TYPE_SIZE 257 #define WCHAR_TYPE_SIZE 32 258 259 /* Make int foo : 8 not cause structures to be aligned to an int boundary. */ 260 /* Override elfos.h definition. */ 261 #undef PCC_BITFIELD_TYPE_MATTERS 262 #define PCC_BITFIELD_TYPE_MATTERS (TARGET_BITFIELD_TYPE) 263 264 #undef BITFIELD_NBYTES_LIMITED 265 #define BITFIELD_NBYTES_LIMITED (TARGET_NO_BITFIELD_WORD) 266 267 /* Define this macro to be the value 1 if instructions will fail to 268 work if given data not on the nominal alignment. If instructions 269 will merely go slower in that case, define this macro as 0. */ 270 #undef STRICT_ALIGNMENT 271 #define STRICT_ALIGNMENT (TARGET_STRICT_ALIGN) 272 273 /* Define this macro if you wish to preserve a certain alignment for 274 the stack pointer, greater than what the hardware enforces. The 275 definition is a C expression for the desired alignment (measured 276 in bits). This macro must evaluate to a value equal to or larger 277 than STACK_BOUNDARY. 278 For the SYSV ABI and variants the alignment of the stack pointer 279 is usually controlled manually in rs6000.c. However, to maintain 280 alignment across alloca () in all circumstances, 281 PREFERRED_STACK_BOUNDARY needs to be set as well. 282 This has the additional advantage of allowing a bigger maximum 283 alignment of user objects on the stack. */ 284 285 #undef PREFERRED_STACK_BOUNDARY 286 #define PREFERRED_STACK_BOUNDARY 128 287 288 /* Real stack boundary as mandated by the appropriate ABI. */ 289 #define ABI_STACK_BOUNDARY \ 290 ((TARGET_EABI && !TARGET_ALTIVEC && !TARGET_ALTIVEC_ABI) ? 64 : 128) 291 292 /* An expression for the alignment of a structure field FIELD if the 293 alignment computed in the usual way is COMPUTED. */ 294 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ 295 (rs6000_special_adjust_field_align_p ((FIELD), (COMPUTED)) \ 296 ? 128 : COMPUTED) 297 298 #undef BIGGEST_FIELD_ALIGNMENT 299 300 /* Use ELF style section commands. */ 301 302 #define TEXT_SECTION_ASM_OP "\t.section\t\".text\"" 303 304 #define DATA_SECTION_ASM_OP "\t.section\t\".data\"" 305 306 #define BSS_SECTION_ASM_OP "\t.section\t\".bss\"" 307 308 /* Override elfos.h definition. */ 309 #undef INIT_SECTION_ASM_OP 310 #define INIT_SECTION_ASM_OP "\t.section\t\".init\",\"ax\"" 311 312 /* Override elfos.h definition. */ 313 #undef FINI_SECTION_ASM_OP 314 #define FINI_SECTION_ASM_OP "\t.section\t\".fini\",\"ax\"" 315 316 #define TOC_SECTION_ASM_OP "\t.section\t\".got\",\"aw\"" 317 318 /* Put PC relative got entries in .got2. */ 319 #define MINIMAL_TOC_SECTION_ASM_OP \ 320 (TARGET_RELOCATABLE || (flag_pic && DEFAULT_ABI == ABI_V4) \ 321 ? "\t.section\t\".got2\",\"aw\"" : "\t.section\t\".got1\",\"aw\"") 322 323 #define SDATA_SECTION_ASM_OP "\t.section\t\".sdata\",\"aw\"" 324 #define SDATA2_SECTION_ASM_OP "\t.section\t\".sdata2\",\"a\"" 325 #define SBSS_SECTION_ASM_OP "\t.section\t\".sbss\",\"aw\",@nobits" 326 327 /* Override default elf definitions. */ 328 #define TARGET_ASM_INIT_SECTIONS rs6000_elf_asm_init_sections 329 #undef TARGET_ASM_RELOC_RW_MASK 330 #define TARGET_ASM_RELOC_RW_MASK rs6000_elf_reloc_rw_mask 331 #undef TARGET_ASM_SELECT_RTX_SECTION 332 #define TARGET_ASM_SELECT_RTX_SECTION rs6000_elf_select_rtx_section 333 334 /* Return nonzero if this entry is to be written into the constant pool 335 in a special way. We do so if this is a SYMBOL_REF, LABEL_REF or a CONST 336 containing one of them. If -mfp-in-toc (the default), we also do 337 this for floating-point constants. We actually can only do this 338 if the FP formats of the target and host machines are the same, but 339 we can't check that since not every file that uses these target macros 340 includes real.h. 341 342 Unlike AIX, we don't key off of -mminimal-toc, but instead do not 343 allow floating point constants in the TOC if -mrelocatable. */ 344 345 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P 346 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \ 347 (TARGET_TOC \ 348 && (GET_CODE (X) == SYMBOL_REF \ 349 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \ 350 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \ 351 || GET_CODE (X) == LABEL_REF \ 352 || (GET_CODE (X) == CONST_INT \ 353 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \ 354 || (!TARGET_NO_FP_IN_TOC \ 355 && !TARGET_RELOCATABLE \ 356 && GET_CODE (X) == CONST_DOUBLE \ 357 && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \ 358 && BITS_PER_WORD == HOST_BITS_PER_INT))) 359 360 /* These macros generate the special .type and .size directives which 361 are used to set the corresponding fields of the linker symbol table 362 entries in an ELF object file under SVR4. These macros also output 363 the starting labels for the relevant functions/objects. */ 364 365 /* Write the extra assembler code needed to declare a function properly. 366 Some svr4 assemblers need to also have something extra said about the 367 function's return value. We allow for that here. */ 368 369 /* Override elfos.h definition. */ 370 #undef ASM_DECLARE_FUNCTION_NAME 371 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ 372 rs6000_elf_declare_function_name ((FILE), (NAME), (DECL)) 373 374 /* The USER_LABEL_PREFIX stuff is affected by the -fleading-underscore 375 flag. The LOCAL_LABEL_PREFIX variable is used by dbxelf.h. */ 376 377 #define LOCAL_LABEL_PREFIX "." 378 #define USER_LABEL_PREFIX "" 379 380 #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX) \ 381 asm_fprintf (FILE, "%L%s", PREFIX) 382 383 /* Globalizing directive for a label. */ 384 #define GLOBAL_ASM_OP "\t.globl " 385 386 /* This says how to output assembler code to declare an 387 uninitialized internal linkage data object. Under SVR4, 388 the linker seems to want the alignment of data objects 389 to depend on their types. We do exactly that here. */ 390 391 #define LOCAL_ASM_OP "\t.local\t" 392 393 #define LCOMM_ASM_OP "\t.lcomm\t" 394 395 /* Describe how to emit uninitialized local items. */ 396 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \ 397 do { \ 398 if ((DECL) && rs6000_elf_in_small_data_p (DECL)) \ 399 { \ 400 switch_to_section (sbss_section); \ 401 ASM_OUTPUT_ALIGN (FILE, exact_log2 (ALIGN / BITS_PER_UNIT)); \ 402 ASM_OUTPUT_LABEL (FILE, NAME); \ 403 ASM_OUTPUT_SKIP (FILE, SIZE); \ 404 if (!flag_inhibit_size_directive && (SIZE) > 0) \ 405 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \ 406 } \ 407 else \ 408 { \ 409 fprintf (FILE, "%s", LCOMM_ASM_OP); \ 410 assemble_name ((FILE), (NAME)); \ 411 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \ 412 (SIZE), (ALIGN) / BITS_PER_UNIT); \ 413 } \ 414 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \ 415 } while (0) 416 417 /* Describe how to emit uninitialized external linkage items. */ 418 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 419 do { \ 420 ASM_OUTPUT_ALIGNED_DECL_LOCAL (FILE, DECL, NAME, SIZE, ALIGN); \ 421 } while (0) 422 423 #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN 424 /* To support -falign-* switches we need to use .p2align so 425 that alignment directives in code sections will be padded 426 with no-op instructions, rather than zeroes. */ 427 #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ 428 if ((LOG) != 0) \ 429 { \ 430 if ((MAX_SKIP) == 0) \ 431 fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ 432 else \ 433 fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ 434 } 435 #endif 436 437 /* This is how to output code to push a register on the stack. 438 It need not be very fast code. 439 440 On the rs6000, we must keep the backchain up to date. In order 441 to simplify things, always allocate 16 bytes for a push (System V 442 wants to keep stack aligned to a 16 byte boundary). */ 443 444 #define ASM_OUTPUT_REG_PUSH(FILE, REGNO) \ 445 do { \ 446 if (DEFAULT_ABI == ABI_V4) \ 447 asm_fprintf (FILE, \ 448 "\tstwu %s,-16(%s)\n\tstw %s,12(%s)\n", \ 449 reg_names[1], reg_names[1], reg_names[REGNO], \ 450 reg_names[1]); \ 451 } while (0) 452 453 /* This is how to output an insn to pop a register from the stack. 454 It need not be very fast code. */ 455 456 #define ASM_OUTPUT_REG_POP(FILE, REGNO) \ 457 do { \ 458 if (DEFAULT_ABI == ABI_V4) \ 459 asm_fprintf (FILE, \ 460 "\tlwz %s,12(%s)\n\taddic %s,%s,16\n", \ 461 reg_names[REGNO], reg_names[1], reg_names[1], \ 462 reg_names[1]); \ 463 } while (0) 464 465 extern int fixuplabelno; 466 467 /* Handle constructors specially for -mrelocatable. */ 468 #define TARGET_ASM_CONSTRUCTOR rs6000_elf_asm_out_constructor 469 #define TARGET_ASM_DESTRUCTOR rs6000_elf_asm_out_destructor 470 471 /* This is the end of what might become sysv4.h. */ 472 473 /* Use DWARF 2 debugging information by default. */ 474 #undef PREFERRED_DEBUGGING_TYPE 475 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG 476 477 /* Historically we have also supported stabs debugging. */ 478 #define DBX_DEBUGGING_INFO 1 479 480 #define TARGET_ENCODE_SECTION_INFO rs6000_elf_encode_section_info 481 #define TARGET_IN_SMALL_DATA_P rs6000_elf_in_small_data_p 482 483 /* The ELF version doesn't encode [DS] or whatever at the end of symbols. */ 484 485 #define RS6000_OUTPUT_BASENAME(FILE, NAME) \ 486 assemble_name (FILE, NAME) 487 488 /* We have to output the stabs for the function name *first*, before 489 outputting its label. */ 490 491 #define DBX_FUNCTION_FIRST 492 493 /* This is the end of what might become sysv4dbx.h. */ 494 495 #define TARGET_OS_SYSV_CPP_BUILTINS() \ 496 do \ 497 { \ 498 if (rs6000_isa_flags_explicit \ 499 & OPTION_MASK_RELOCATABLE) \ 500 builtin_define ("_RELOCATABLE"); \ 501 } \ 502 while (0) 503 504 #ifndef TARGET_OS_CPP_BUILTINS 505 #define TARGET_OS_CPP_BUILTINS() \ 506 do \ 507 { \ 508 builtin_define_std ("PPC"); \ 509 builtin_define_std ("unix"); \ 510 builtin_define ("__svr4__"); \ 511 builtin_assert ("system=unix"); \ 512 builtin_assert ("system=svr4"); \ 513 builtin_assert ("cpu=powerpc"); \ 514 builtin_assert ("machine=powerpc"); \ 515 TARGET_OS_SYSV_CPP_BUILTINS (); \ 516 } \ 517 while (0) 518 #endif 519 520 /* Select one of BIG_OPT, LITTLE_OPT or DEFAULT_OPT depending 521 on various -mbig, -mlittle and -mcall- options. */ 522 #define ENDIAN_SELECT(BIG_OPT, LITTLE_OPT, DEFAULT_OPT) \ 523 "%{mlittle|mlittle-endian:" LITTLE_OPT ";" \ 524 "mbig|mbig-endian:" BIG_OPT ";" \ 525 "mcall-i960-old:" LITTLE_OPT ";" \ 526 ":" DEFAULT_OPT "}" 527 528 #define DEFAULT_ASM_ENDIAN " -mbig" 529 530 #undef ASM_SPEC 531 #define ASM_SPEC "%(asm_cpu) \ 532 %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}} \ 533 %{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} \ 534 %{memb|msdata=eabi: -memb}" \ 535 ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) 536 537 #ifndef CC1_SECURE_PLT_DEFAULT_SPEC 538 #define CC1_SECURE_PLT_DEFAULT_SPEC "" 539 #endif 540 541 /* Pass -G xxx to the compiler. */ 542 #define CC1_SPEC "%{G*} %(cc1_cpu)" \ 543 "%{meabi: %{!mcall-*: -mcall-sysv }} \ 544 %{!meabi: %{!mno-eabi: \ 545 %{mrelocatable: -meabi } \ 546 %{mcall-freebsd: -mno-eabi } \ 547 %{mcall-i960-old: -meabi } \ 548 %{mcall-linux: -mno-eabi } \ 549 %{mcall-netbsd: -mno-eabi } \ 550 %{mcall-openbsd: -mno-eabi }}} \ 551 %{msdata: -msdata=default} \ 552 %{mno-sdata: -msdata=none} \ 553 %{!mbss-plt: %{!msecure-plt: %(cc1_secure_plt_default)}} \ 554 %{profile: -p}" 555 556 /* Default starting address if specified. */ 557 #define LINK_START_SPEC "\ 558 %{mads : %(link_start_ads) ; \ 559 myellowknife : %(link_start_yellowknife) ; \ 560 mmvme : %(link_start_mvme) ; \ 561 msim : %(link_start_sim) ; \ 562 mcall-freebsd: %(link_start_freebsd) ; \ 563 mcall-linux : %(link_start_linux) ; \ 564 mcall-netbsd : %(link_start_netbsd) ; \ 565 mcall-openbsd: %(link_start_openbsd) ; \ 566 : %(link_start_default) }" 567 568 #define LINK_START_DEFAULT_SPEC "" 569 570 #undef LINK_SPEC 571 #define LINK_SPEC "\ 572 %{h*} %{v:-V} %{!msdata=none:%{G*}} %{msdata=none:-G0} \ 573 %{R*} \ 574 %(link_shlib) \ 575 %{!T*: %(link_start) } \ 576 %(link_target) \ 577 %(link_os)" 578 579 /* Shared libraries are not default. */ 580 #define LINK_SHLIB_SPEC "\ 581 %{!mshlib: %{!shared: %{!symbolic: -dn -Bstatic}}} \ 582 %{static: } \ 583 %{shared:-G -dy -z text } \ 584 %{symbolic:-Bsymbolic -G -dy -z text }" 585 586 /* Override the default target of the linker. */ 587 #define LINK_TARGET_SPEC \ 588 ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") 589 590 /* Any specific OS flags. */ 591 #define LINK_OS_SPEC "\ 592 %{mads : %(link_os_ads) ; \ 593 myellowknife : %(link_os_yellowknife) ; \ 594 mmvme : %(link_os_mvme) ; \ 595 msim : %(link_os_sim) ; \ 596 mcall-freebsd: %(link_os_freebsd) ; \ 597 mcall-linux : %(link_os_linux) ; \ 598 mcall-netbsd : %(link_os_netbsd) ; \ 599 mcall-openbsd: %(link_os_openbsd) ; \ 600 : %(link_os_default) }" 601 602 #define LINK_OS_DEFAULT_SPEC "" 603 604 #define DRIVER_SELF_SPECS "%{mfpu=none: %<mfpu=* \ 605 %<msingle-float %<mdouble-float}" 606 607 /* Override rs6000.h definition. */ 608 #undef CPP_SPEC 609 #define CPP_SPEC "%{posix: -D_POSIX_SOURCE} \ 610 %{mads : %(cpp_os_ads) ; \ 611 myellowknife : %(cpp_os_yellowknife) ; \ 612 mmvme : %(cpp_os_mvme) ; \ 613 msim : %(cpp_os_sim) ; \ 614 mcall-freebsd: %(cpp_os_freebsd) ; \ 615 mcall-linux : %(cpp_os_linux) ; \ 616 mcall-netbsd : %(cpp_os_netbsd) ; \ 617 mcall-openbsd: %(cpp_os_openbsd) ; \ 618 : %(cpp_os_default) }" 619 620 #define CPP_OS_DEFAULT_SPEC "" 621 622 #undef STARTFILE_SPEC 623 #define STARTFILE_SPEC "\ 624 %{mads : %(startfile_ads) ; \ 625 myellowknife : %(startfile_yellowknife) ; \ 626 mmvme : %(startfile_mvme) ; \ 627 msim : %(startfile_sim) ; \ 628 mcall-freebsd: %(startfile_freebsd) ; \ 629 mcall-linux : %(startfile_linux) ; \ 630 mcall-netbsd : %(startfile_netbsd) ; \ 631 mcall-openbsd: %(startfile_openbsd) ; \ 632 : %(startfile_default) }" 633 634 #define STARTFILE_DEFAULT_SPEC "ecrti.o%s crtbegin.o%s" 635 636 #undef LIB_SPEC 637 #define LIB_SPEC "\ 638 %{mads : %(lib_ads) ; \ 639 myellowknife : %(lib_yellowknife) ; \ 640 mmvme : %(lib_mvme) ; \ 641 msim : %(lib_sim) ; \ 642 mcall-freebsd: %(lib_freebsd) ; \ 643 mcall-linux : %(lib_linux) ; \ 644 mcall-netbsd : %(lib_netbsd) ; \ 645 mcall-openbsd: %(lib_openbsd) ; \ 646 : %(lib_default) }" 647 648 #define LIB_DEFAULT_SPEC "-lc" 649 650 #undef ENDFILE_SPEC 651 #define ENDFILE_SPEC "\ 652 %{mads : %(endfile_ads) ; \ 653 myellowknife : %(endfile_yellowknife) ; \ 654 mmvme : %(endfile_mvme) ; \ 655 msim : %(endfile_sim) ; \ 656 mcall-freebsd: %(endfile_freebsd) ; \ 657 mcall-linux : %(endfile_linux) ; \ 658 mcall-netbsd : %(endfile_netbsd) ; \ 659 mcall-openbsd: %(endfile_openbsd) ; \ 660 : %(crtsavres_default) %(endfile_default) }" 661 662 #define CRTSAVRES_DEFAULT_SPEC "" 663 664 #define ENDFILE_DEFAULT_SPEC "crtend.o%s ecrtn.o%s" 665 666 /* Motorola ADS support. */ 667 #define LIB_ADS_SPEC "--start-group -lads -lc --end-group" 668 669 #define STARTFILE_ADS_SPEC "ecrti.o%s crt0.o%s crtbegin.o%s" 670 671 #define ENDFILE_ADS_SPEC "crtend.o%s ecrtn.o%s" 672 673 #define LINK_START_ADS_SPEC "-T ads.ld%s" 674 675 #define LINK_OS_ADS_SPEC "" 676 677 #define CPP_OS_ADS_SPEC "" 678 679 /* Motorola Yellowknife support. */ 680 #define LIB_YELLOWKNIFE_SPEC "--start-group -lyk -lc --end-group" 681 682 #define STARTFILE_YELLOWKNIFE_SPEC "ecrti.o%s crt0.o%s crtbegin.o%s" 683 684 #define ENDFILE_YELLOWKNIFE_SPEC "crtend.o%s ecrtn.o%s" 685 686 #define LINK_START_YELLOWKNIFE_SPEC "-T yellowknife.ld%s" 687 688 #define LINK_OS_YELLOWKNIFE_SPEC "" 689 690 #define CPP_OS_YELLOWKNIFE_SPEC "" 691 692 /* Motorola MVME support. */ 693 #define LIB_MVME_SPEC "--start-group -lmvme -lc --end-group" 694 695 #define STARTFILE_MVME_SPEC "ecrti.o%s crt0.o%s crtbegin.o%s" 696 697 #define ENDFILE_MVME_SPEC "crtend.o%s ecrtn.o%s" 698 699 #define LINK_START_MVME_SPEC "-Ttext 0x40000" 700 701 #define LINK_OS_MVME_SPEC "" 702 703 #define CPP_OS_MVME_SPEC "" 704 705 /* PowerPC simulator based on netbsd system calls support. */ 706 #define LIB_SIM_SPEC "--start-group -lsim -lc --end-group" 707 708 #define STARTFILE_SIM_SPEC "ecrti.o%s sim-crt0.o%s crtbegin.o%s" 709 710 #define ENDFILE_SIM_SPEC "crtend.o%s ecrtn.o%s" 711 712 #define LINK_START_SIM_SPEC "" 713 714 #define LINK_OS_SIM_SPEC "-m elf32ppcsim" 715 716 #define CPP_OS_SIM_SPEC "" 717 718 /* FreeBSD support. */ 719 720 #define CPP_OS_FREEBSD_SPEC "\ 721 -D__PPC__ -D__ppc__ -D__PowerPC__ -D__powerpc__ \ 722 -Acpu=powerpc -Amachine=powerpc" 723 724 #define STARTFILE_FREEBSD_SPEC FBSD_STARTFILE_SPEC 725 #define ENDFILE_FREEBSD_SPEC FBSD_ENDFILE_SPEC 726 #define LIB_FREEBSD_SPEC FBSD_LIB_SPEC 727 #define LINK_START_FREEBSD_SPEC "" 728 729 #define LINK_OS_FREEBSD_SPEC "\ 730 %{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \ 731 %{v:-V} \ 732 %{assert*} %{R*} %{rpath*} %{defsym*} \ 733 %{shared:-Bshareable %{h*} %{soname*}} \ 734 %{!shared: \ 735 %{!static: \ 736 %{rdynamic: -export-dynamic} \ 737 -dynamic-linker %(fbsd_dynamic_linker) } \ 738 %{static:-Bstatic}} \ 739 %{symbolic:-Bsymbolic}" 740 741 /* GNU/Linux support. */ 742 #define LIB_LINUX_SPEC "%{mnewlib: --start-group -llinux -lc --end-group } \ 743 %{!mnewlib: %{pthread:-lpthread} %{shared:-lc} \ 744 %{!shared: %{profile:-lc_p} %{!profile:-lc}}}" 745 746 #ifdef HAVE_LD_PIE 747 #define STARTFILE_LINUX_SPEC "\ 748 %{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \ 749 %{mnewlib:ecrti.o%s;:crti.o%s} \ 750 %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" 751 #else 752 #define STARTFILE_LINUX_SPEC "\ 753 %{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \ 754 %{mnewlib:ecrti.o%s;:crti.o%s} \ 755 %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" 756 #endif 757 758 #define ENDFILE_LINUX_SPEC "\ 759 %{shared|pie:crtendS.o%s;:crtend.o%s} \ 760 %{mnewlib:ecrtn.o%s;:crtn.o%s}" 761 762 #define LINK_START_LINUX_SPEC "" 763 764 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" 765 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" 766 #if DEFAULT_LIBC == LIBC_UCLIBC 767 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" 768 #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC 769 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}" 770 #else 771 #error "Unsupported DEFAULT_LIBC" 772 #endif 773 #define GNU_USER_DYNAMIC_LINKER \ 774 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER) 775 776 #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \ 777 %{rdynamic:-export-dynamic} \ 778 -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}" 779 780 #if defined(HAVE_LD_EH_FRAME_HDR) 781 # define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " 782 #endif 783 784 #define CPP_OS_LINUX_SPEC "-D__unix__ -D__gnu_linux__ -D__linux__ \ 785 %{!undef: \ 786 %{!ansi: \ 787 %{!std=*:-Dunix -D__unix -Dlinux -D__linux} \ 788 %{std=gnu*:-Dunix -D__unix -Dlinux -D__linux}}} \ 789 -Asystem=linux -Asystem=unix -Asystem=posix %{pthread:-D_REENTRANT}" 790 791 /* NetBSD support. */ 792 #define LIB_NETBSD_SPEC "\ 793 -lc" 794 795 #define STARTFILE_NETBSD_SPEC "\ 796 ncrti.o%s crt0.o%s \ 797 %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" 798 799 #define ENDFILE_NETBSD_SPEC "\ 800 %{!shared:crtend.o%s} %{shared:crtendS.o%s} \ 801 ncrtn.o%s" 802 803 #define LINK_START_NETBSD_SPEC "\ 804 " 805 806 #define LINK_OS_NETBSD_SPEC "\ 807 %{!shared: %{!static: \ 808 %{rdynamic:-export-dynamic} \ 809 -dynamic-linker /usr/libexec/ld.elf_so}}" 810 811 #define CPP_OS_NETBSD_SPEC "\ 812 -D__powerpc__ -D__NetBSD__ -D__KPRINTF_ATTRIBUTE__" 813 814 /* OpenBSD support. */ 815 #ifndef LIB_OPENBSD_SPEC 816 #define LIB_OPENBSD_SPEC "%{!shared:%{pthread:-lpthread%{p:_p}%{!p:%{pg:_p}}}} %{!shared:-lc%{p:_p}%{!p:%{pg:_p}}}" 817 #endif 818 819 #ifndef STARTFILE_OPENBSD_SPEC 820 #define STARTFILE_OPENBSD_SPEC "\ 821 %{!shared: %{pg:gcrt0.o%s} %{!pg:%{p:gcrt0.o%s} %{!p:crt0.o%s}}} \ 822 %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" 823 #endif 824 825 #ifndef ENDFILE_OPENBSD_SPEC 826 #define ENDFILE_OPENBSD_SPEC "\ 827 %{!shared:crtend.o%s} %{shared:crtendS.o%s}" 828 #endif 829 830 #ifndef LINK_START_OPENBSD_SPEC 831 #define LINK_START_OPENBSD_SPEC "-Ttext 0x400074" 832 #endif 833 834 #ifndef LINK_OS_OPENBSD_SPEC 835 #define LINK_OS_OPENBSD_SPEC "" 836 #endif 837 838 #ifndef CPP_OS_OPENBSD_SPEC 839 #define CPP_OS_OPENBSD_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}" 840 #endif 841 842 /* Define any extra SPECS that the compiler needs to generate. */ 843 /* Override rs6000.h definition. */ 844 #undef SUBTARGET_EXTRA_SPECS 845 #define SUBTARGET_EXTRA_SPECS \ 846 { "crtsavres_default", CRTSAVRES_DEFAULT_SPEC }, \ 847 { "lib_ads", LIB_ADS_SPEC }, \ 848 { "lib_yellowknife", LIB_YELLOWKNIFE_SPEC }, \ 849 { "lib_mvme", LIB_MVME_SPEC }, \ 850 { "lib_sim", LIB_SIM_SPEC }, \ 851 { "lib_freebsd", LIB_FREEBSD_SPEC }, \ 852 { "lib_linux", LIB_LINUX_SPEC }, \ 853 { "lib_netbsd", LIB_NETBSD_SPEC }, \ 854 { "lib_openbsd", LIB_OPENBSD_SPEC }, \ 855 { "lib_default", LIB_DEFAULT_SPEC }, \ 856 { "startfile_ads", STARTFILE_ADS_SPEC }, \ 857 { "startfile_yellowknife", STARTFILE_YELLOWKNIFE_SPEC }, \ 858 { "startfile_mvme", STARTFILE_MVME_SPEC }, \ 859 { "startfile_sim", STARTFILE_SIM_SPEC }, \ 860 { "startfile_freebsd", STARTFILE_FREEBSD_SPEC }, \ 861 { "startfile_linux", STARTFILE_LINUX_SPEC }, \ 862 { "startfile_netbsd", STARTFILE_NETBSD_SPEC }, \ 863 { "startfile_openbsd", STARTFILE_OPENBSD_SPEC }, \ 864 { "startfile_default", STARTFILE_DEFAULT_SPEC }, \ 865 { "endfile_ads", ENDFILE_ADS_SPEC }, \ 866 { "endfile_yellowknife", ENDFILE_YELLOWKNIFE_SPEC }, \ 867 { "endfile_mvme", ENDFILE_MVME_SPEC }, \ 868 { "endfile_sim", ENDFILE_SIM_SPEC }, \ 869 { "endfile_freebsd", ENDFILE_FREEBSD_SPEC }, \ 870 { "endfile_linux", ENDFILE_LINUX_SPEC }, \ 871 { "endfile_netbsd", ENDFILE_NETBSD_SPEC }, \ 872 { "endfile_openbsd", ENDFILE_OPENBSD_SPEC }, \ 873 { "endfile_default", ENDFILE_DEFAULT_SPEC }, \ 874 { "link_shlib", LINK_SHLIB_SPEC }, \ 875 { "link_target", LINK_TARGET_SPEC }, \ 876 { "link_start", LINK_START_SPEC }, \ 877 { "link_start_ads", LINK_START_ADS_SPEC }, \ 878 { "link_start_yellowknife", LINK_START_YELLOWKNIFE_SPEC }, \ 879 { "link_start_mvme", LINK_START_MVME_SPEC }, \ 880 { "link_start_sim", LINK_START_SIM_SPEC }, \ 881 { "link_start_freebsd", LINK_START_FREEBSD_SPEC }, \ 882 { "link_start_linux", LINK_START_LINUX_SPEC }, \ 883 { "link_start_netbsd", LINK_START_NETBSD_SPEC }, \ 884 { "link_start_openbsd", LINK_START_OPENBSD_SPEC }, \ 885 { "link_start_default", LINK_START_DEFAULT_SPEC }, \ 886 { "link_os", LINK_OS_SPEC }, \ 887 { "link_os_ads", LINK_OS_ADS_SPEC }, \ 888 { "link_os_yellowknife", LINK_OS_YELLOWKNIFE_SPEC }, \ 889 { "link_os_mvme", LINK_OS_MVME_SPEC }, \ 890 { "link_os_sim", LINK_OS_SIM_SPEC }, \ 891 { "link_os_freebsd", LINK_OS_FREEBSD_SPEC }, \ 892 { "link_os_linux", LINK_OS_LINUX_SPEC }, \ 893 { "link_os_netbsd", LINK_OS_NETBSD_SPEC }, \ 894 { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \ 895 { "link_os_default", LINK_OS_DEFAULT_SPEC }, \ 896 { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \ 897 { "cpp_os_ads", CPP_OS_ADS_SPEC }, \ 898 { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \ 899 { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \ 900 { "cpp_os_sim", CPP_OS_SIM_SPEC }, \ 901 { "cpp_os_freebsd", CPP_OS_FREEBSD_SPEC }, \ 902 { "cpp_os_linux", CPP_OS_LINUX_SPEC }, \ 903 { "cpp_os_netbsd", CPP_OS_NETBSD_SPEC }, \ 904 { "cpp_os_openbsd", CPP_OS_OPENBSD_SPEC }, \ 905 { "cpp_os_default", CPP_OS_DEFAULT_SPEC }, \ 906 { "fbsd_dynamic_linker", FBSD_DYNAMIC_LINKER }, \ 907 SUBSUBTARGET_EXTRA_SPECS 908 909 #define SUBSUBTARGET_EXTRA_SPECS 910 911 /* Define this macro as a C expression for the initializer of an 912 array of string to tell the driver program which options are 913 defaults for this target and thus do not need to be handled 914 specially when using `MULTILIB_OPTIONS'. 915 916 Do not define this macro if `MULTILIB_OPTIONS' is not defined in 917 the target makefile fragment or if none of the options listed in 918 `MULTILIB_OPTIONS' are set by default. *Note Target Fragment::. */ 919 920 #define MULTILIB_DEFAULTS { "mbig", "mcall-sysv" } 921 922 /* Define this macro if the code for function profiling should come 923 before the function prologue. Normally, the profiling code comes 924 after. */ 925 #define PROFILE_BEFORE_PROLOGUE 1 926 927 /* Function name to call to do profiling. */ 928 #define RS6000_MCOUNT "_mcount" 929 930 /* Select a format to encode pointers in exception handling data. CODE 931 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is 932 true if the symbol may be affected by dynamic relocations. */ 933 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \ 934 ((flag_pic || TARGET_RELOCATABLE) \ 935 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4) \ 936 : DW_EH_PE_absptr) 937 938 #define DOUBLE_INT_ASM_OP "\t.quad\t" 939 940 /* Generate entries in .fixup for relocatable addresses. */ 941 #define RELOCATABLE_NEEDS_FIXUP 1 942 943 #define TARGET_ASM_FILE_END rs6000_elf_file_end 944 945 #undef TARGET_ASAN_SHADOW_OFFSET 946 #define TARGET_ASAN_SHADOW_OFFSET rs6000_asan_shadow_offset 947 948 /* This target uses the sysv4.opt file. */ 949 #define TARGET_USES_SYSV4_OPT 1 950 951 #undef DBX_REGISTER_NUMBER 952 953 /* Link -lasan early on the command line. For -static-libasan, don't link 954 it for -shared link, the executable should be compiled with -static-libasan 955 in that case, and for executable link link with --{,no-}whole-archive around 956 it to force everything into the executable. And similarly for -ltsan. */ 957 #if defined(HAVE_LD_STATIC_DYNAMIC) 958 #undef LIBASAN_EARLY_SPEC 959 #define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \ 960 "%{static-libasan:%{!shared:" \ 961 LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \ 962 LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}" 963 #undef LIBTSAN_EARLY_SPEC 964 #define LIBTSAN_EARLY_SPEC "%{static-libtsan:%{!shared:" \ 965 LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \ 966 LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}" 967 #endif 968