1 /* Target definitions for Darwin (Mac OS X) systems. 2 Copyright (C) 1989-2018 Free Software Foundation, Inc. 3 Contributed by Apple Computer Inc. 4 5 This file is part of GCC. 6 7 GCC 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 3, or (at your option) 10 any later version. 11 12 GCC 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 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 #ifndef CONFIG_DARWIN_H 27 #define CONFIG_DARWIN_H 28 29 /* The definitions in this file are common to all processor types 30 running Darwin, which is the kernel for Mac OS X. Darwin is 31 basically a BSD user layer laid over a Mach kernel, then evolved 32 for many years (at NeXT) in parallel with other Unix systems. So 33 while the runtime is a somewhat idiosyncratic Mach-based thing, 34 other definitions look like they would for a BSD variant. */ 35 36 /* Although NeXT ran on many different architectures, as of Jan 2001 37 the only supported Darwin targets are PowerPC and x86. */ 38 39 /* One of Darwin's NeXT legacies is the Mach-O format, which is partly 40 like a.out and partly like COFF, with additional features like 41 multi-architecture binary support. */ 42 43 #define DARWIN_X86 0 44 #define DARWIN_PPC 0 45 46 /* Don't assume anything about the header files. */ 47 #define NO_IMPLICIT_EXTERN_C 48 49 /* Suppress g++ attempt to link in the math library automatically. */ 50 #define MATH_LIBRARY "" 51 52 /* We have atexit. */ 53 54 #define HAVE_ATEXIT 55 56 /* Define an empty body for the function do_global_dtors() in libgcc2.c. */ 57 58 #define DO_GLOBAL_DTORS_BODY 59 60 /* The string value for __SIZE_TYPE__. */ 61 62 #ifndef SIZE_TYPE 63 #define SIZE_TYPE "long unsigned int" 64 #endif 65 66 /* Type used for ptrdiff_t, as a string used in a declaration. */ 67 68 #undef PTRDIFF_TYPE 69 #define PTRDIFF_TYPE "int" 70 71 /* wchar_t is int. */ 72 73 #undef WCHAR_TYPE 74 #define WCHAR_TYPE "int" 75 #undef WCHAR_TYPE_SIZE 76 #define WCHAR_TYPE_SIZE 32 77 78 #define INT8_TYPE "signed char" 79 #define INT16_TYPE "short int" 80 #define INT32_TYPE "int" 81 #define INT64_TYPE "long long int" 82 #define UINT8_TYPE "unsigned char" 83 #define UINT16_TYPE "short unsigned int" 84 #define UINT32_TYPE "unsigned int" 85 #define UINT64_TYPE "long long unsigned int" 86 87 #define INT_LEAST8_TYPE "signed char" 88 #define INT_LEAST16_TYPE "short int" 89 #define INT_LEAST32_TYPE "int" 90 #define INT_LEAST64_TYPE "long long int" 91 #define UINT_LEAST8_TYPE "unsigned char" 92 #define UINT_LEAST16_TYPE "short unsigned int" 93 #define UINT_LEAST32_TYPE "unsigned int" 94 #define UINT_LEAST64_TYPE "long long unsigned int" 95 96 #define INT_FAST8_TYPE "signed char" 97 #define INT_FAST16_TYPE "short int" 98 #define INT_FAST32_TYPE "int" 99 #define INT_FAST64_TYPE "long long int" 100 #define UINT_FAST8_TYPE "unsigned char" 101 #define UINT_FAST16_TYPE "short unsigned int" 102 #define UINT_FAST32_TYPE "unsigned int" 103 #define UINT_FAST64_TYPE "long long unsigned int" 104 105 #define INTPTR_TYPE "long int" 106 #define UINTPTR_TYPE "long unsigned int" 107 108 #define SIG_ATOMIC_TYPE "int" 109 110 /* Default to using the NeXT-style runtime, since that's what is 111 pre-installed on Darwin systems. */ 112 113 #define NEXT_OBJC_RUNTIME 1 114 115 /* Don't default to pcc-struct-return, because gcc is the only compiler, and 116 we want to retain compatibility with older gcc versions. */ 117 118 #undef DEFAULT_PCC_STRUCT_RETURN 119 #define DEFAULT_PCC_STRUCT_RETURN 0 120 121 /* True if pragma ms_struct is in effect. */ 122 extern GTY(()) int darwin_ms_struct; 123 124 #define DRIVER_SELF_SPECS \ 125 "%{gfull:-g -fno-eliminate-unused-debug-symbols} %<gfull", \ 126 "%{gused:-g -feliminate-unused-debug-symbols} %<gused", \ 127 "%{fapple-kext|mkernel:-static}", \ 128 "%{shared:-Zdynamiclib} %<shared", \ 129 "%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform } \ 130 %<gsplit-dwarf" 131 132 #if LD64_HAS_EXPORT_DYNAMIC 133 #define DARWIN_RDYNAMIC "%{rdynamic:-export_dynamic}" 134 #else 135 #define DARWIN_RDYNAMIC "%{rdynamic:%nrdynamic is not supported}" 136 #endif 137 138 /* FIXME: we should check that the linker supports the -pie and -no_pie. 139 options. */ 140 #define DARWIN_PIE_SPEC \ 141 "%{pie|fpie|fPIE:\ 142 %{mdynamic-no-pic: \ 143 %n'-mdynamic-no-pic' overrides '-pie', '-fpie' or '-fPIE'; \ 144 :%:version-compare(>= 10.5 mmacosx-version-min= -pie) }} " 145 146 #define DARWIN_NOPIE_SPEC \ 147 "%{no-pie|fno-pie|fno-PIE: \ 148 %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) }" 149 150 #define DARWIN_CC1_SPEC \ 151 "%{findirect-virtual-calls: -fapple-kext} %<findirect-virtual-calls " \ 152 "%{fterminated-vtables: -fapple-kext} %<fterminated-vtables " \ 153 "%<filelist* %<framework*" 154 155 #define SUBSUBTARGET_OVERRIDE_OPTIONS \ 156 do { \ 157 darwin_override_options (); \ 158 } while (0) 159 160 #define SUBTARGET_C_COMMON_OVERRIDE_OPTIONS do { \ 161 if (flag_mkernel || flag_apple_kext) \ 162 { \ 163 if (flag_use_cxa_atexit == 2) \ 164 flag_use_cxa_atexit = 0; \ 165 /* kexts should always be built without the coalesced sections \ 166 because the kernel loader doesn't grok such sections. */ \ 167 flag_weak = 0; \ 168 /* No RTTI in kexts. */ \ 169 flag_rtti = 0; \ 170 } \ 171 } while (0) 172 173 /* Machine dependent cpp options. Don't add more options here, add 174 them to darwin_cpp_builtins in darwin-c.c. */ 175 176 #undef CPP_SPEC 177 #define CPP_SPEC "%{static:%{!dynamic:-D__STATIC__}}%{!static:-D__DYNAMIC__}" \ 178 " %{pthread:-D_REENTRANT}" 179 180 /* This is a fix for PR41260 by passing -no_compact_unwind on darwin10 and 181 later until the assembler, linker and libunwind are able to deal with the 182 output from GCC. 183 184 FIXME: we should check that the linker supports the option. 185 */ 186 187 #define DARWIN_NOCOMPACT_UNWIND \ 188 " %:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) " 189 190 /* In Darwin linker specs we can put -lcrt0.o and ld will search the library 191 path for crt0.o or -lcrtx.a and it will search for for libcrtx.a. As for 192 other ports, we can also put xxx.{o,a}%s and get the appropriate complete 193 startfile absolute directory. This latter point is important when we want 194 to override ld's rule of .dylib being found ahead of .a and the user wants 195 the convenience library to be linked. */ 196 197 /* The LINK_COMMAND spec is mostly a clone of the standard LINK_COMMAND_SPEC, 198 plus precomp, libtool, and fat build additions. 199 200 In general, random Darwin linker flags should go into LINK_SPEC 201 instead of LINK_COMMAND_SPEC. The command spec is better for 202 specifying the handling of options understood by generic Unix 203 linkers, and for positional arguments like libraries. */ 204 205 #define LINK_COMMAND_SPEC_A \ 206 "%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ 207 %(linker)" \ 208 LINK_PLUGIN_SPEC \ 209 "%{flto*:%<fcompare-debug*} \ 210 %{flto} %{fno-lto} %{flto=*} \ 211 %l " LINK_COMPRESS_DEBUG_SPEC \ 212 "%X %{s} %{t} %{Z} %{u*} \ 213 %{e*} %{r} \ 214 %{o*}%{!o:-o a.out} \ 215 %{!nostdlib:%{!nostartfiles:%S}} \ 216 %{L*} %(link_libgcc) %o %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} \ 217 %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): \ 218 %{static|static-libgcc|static-libstdc++|static-libgfortran: libgomp.a%s; : -lgomp } } \ 219 %{fgnu-tm: \ 220 %{static|static-libgcc|static-libstdc++|static-libgfortran: libitm.a%s; : -litm } } \ 221 %{!nostdlib:%{!nodefaultlibs:\ 222 %{%:sanitize(address): -lasan } \ 223 %{%:sanitize(undefined): -lubsan } \ 224 %(link_ssp) \ 225 %(link_gcc_c_sequence) \ 226 }}\ 227 %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} %{F*} "\ 228 DARWIN_PIE_SPEC \ 229 DARWIN_NOPIE_SPEC \ 230 DARWIN_RDYNAMIC \ 231 DARWIN_NOCOMPACT_UNWIND \ 232 "}}}}}}} %<pie %<no-pie %<rdynamic " 233 234 #define DSYMUTIL "\ndsymutil" 235 236 #define DSYMUTIL_SPEC \ 237 "%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ 238 %{v} \ 239 %{gdwarf-2:%{!gstabs*:%{%:debug-level-gt(0): -idsym}}}\ 240 %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm: \ 241 %{gdwarf-2:%{!gstabs*:%{%:debug-level-gt(0): -dsym}}}}}}}}}}}" 242 243 #define LINK_COMMAND_SPEC LINK_COMMAND_SPEC_A DSYMUTIL_SPEC 244 245 /* Tell collect2 to run dsymutil for us as necessary. */ 246 #define COLLECT_RUN_DSYMUTIL 1 247 248 /* We only want one instance of %G, since libSystem (Darwin's -lc) does not depend 249 on libgcc. */ 250 #undef LINK_GCC_C_SEQUENCE_SPEC 251 #define LINK_GCC_C_SEQUENCE_SPEC "%G %L" 252 253 /* ld64 supports a sysroot, it just has a different name and there's no easy 254 way to check for it at config time. */ 255 #undef HAVE_LD_SYSROOT 256 #define HAVE_LD_SYSROOT 1 257 /* It seems the only (working) way to get a space after %R is to append a 258 dangling '/'. */ 259 #define SYSROOT_SPEC "%{!isysroot*:-syslibroot %R/ }" 260 261 /* Do the same as clang, for now, and insert the sysroot for ld when an 262 isysroot is specified. */ 263 #define LINK_SYSROOT_SPEC "%{isysroot*:-syslibroot %*}" 264 265 /* Suppress the addition of extra prefix paths when a sysroot is in use. */ 266 #define STANDARD_STARTFILE_PREFIX_1 "" 267 #define STANDARD_STARTFILE_PREFIX_2 "" 268 269 /* Please keep the random linker options in alphabetical order (modulo 270 'Z' and 'no' prefixes). Note that options taking arguments may appear 271 multiple times on a command line with different arguments each time, 272 so put a * after their names so all of them get passed. */ 273 #define LINK_SPEC \ 274 "%{static}%{!static:-dynamic} \ 275 %:remove-outfile(-ldl) \ 276 %:remove-outfile(-lm) \ 277 %:remove-outfile(-lpthread) \ 278 %{fgnu-runtime: %{static|static-libgcc: \ 279 %:replace-outfile(-lobjc libobjc-gnu.a%s); \ 280 :%:replace-outfile(-lobjc -lobjc-gnu ) } }\ 281 %{static|static-libgcc|static-libgfortran:%:replace-outfile(-lgfortran libgfortran.a%s)}\ 282 %{static|static-libgcc|static-libstdc++|static-libgfortran:%:replace-outfile(-lgomp libgomp.a%s)}\ 283 %{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ libstdc++.a%s)}\ 284 %{!Zdynamiclib: \ 285 %{Zforce_cpusubtype_ALL:-arch %(darwin_arch) -force_cpusubtype_ALL} \ 286 %{!Zforce_cpusubtype_ALL:-arch %(darwin_subarch)} \ 287 %{Zbundle:-bundle} \ 288 %{Zbundle_loader*:-bundle_loader %*} \ 289 %{client_name*} \ 290 %{compatibility_version*:%e-compatibility_version only allowed with -dynamiclib\ 291 } \ 292 %{current_version*:%e-current_version only allowed with -dynamiclib} \ 293 %{Zforce_flat_namespace:-force_flat_namespace} \ 294 %{Zinstall_name*:%e-install_name only allowed with -dynamiclib} \ 295 %{keep_private_externs} \ 296 %{private_bundle} \ 297 } \ 298 %{Zdynamiclib: -dylib \ 299 %{Zbundle:%e-bundle not allowed with -dynamiclib} \ 300 %{Zbundle_loader*:%e-bundle_loader not allowed with -dynamiclib} \ 301 %{client_name*:%e-client_name not allowed with -dynamiclib} \ 302 %{compatibility_version*:-dylib_compatibility_version %*} \ 303 %{current_version*:-dylib_current_version %*} \ 304 %{Zforce_cpusubtype_ALL:-arch %(darwin_arch)} \ 305 %{!Zforce_cpusubtype_ALL: -arch %(darwin_subarch)} \ 306 %{Zforce_flat_namespace:%e-force_flat_namespace not allowed with -dynamiclib} \ 307 %{Zinstall_name*:-dylib_install_name %*} \ 308 %{keep_private_externs:%e-keep_private_externs not allowed with -dynamiclib} \ 309 %{private_bundle:%e-private_bundle not allowed with -dynamiclib} \ 310 } \ 311 %{Zall_load:-all_load} \ 312 %{Zallowable_client*:-allowable_client %*} \ 313 %{Zbind_at_load:-bind_at_load} \ 314 %{Zarch_errors_fatal:-arch_errors_fatal} \ 315 %{Zdead_strip:-dead_strip} \ 316 %{Zno_dead_strip_inits_and_terms:-no_dead_strip_inits_and_terms} \ 317 %{Zdylib_file*:-dylib_file %*} \ 318 %{Zdynamic:-dynamic}\ 319 %{Zexported_symbols_list*:-exported_symbols_list %*} \ 320 %{Zflat_namespace:-flat_namespace} \ 321 %{headerpad_max_install_names} \ 322 %{Zimage_base*:-image_base %*} \ 323 %{Zinit*:-init %*} \ 324 %{mmacosx-version-min=*:-macosx_version_min %*} \ 325 %{nomultidefs} \ 326 %{Zmulti_module:-multi_module} %{Zsingle_module:-single_module} \ 327 %{Zmultiply_defined*:-multiply_defined %*} \ 328 %{!Zmultiply_defined*:%{shared-libgcc: \ 329 %:version-compare(< 10.5 mmacosx-version-min= -multiply_defined) \ 330 %:version-compare(< 10.5 mmacosx-version-min= suppress)}} \ 331 %{Zmultiplydefinedunused*:-multiply_defined_unused %*} \ 332 %{prebind} %{noprebind} %{nofixprebinding} %{prebind_all_twolevel_modules} \ 333 %{read_only_relocs} \ 334 %{sectcreate*} %{sectorder*} %{seg1addr*} %{segprot*} \ 335 %{Zsegaddr*:-segaddr %*} \ 336 %{Zsegs_read_only_addr*:-segs_read_only_addr %*} \ 337 %{Zsegs_read_write_addr*:-segs_read_write_addr %*} \ 338 %{Zseg_addr_table*: -seg_addr_table %*} \ 339 %{Zfn_seg_addr_table_filename*:-seg_addr_table_filename %*} \ 340 %{sub_library*} %{sub_umbrella*} \ 341 " LINK_SYSROOT_SPEC " \ 342 %{twolevel_namespace} %{twolevel_namespace_hints} \ 343 %{Zumbrella*: -umbrella %*} \ 344 %{undefined*} \ 345 %{Zunexported_symbols_list*:-unexported_symbols_list %*} \ 346 %{Zweak_reference_mismatches*:-weak_reference_mismatches %*} \ 347 %{!Zweak_reference_mismatches*:-weak_reference_mismatches non-weak} \ 348 %{X} \ 349 %{y*} \ 350 %{w} \ 351 %{pagezero_size*} %{segs_read_*} %{seglinkedit} %{noseglinkedit} \ 352 %{sectalign*} %{sectobjectsymbols*} %{segcreate*} %{whyload} \ 353 %{whatsloaded} %{dylinker_install_name*} \ 354 %{dylinker} %{Mach} " 355 356 357 /* Machine dependent libraries. */ 358 359 #define LIB_SPEC "%{!static:-lSystem}" 360 361 /* Support -mmacosx-version-min by supplying different (stub) libgcc_s.dylib 362 libraries to link against, and by not linking against libgcc_s on 363 earlier-than-10.3.9. If we need exceptions, prior to 10.3.9, then we have 364 to link the static eh lib, since there's no shared version on the system. 365 366 Note that by default, except as above, -lgcc_eh is not linked against. 367 This is because,in general, we need to unwind through system libraries that 368 are linked with the shared unwinder in libunwind (or libgcc_s for 10.4/5). 369 370 The static version of the current libgcc unwinder (which differs from the 371 implementation in libunwind.dylib on systems Darwin10 [10.6]+) can be used 372 by specifying -static-libgcc. 373 374 If libgcc_eh is linked against, it has to be before -lgcc, because it might 375 need symbols from -lgcc. */ 376 377 #undef REAL_LIBGCC_SPEC 378 #define REAL_LIBGCC_SPEC \ 379 "%{static-libgcc|static: -lgcc_eh -lgcc; \ 380 shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \ 381 %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh) \ 382 %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \ 383 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5) \ 384 %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_ext.10.4) \ 385 %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5) \ 386 -lgcc ; \ 387 :%:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \ 388 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5) \ 389 %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_ext.10.4) \ 390 %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5) \ 391 -lgcc }" 392 393 /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */ 394 395 #undef STARTFILE_SPEC 396 #define STARTFILE_SPEC \ 397 "%{Zdynamiclib: %(darwin_dylib1) %{fgnu-tm: -lcrttms.o}} \ 398 %{!Zdynamiclib:%{Zbundle:%(darwin_bundle1)} \ 399 %{!Zbundle:%{pg:%{static:-lgcrt0.o} \ 400 %{!static:%{object:-lgcrt0.o} \ 401 %{!object:%{preload:-lgcrt0.o} \ 402 %{!preload:-lgcrt1.o \ 403 %:version-compare(>= 10.8 mmacosx-version-min= -no_new_main) \ 404 %(darwin_crt2)}}}} \ 405 %{!pg:%{static:-lcrt0.o} \ 406 %{!static:%{object:-lcrt0.o} \ 407 %{!object:%{preload:-lcrt0.o} \ 408 %{!preload: %(darwin_crt1) \ 409 %(darwin_crt2)}}}}}} \ 410 %(darwin_crt3)" 411 412 /* We want a destructor last in the list. */ 413 #define TM_DESTRUCTOR "%{fgnu-tm: -lcrttme.o}" 414 #define ENDFILE_SPEC TM_DESTRUCTOR 415 416 #define DARWIN_EXTRA_SPECS \ 417 { "darwin_crt1", DARWIN_CRT1_SPEC }, \ 418 { "darwin_crt2", DARWIN_CRT2_SPEC }, \ 419 { "darwin_crt3", DARWIN_CRT3_SPEC }, \ 420 { "darwin_dylib1", DARWIN_DYLIB1_SPEC }, \ 421 { "darwin_bundle1", DARWIN_BUNDLE1_SPEC }, 422 423 #define DARWIN_CRT1_SPEC \ 424 "%:version-compare(!> 10.5 mmacosx-version-min= -lcrt1.o) \ 425 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lcrt1.10.5.o) \ 426 %:version-compare(>< 10.6 10.8 mmacosx-version-min= -lcrt1.10.6.o) \ 427 %{fgnu-tm: -lcrttms.o}" 428 429 #define DARWIN_CRT2_SPEC "" 430 431 /* crt3.o provides __cxa_atexit on systems that don't have it (and a fix 432 up for faulty versions on 10.4). Since it's only used with C++, which 433 requires passing -shared-libgcc, key off that to avoid unnecessarily 434 adding a destructor to every program built for 10.4 or earlier. */ 435 436 #define DARWIN_CRT3_SPEC \ 437 "%{shared-libgcc:%:version-compare(< 10.5 mmacosx-version-min= crt3.o%s)}" 438 439 #define DARWIN_DYLIB1_SPEC \ 440 "%:version-compare(!> 10.5 mmacosx-version-min= -ldylib1.o) \ 441 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -ldylib1.10.5.o)" 442 443 #define DARWIN_BUNDLE1_SPEC \ 444 "%{!static:%:version-compare(< 10.6 mmacosx-version-min= -lbundle1.o) \ 445 %{fgnu-tm: -lcrttms.o}}" 446 447 #ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION 448 /* Emit macosx version (but only major). */ 449 #define ASM_MMACOSX_VERSION_MIN_SPEC \ 450 " %{asm_macosx_version_min=*: -mmacosx-version-min=%*} %<asm_macosx_version_min=*" 451 #else 452 #define ASM_MMACOSX_VERSION_MIN_SPEC " %<asm_macosx_version_min=*" 453 #endif 454 455 /* When we detect that we're cctools or llvm as, we need to insert the right 456 additional options. */ 457 #if HAVE_GNU_AS 458 #define ASM_OPTIONS "" 459 #else 460 #define ASM_OPTIONS "%{v} %{w:-W} %{I*}" 461 #endif 462 463 /* Default Darwin ASM_SPEC, very simple. */ 464 #define ASM_SPEC "-arch %(darwin_arch) \ 465 " ASM_OPTIONS " \ 466 %{Zforce_cpusubtype_ALL:-force_cpusubtype_ALL} \ 467 %{static}" ASM_MMACOSX_VERSION_MIN_SPEC 468 469 /* Default ASM_DEBUG_SPEC. Darwin's as cannot currently produce dwarf 470 debugging data. */ 471 472 #define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):%{!gdwarf*:--gstabs}}}" 473 #define ASM_FINAL_SPEC \ 474 "%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform } %<gsplit-dwarf" 475 476 /* We still allow output of STABS if the assembler supports it. */ 477 #ifdef HAVE_AS_STABS_DIRECTIVE 478 #define DBX_DEBUGGING_INFO 1 479 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG 480 #endif 481 482 #define DWARF2_DEBUGGING_INFO 1 483 484 #define DEBUG_FRAME_SECTION "__DWARF,__debug_frame,regular,debug" 485 #define DEBUG_INFO_SECTION "__DWARF,__debug_info,regular,debug" 486 #define DEBUG_ABBREV_SECTION "__DWARF,__debug_abbrev,regular,debug" 487 #define DEBUG_ARANGES_SECTION "__DWARF,__debug_aranges,regular,debug" 488 #define DEBUG_MACINFO_SECTION "__DWARF,__debug_macinfo,regular,debug" 489 #define DEBUG_LINE_SECTION "__DWARF,__debug_line,regular,debug" 490 #define DEBUG_LOC_SECTION "__DWARF,__debug_loc,regular,debug" 491 #define DEBUG_LOCLISTS_SECTION "__DWARF,__debug_loclists,regular,debug" 492 493 #define DEBUG_STR_SECTION "__DWARF,__debug_str,regular,debug" 494 #define DEBUG_STR_OFFSETS_SECTION "__DWARF,__debug_str_offs,regular,debug" 495 #define DEBUG_RANGES_SECTION "__DWARF,__debug_ranges,regular,debug" 496 #define DEBUG_RNGLISTS_SECTION "__DWARF,__debug_rnglists,regular,debug" 497 #define DEBUG_MACRO_SECTION "__DWARF,__debug_macro,regular,debug" 498 499 #define DEBUG_LTO_INFO_SECTION "__GNU_DWARF_LTO,__debug_info,regular,debug" 500 #define DEBUG_LTO_ABBREV_SECTION "__GNU_DWARF_LTO,__debug_abbrev,regular,debug" 501 #define DEBUG_LTO_MACINFO_SECTION "__GNU_DWARF_LTO,__debug_macinfo,regular,debug" 502 #define DEBUG_LTO_LINE_SECTION "__GNU_DWARF_LTO,__debug_line,regular,debug" 503 #define DEBUG_LTO_STR_SECTION "__GNU_DWARF_LTO,__debug_str,regular,debug" 504 #define DEBUG_LTO_MACRO_SECTION "__GNU_DWARF_LTO,__debug_macro,regular,debug" 505 506 #define TARGET_WANT_DEBUG_PUB_SECTIONS true 507 #define DEBUG_PUBNAMES_SECTION ((debug_generate_pub_sections == 2) \ 508 ? "__DWARF,__debug_gnu_pubn,regular,debug" \ 509 : "__DWARF,__debug_pubnames,regular,debug") 510 511 #define DEBUG_PUBTYPES_SECTION ((debug_generate_pub_sections == 2) \ 512 ? "__DWARF,__debug_gnu_pubt,regular,debug" \ 513 : "__DWARF,__debug_pubtypes,regular,debug") 514 515 /* When generating stabs debugging, use N_BINCL entries. */ 516 517 #define DBX_USE_BINCL 518 519 /* There is no limit to the length of stabs strings. */ 520 521 #define DBX_CONTIN_LENGTH 0 522 523 /* gdb needs a null N_SO at the end of each file for scattered loading. */ 524 525 #define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END 526 527 /* GCC's definition of 'one_only' is the same as its definition of 'weak'. */ 528 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) 529 530 /* Mach-O supports 'weak imports', and 'weak definitions' in coalesced 531 sections. machopic_select_section ensures that weak variables go in 532 coalesced sections. Weak aliases (or any other kind of aliases) are 533 not supported. Weak symbols that aren't visible outside the .s file 534 are not supported. */ 535 #define ASM_WEAKEN_DECL(FILE, DECL, NAME, ALIAS) \ 536 do { \ 537 if (ALIAS) \ 538 { \ 539 warning (0, "alias definitions not supported in Mach-O; ignored"); \ 540 break; \ 541 } \ 542 \ 543 if (! DECL_EXTERNAL (DECL) && TREE_PUBLIC (DECL)) \ 544 targetm.asm_out.globalize_label (FILE, NAME); \ 545 if (DECL_EXTERNAL (DECL)) \ 546 fputs ("\t.weak_reference ", FILE); \ 547 else if (lookup_attribute ("weak_import", DECL_ATTRIBUTES (DECL))) \ 548 break; \ 549 else if (TREE_PUBLIC (DECL)) \ 550 fputs ("\t.weak_definition ", FILE); \ 551 else \ 552 break; \ 553 assemble_name (FILE, NAME); \ 554 fputc ('\n', FILE); \ 555 } while (0) 556 557 /* Darwin has the pthread routines in libSystem, which every program 558 links to, so there's no need for weak-ness for that. */ 559 #define GTHREAD_USE_WEAK 0 560 561 /* On Darwin, we don't (at the time of writing) have linkonce sections 562 with names, so it's safe to make the class data not comdat. */ 563 #define TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT hook_bool_void_false 564 565 /* For efficiency, on Darwin the RTTI information that is always 566 emitted in the standard C++ library should not be COMDAT. */ 567 #define TARGET_CXX_LIBRARY_RTTI_COMDAT hook_bool_void_false 568 569 /* We make exception information linkonce. */ 570 #undef TARGET_USES_WEAK_UNWIND_INFO 571 #define TARGET_USES_WEAK_UNWIND_INFO 1 572 573 /* We need to use a nonlocal label for the start of an EH frame: the 574 Darwin linker requires that a coalesced section start with a label. 575 Unfortunately, it also requires that 'debug' sections don't contain 576 labels. */ 577 #undef FRAME_BEGIN_LABEL 578 #define FRAME_BEGIN_LABEL (for_eh ? "EH_frame" : "Lframe") 579 580 /* Emit a label for the FDE corresponding to DECL. EMPTY means 581 emit a label for an empty FDE. */ 582 #define TARGET_ASM_EMIT_UNWIND_LABEL darwin_emit_unwind_label 583 584 /* Emit a label to separate the exception table. */ 585 #define TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL darwin_emit_except_table_label 586 587 /* Our profiling scheme doesn't LP labels and counter words. */ 588 589 #define NO_PROFILE_COUNTERS 1 590 591 #undef INIT_SECTION_ASM_OP 592 #define INIT_SECTION_ASM_OP "" 593 594 #undef INVOKE__main 595 596 #define TARGET_ASM_CONSTRUCTOR machopic_asm_out_constructor 597 #define TARGET_ASM_DESTRUCTOR machopic_asm_out_destructor 598 599 /* Always prefix with an underscore. */ 600 601 #define USER_LABEL_PREFIX "_" 602 603 /* A dummy symbol that will be replaced with the function base name. */ 604 #define MACHOPIC_FUNCTION_BASE_NAME "<pic base>" 605 606 /* Don't output a .file directive. That is only used by the assembler for 607 error reporting. */ 608 #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE 609 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE false 610 611 #undef TARGET_ASM_FILE_END 612 #define TARGET_ASM_FILE_END darwin_file_end 613 614 /* Because Mach-O relocations have a counter from 1 to 255 for the 615 section number they apply to, it is necessary to output all 616 normal sections before the LTO sections, to make sure that the 617 sections that may have relocations always have a section number 618 smaller than 255. */ 619 #undef TARGET_ASM_LTO_START 620 #define TARGET_ASM_LTO_START darwin_asm_lto_start 621 #undef TARGET_ASM_LTO_END 622 #define TARGET_ASM_LTO_END darwin_asm_lto_end 623 624 #define ASM_OUTPUT_SKIP(FILE,SIZE) \ 625 fprintf (FILE, "\t.space " HOST_WIDE_INT_PRINT_UNSIGNED"\n", SIZE) 626 627 /* Give ObjC methods pretty symbol names. */ 628 629 #undef OBJC_GEN_METHOD_LABEL 630 #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \ 631 do { if (CAT_NAME) \ 632 sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+', \ 633 (CLASS_NAME), (CAT_NAME), (SEL_NAME)); \ 634 else \ 635 sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+', \ 636 (CLASS_NAME), (SEL_NAME)); \ 637 } while (0) 638 639 #undef ASM_DECLARE_OBJECT_NAME 640 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ 641 darwin_asm_declare_object_name ((FILE), (NAME), (DECL)) 642 643 /* The RTTI data (e.g., __ti4name) is common and public (and static), 644 but it does need to be referenced via indirect PIC data pointers. 645 The machopic_define_symbol calls are telling the machopic subsystem 646 that the name *is* defined in this module, so it doesn't need to 647 make them indirect. */ 648 649 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ 650 do { \ 651 const char *xname = NAME; \ 652 if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \ 653 xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \ 654 if (! DECL_WEAK (DECL) \ 655 && ((TREE_STATIC (DECL) \ 656 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \ 657 || DECL_INITIAL (DECL))) \ 658 machopic_define_symbol (DECL_RTL (DECL)); \ 659 if ((TREE_STATIC (DECL) \ 660 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \ 661 || DECL_INITIAL (DECL)) \ 662 (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \ 663 ASM_OUTPUT_FUNCTION_LABEL (FILE, xname, DECL); \ 664 } while (0) 665 666 #undef TARGET_ASM_DECLARE_CONSTANT_NAME 667 #define TARGET_ASM_DECLARE_CONSTANT_NAME darwin_asm_declare_constant_name 668 669 /* Wrap new method names in quotes so the assembler doesn't gag. 670 Make Objective-C internal symbols local and in doing this, we need 671 to accommodate the name mangling done by c++ on file scope locals. */ 672 673 int darwin_label_is_anonymous_local_objc_name (const char *name); 674 675 #undef ASM_OUTPUT_LABELREF 676 #define ASM_OUTPUT_LABELREF(FILE,NAME) \ 677 do { \ 678 const char *xname = (NAME); \ 679 if (! strcmp (xname, MACHOPIC_FUNCTION_BASE_NAME)) \ 680 machopic_output_function_base_name(FILE); \ 681 else if (xname[0] == '&' || xname[0] == '*') \ 682 { \ 683 int len = strlen (xname); \ 684 if (len > 6 && !strcmp ("$stub", xname + len - 5)) \ 685 machopic_validate_stub_or_non_lazy_ptr (xname); \ 686 else if (len > 7 && !strcmp ("$stub\"", xname + len - 6)) \ 687 machopic_validate_stub_or_non_lazy_ptr (xname); \ 688 else if (len > 14 && !strcmp ("$non_lazy_ptr", xname + len - 13)) \ 689 machopic_validate_stub_or_non_lazy_ptr (xname); \ 690 else if (len > 15 && !strcmp ("$non_lazy_ptr\"", xname + len - 14)) \ 691 machopic_validate_stub_or_non_lazy_ptr (xname); \ 692 if (xname[1] != '"' && name_needs_quotes (&xname[1])) \ 693 fprintf (FILE, "\"%s\"", &xname[1]); \ 694 else \ 695 fputs (&xname[1], FILE); \ 696 } \ 697 else if (xname[0] == '+' || xname[0] == '-') \ 698 fprintf (FILE, "\"%s\"", xname); \ 699 else if (darwin_label_is_anonymous_local_objc_name (xname)) \ 700 fprintf (FILE, "L%s", xname); \ 701 else if (xname[0] != '"' && name_needs_quotes (xname)) \ 702 asm_fprintf (FILE, "\"%U%s\"", xname); \ 703 else \ 704 asm_fprintf (FILE, "%U%s", xname); \ 705 } while (0) 706 707 /* Output before executable code. */ 708 #undef TEXT_SECTION_ASM_OP 709 #define TEXT_SECTION_ASM_OP "\t.text" 710 711 /* Output before writable data. */ 712 713 #undef DATA_SECTION_ASM_OP 714 #define DATA_SECTION_ASM_OP "\t.data" 715 716 #undef ALIGN_ASM_OP 717 #define ALIGN_ASM_OP ".align" 718 719 #undef ASM_OUTPUT_ALIGN 720 #define ASM_OUTPUT_ALIGN(FILE,LOG) \ 721 if ((LOG) != 0) \ 722 fprintf (FILE, "\t%s\t%d\n", ALIGN_ASM_OP, (LOG)) 723 724 /* The maximum alignment which the object file format can support in 725 bits. For Mach-O, this is 2^15 bytes. */ 726 727 #undef MAX_OFILE_ALIGNMENT 728 #define MAX_OFILE_ALIGNMENT (0x8000 * 8) 729 730 #define L2_MAX_OFILE_ALIGNMENT 15 731 732 /* These are the three variants that emit referenced blank space. */ 733 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 734 darwin_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN)) 735 736 #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL 737 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \ 738 darwin_asm_output_aligned_decl_local \ 739 ((FILE), (DECL), (NAME), (SIZE), (ALIGN)) 740 741 #undef ASM_OUTPUT_ALIGNED_DECL_COMMON 742 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \ 743 darwin_asm_output_aligned_decl_common \ 744 ((FILE), (DECL), (NAME), (SIZE), (ALIGN)) 745 746 /* The generic version, archs should over-ride where required. */ 747 #define MACHOPIC_NL_SYMBOL_PTR_SECTION ".non_lazy_symbol_pointer" 748 749 /* Declare the section variables. */ 750 #ifndef USED_FOR_TARGET 751 enum darwin_section_enum { 752 #define DEF_SECTION(NAME, FLAGS, DIRECTIVE, OBJC) NAME, 753 #include "darwin-sections.def" 754 #undef DEF_SECTION 755 NUM_DARWIN_SECTIONS 756 }; 757 extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS]; 758 #endif 759 760 #undef TARGET_ASM_SELECT_SECTION 761 #define TARGET_ASM_SELECT_SECTION machopic_select_section 762 763 #undef TARGET_ASM_FUNCTION_SECTION 764 #define TARGET_ASM_FUNCTION_SECTION darwin_function_section 765 766 #undef TARGET_ASM_SELECT_RTX_SECTION 767 #define TARGET_ASM_SELECT_RTX_SECTION machopic_select_rtx_section 768 #undef TARGET_ASM_UNIQUE_SECTION 769 #define TARGET_ASM_UNIQUE_SECTION darwin_unique_section 770 #undef TARGET_ASM_FUNCTION_RODATA_SECTION 771 #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section 772 773 #undef TARGET_ASM_TM_CLONE_TABLE_SECTION 774 #define TARGET_ASM_TM_CLONE_TABLE_SECTION darwin_tm_clone_table_section 775 776 #undef TARGET_ASM_RELOC_RW_MASK 777 #define TARGET_ASM_RELOC_RW_MASK machopic_reloc_rw_mask 778 779 /* Globalizing directive for a label. */ 780 #define GLOBAL_ASM_OP "\t.globl " 781 #define TARGET_ASM_GLOBALIZE_LABEL darwin_globalize_label 782 783 /* Emit an assembler directive to set visibility for a symbol. Used 784 to support visibility attribute and Darwin's private extern 785 feature. */ 786 #undef TARGET_ASM_ASSEMBLE_VISIBILITY 787 #define TARGET_ASM_ASSEMBLE_VISIBILITY darwin_assemble_visibility 788 789 /* Extra attributes for Darwin. */ 790 #define SUBTARGET_ATTRIBUTE_TABLE \ 791 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, \ 792 affects_type_identity, handler, exclude } */ \ 793 { "apple_kext_compatibility", 0, 0, false, true, false, false, \ 794 darwin_handle_kext_attribute, NULL }, \ 795 { "weak_import", 0, 0, true, false, false, false, \ 796 darwin_handle_weak_import_attribute, NULL } 797 798 /* Make local constant labels linker-visible, so that if one follows a 799 weak_global constant, ld64 will be able to separate the atoms. */ 800 #undef ASM_GENERATE_INTERNAL_LABEL 801 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ 802 do { \ 803 if (strcmp ("LC", PREFIX) == 0) \ 804 sprintf (LABEL, "*%s%ld", "lC", (long)(NUM)); \ 805 else \ 806 sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM)); \ 807 } while (0) 808 809 #undef TARGET_ASM_MARK_DECL_PRESERVED 810 #define TARGET_ASM_MARK_DECL_PRESERVED darwin_mark_decl_preserved 811 812 /* Any port using this header needs to define the first available 813 subtarget symbol bit: SYMBOL_FLAG_SUBT_DEP. */ 814 815 /* Is a variable. */ 816 #define MACHO_SYMBOL_FLAG_VARIABLE (SYMBOL_FLAG_SUBT_DEP) 817 #define MACHO_SYMBOL_VARIABLE_P(RTX) \ 818 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_VARIABLE) != 0) 819 820 /* Set on a symbol that must be indirected, even when there is a 821 definition in the TU. The ABI mandates that common symbols are so 822 indirected, as are weak. If 'fix-and-continue' is operational then 823 data symbols might also be. */ 824 825 #define MACHO_SYMBOL_FLAG_MUST_INDIRECT ((SYMBOL_FLAG_SUBT_DEP) << 1) 826 #define MACHO_SYMBOL_MUST_INDIRECT_P(RTX) \ 827 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_MUST_INDIRECT) != 0) 828 829 /* Set on a symbol with SYMBOL_FLAG_FUNCTION or MACHO_SYMBOL_FLAG_VARIABLE 830 to indicate that the function or variable is considered defined in this 831 translation unit. */ 832 833 #define MACHO_SYMBOL_FLAG_DEFINED ((SYMBOL_FLAG_SUBT_DEP) << 2) 834 #define MACHO_SYMBOL_DEFINED_P(RTX) \ 835 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_DEFINED) != 0) 836 837 /* Set on a symbol that has specified non-default visibility. */ 838 839 #define MACHO_SYMBOL_FLAG_HIDDEN_VIS ((SYMBOL_FLAG_SUBT_DEP) << 3) 840 #define MACHO_SYMBOL_HIDDEN_VIS_P(RTX) \ 841 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_HIDDEN_VIS) != 0) 842 843 /* Set on a symbol that is a pic stub or symbol indirection (i.e. the 844 L_xxxxx${stub,non_lazy_ptr,lazy_ptr}. */ 845 846 #define MACHO_SYMBOL_FLAG_INDIRECTION ((SYMBOL_FLAG_SUBT_DEP) << 5) 847 #define MACHO_SYMBOL_INDIRECTION_P(RTX) \ 848 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_INDIRECTION) != 0) 849 850 /* Set on a symbol to indicate when fix-and-continue style code 851 generation is being used and the symbol refers to a static symbol 852 that should be rebound from new instances of a translation unit to 853 the original instance of the data. */ 854 855 #define MACHO_SYMBOL_FLAG_STATIC ((SYMBOL_FLAG_SUBT_DEP) << 6) 856 #define MACHO_SYMBOL_STATIC_P(RTX) \ 857 ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_STATIC) != 0) 858 859 /* Symbolic names for various things we might know about a symbol. */ 860 861 enum machopic_addr_class { 862 MACHOPIC_UNDEFINED, 863 MACHOPIC_DEFINED_DATA, 864 MACHOPIC_UNDEFINED_DATA, 865 MACHOPIC_DEFINED_FUNCTION, 866 MACHOPIC_UNDEFINED_FUNCTION 867 }; 868 869 /* Macros defining the various PIC cases. */ 870 871 #undef MACHO_DYNAMIC_NO_PIC_P 872 #define MACHO_DYNAMIC_NO_PIC_P (TARGET_MACHO_DYNAMIC_NO_PIC) 873 #undef MACHOPIC_INDIRECT 874 #define MACHOPIC_INDIRECT (flag_pic || MACHO_DYNAMIC_NO_PIC_P) 875 #define MACHOPIC_JUST_INDIRECT (MACHO_DYNAMIC_NO_PIC_P) 876 #undef MACHOPIC_PURE 877 #define MACHOPIC_PURE (flag_pic && ! MACHO_DYNAMIC_NO_PIC_P) 878 879 #undef TARGET_ENCODE_SECTION_INFO 880 #define TARGET_ENCODE_SECTION_INFO darwin_encode_section_info 881 #undef TARGET_STRIP_NAME_ENCODING 882 #define TARGET_STRIP_NAME_ENCODING default_strip_name_encoding 883 884 #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH) \ 885 do { \ 886 const char *const stub_ = (STUB); \ 887 char *buffer_ = (BUF); \ 888 strcpy (buffer_, stub_); \ 889 if (stub_[0] == '"') \ 890 { \ 891 strcpy (buffer_ + (STUB_LENGTH) - 1, "_binder\""); \ 892 } \ 893 else \ 894 { \ 895 strcpy (buffer_ + (STUB_LENGTH), "_binder"); \ 896 } \ 897 } while (0) 898 899 #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \ 900 do { \ 901 const char *const symbol_ = (SYMBOL); \ 902 char *buffer_ = (BUF); \ 903 if (name_needs_quotes (symbol_) && symbol_[0] != '"') \ 904 { \ 905 sprintf (buffer_, "\"%s\"", symbol_); \ 906 } \ 907 else \ 908 { \ 909 strcpy (buffer_, symbol_); \ 910 } \ 911 } while (0) 912 913 /* Given a symbol name string, create the lazy pointer version 914 of the symbol name. */ 915 916 #define GEN_LAZY_PTR_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \ 917 do { \ 918 const char *symbol_ = (SYMBOL); \ 919 char *buffer_ = (BUF); \ 920 if (symbol_[0] == '"') \ 921 { \ 922 strcpy (buffer_, "\"L"); \ 923 strcpy (buffer_ + 2, symbol_ + 1); \ 924 strcpy (buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\""); \ 925 } \ 926 else if (name_needs_quotes (symbol_)) \ 927 { \ 928 strcpy (buffer_, "\"L"); \ 929 strcpy (buffer_ + 2, symbol_); \ 930 strcpy (buffer_ + (SYMBOL_LENGTH) + 2, "$lazy_ptr\""); \ 931 } \ 932 else \ 933 { \ 934 strcpy (buffer_, "L"); \ 935 strcpy (buffer_ + 1, symbol_); \ 936 strcpy (buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr"); \ 937 } \ 938 } while (0) 939 940 #define EH_FRAME_SECTION_NAME "__TEXT" 941 #define EH_FRAME_SECTION_ATTR ",coalesced,no_toc+strip_static_syms+live_support" 942 943 #undef ASM_PREFERRED_EH_DATA_FORMAT 944 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \ 945 (((CODE) == 2 && (GLOBAL) == 1) \ 946 ? (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4) : \ 947 ((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr) 948 949 #define ASM_OUTPUT_DWARF_DELTA(FILE,SIZE,LABEL1,LABEL2) \ 950 darwin_asm_output_dwarf_delta (FILE, SIZE, LABEL1, LABEL2, 0) 951 952 #define ASM_OUTPUT_DWARF_OFFSET(FILE,SIZE,LABEL,OFFSET,BASE) \ 953 darwin_asm_output_dwarf_offset (FILE, SIZE, LABEL, OFFSET, BASE) 954 955 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(ASM_OUT_FILE, ENCODING, SIZE, ADDR, DONE) \ 956 if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1)) { \ 957 darwin_non_lazy_pcrel (ASM_OUT_FILE, ADDR); \ 958 goto DONE; \ 959 } 960 961 /* Experimentally, putting jump tables in text is faster on SPEC. 962 Also this is needed for correctness for coalesced functions. */ 963 964 #ifndef JUMP_TABLES_IN_TEXT_SECTION 965 #define JUMP_TABLES_IN_TEXT_SECTION 1 966 #endif 967 968 #define TARGET_TERMINATE_DW2_EH_FRAME_INFO false 969 970 #define TARGET_ASM_INIT_SECTIONS darwin_init_sections 971 #undef TARGET_ASM_NAMED_SECTION 972 #define TARGET_ASM_NAMED_SECTION darwin_asm_named_section 973 974 #define DARWIN_REGISTER_TARGET_PRAGMAS() \ 975 do { \ 976 if (!flag_preprocess_only) \ 977 cpp_register_pragma (parse_in, NULL, "mark", \ 978 darwin_pragma_ignore, false); \ 979 c_register_pragma (0, "options", darwin_pragma_options); \ 980 c_register_pragma (0, "segment", darwin_pragma_ignore); \ 981 c_register_pragma (0, "unused", darwin_pragma_unused); \ 982 c_register_pragma (0, "ms_struct", darwin_pragma_ms_struct); \ 983 } while (0) 984 985 #undef ASM_APP_ON 986 #define ASM_APP_ON "" 987 #undef ASM_APP_OFF 988 #define ASM_APP_OFF "" 989 990 void darwin_register_frameworks (const char *, const char *, int); 991 void darwin_register_objc_includes (const char *, const char *, int); 992 #define TARGET_EXTRA_PRE_INCLUDES darwin_register_objc_includes 993 #define TARGET_EXTRA_INCLUDES darwin_register_frameworks 994 995 void add_framework_path (char *); 996 #define TARGET_OPTF add_framework_path 997 998 #define TARGET_POSIX_IO 999 1000 #define WINT_TYPE "int" 1001 1002 /* Every program on darwin links against libSystem which contains the pthread 1003 routines, so there's no need to explicitly call out when doing threaded 1004 work. */ 1005 1006 #undef GOMP_SELF_SPECS 1007 #define GOMP_SELF_SPECS "" 1008 #undef GTM_SELF_SPECS 1009 #define GTM_SELF_SPECS "" 1010 1011 /* Darwin disables section anchors by default. 1012 They should be enabled per arch where support exists in that arch. */ 1013 #define TARGET_ASM_OUTPUT_ANCHOR NULL 1014 #define DARWIN_SECTION_ANCHORS 0 1015 1016 #define HAVE_ENABLE_EXECUTE_STACK 1017 1018 /* For Apple KEXTs, we make the constructors return this to match gcc 1019 2.95. */ 1020 #define TARGET_CXX_CDTOR_RETURNS_THIS (darwin_kextabi_p) 1021 #define TARGET_KEXTABI flag_apple_kext 1022 1023 /* We have target-specific builtins. */ 1024 #define SUBTARGET_FOLD_BUILTIN darwin_fold_builtin 1025 1026 #define TARGET_N_FORMAT_TYPES 1 1027 #define TARGET_FORMAT_TYPES darwin_additional_format_types 1028 1029 #ifndef USED_FOR_TARGET 1030 extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **); 1031 #define GCC_DRIVER_HOST_INITIALIZATION \ 1032 darwin_driver_init (&decoded_options_count, &decoded_options) 1033 #endif 1034 1035 /* The Apple assembler and linker do not support constructor priorities. */ 1036 #undef SUPPORTS_INIT_PRIORITY 1037 #define SUPPORTS_INIT_PRIORITY 0 1038 1039 /* When building cross-compilers (and native crosses) we shall default to 1040 providing an osx-version-min of this unless overridden by the User. 1041 10.5 is the only version that fully supports all our archs so that's the 1042 fall-back default. */ 1043 #define DEF_MIN_OSX_VERSION "10.5" 1044 1045 /* Later versions of ld64 support coalescing weak code/data without requiring 1046 that they be placed in specially identified sections. This is the earliest 1047 _tested_ version known to support this so far. */ 1048 #define MIN_LD64_NO_COAL_SECTS "236.4" 1049 1050 /* From at least version 62.1, ld64 can build symbol indirection stubs as 1051 needed, and there is no need for the compiler to emit them. */ 1052 #define MIN_LD64_OMIT_STUBS "85.2" 1053 1054 #ifndef LD64_VERSION 1055 #define LD64_VERSION "62.1" 1056 #else 1057 #define DEF_LD64 LD64_VERSION 1058 #endif 1059 1060 #endif /* CONFIG_DARWIN_H */ 1061