| 1 |
/* Target definitions for Darwin (macOS) systems. |
| 2 |
Copyright (C) 1989-2025 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 macOS. 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 |
#define OBJECT_FORMAT_MACHO 1 |
| 47 |
|
| 48 |
/* Suppress language-specific specs attempt to link in libm automatically. */ |
| 49 |
#define MATH_LIBRARY "" |
| 50 |
|
| 51 |
/* Likewise libdl. */ |
| 52 |
#define DL_LIBRARY "" |
| 53 |
|
| 54 |
/* We have atexit. */ |
| 55 |
|
| 56 |
#define HAVE_ATEXIT |
| 57 |
|
| 58 |
/* Define an empty body for the function do_global_dtors() in libgcc2.c. */ |
| 59 |
|
| 60 |
#define DO_GLOBAL_DTORS_BODY |
| 61 |
|
| 62 |
/* Register static destructors to run from __cxa_atexit instead of putting |
| 63 |
them into a .mod_term_funcs section. */ |
| 64 |
|
| 65 |
#define TARGET_DTORS_FROM_CXA_ATEXIT true |
| 66 |
|
| 67 |
/* The string value for __SIZE_TYPE__. */ |
| 68 |
|
| 69 |
#ifndef SIZE_TYPE |
| 70 |
#define SIZE_TYPE "long unsigned int" |
| 71 |
#endif |
| 72 |
|
| 73 |
/* Type used for ptrdiff_t, as a string used in a declaration. */ |
| 74 |
|
| 75 |
#undef PTRDIFF_TYPE |
| 76 |
#define PTRDIFF_TYPE "int" |
| 77 |
|
| 78 |
/* wchar_t is int. */ |
| 79 |
|
| 80 |
#undef WCHAR_TYPE |
| 81 |
#define WCHAR_TYPE "int" |
| 82 |
#undef WCHAR_TYPE_SIZE |
| 83 |
#define WCHAR_TYPE_SIZE 32 |
| 84 |
|
| 85 |
#define INT8_TYPE "signed char" |
| 86 |
#define INT16_TYPE "short int" |
| 87 |
#define INT32_TYPE "int" |
| 88 |
#define INT64_TYPE "long long int" |
| 89 |
#define UINT8_TYPE "unsigned char" |
| 90 |
#define UINT16_TYPE "short unsigned int" |
| 91 |
#define UINT32_TYPE "unsigned int" |
| 92 |
#define UINT64_TYPE "long long unsigned int" |
| 93 |
|
| 94 |
#define INT_LEAST8_TYPE "signed char" |
| 95 |
#define INT_LEAST16_TYPE "short int" |
| 96 |
#define INT_LEAST32_TYPE "int" |
| 97 |
#define INT_LEAST64_TYPE "long long int" |
| 98 |
#define UINT_LEAST8_TYPE "unsigned char" |
| 99 |
#define UINT_LEAST16_TYPE "short unsigned int" |
| 100 |
#define UINT_LEAST32_TYPE "unsigned int" |
| 101 |
#define UINT_LEAST64_TYPE "long long unsigned int" |
| 102 |
|
| 103 |
#define INT_FAST8_TYPE "signed char" |
| 104 |
#define INT_FAST16_TYPE "short int" |
| 105 |
#define INT_FAST32_TYPE "int" |
| 106 |
#define INT_FAST64_TYPE "long long int" |
| 107 |
#define UINT_FAST8_TYPE "unsigned char" |
| 108 |
#define UINT_FAST16_TYPE "short unsigned int" |
| 109 |
#define UINT_FAST32_TYPE "unsigned int" |
| 110 |
#define UINT_FAST64_TYPE "long long unsigned int" |
| 111 |
|
| 112 |
#define INTPTR_TYPE "long int" |
| 113 |
#define UINTPTR_TYPE "long unsigned int" |
| 114 |
|
| 115 |
#define SIG_ATOMIC_TYPE "int" |
| 116 |
|
| 117 |
/* Default to using the NeXT-style runtime, since that's what is |
| 118 |
pre-installed on Darwin systems. */ |
| 119 |
|
| 120 |
#define NEXT_OBJC_RUNTIME 100508 |
| 121 |
|
| 122 |
/* Don't default to pcc-struct-return, because gcc is the only compiler, and |
| 123 |
we want to retain compatibility with older gcc versions. */ |
| 124 |
|
| 125 |
#undef DEFAULT_PCC_STRUCT_RETURN |
| 126 |
#define DEFAULT_PCC_STRUCT_RETURN 0 |
| 127 |
|
| 128 |
/* True if pragma ms_struct is in effect. */ |
| 129 |
extern GTY(()) int darwin_ms_struct; |
| 130 |
|
| 131 |
/* Darwin has a user convenience feature where some linker options are exposed |
| 132 |
at the driver level (so one can type "-all_load" instead of "-Wl,-all_load" |
| 133 |
or "-Xlinker -all_load"). We retain this, but now these options are all |
| 134 |
marked as 'Driver' and we process them as early as possible so that they |
| 135 |
get allocated to the right toolchain command. There are a couple of special |
| 136 |
cases where these driver opts are used multiple times, or to control |
| 137 |
operations on more than one command (e.g. dynamiclib). These are handled |
| 138 |
specially and we then add %<xxxx specs for the commands that _don't_ need |
| 139 |
them. |
| 140 |
We keep a couple of cases where a negative option originally appeared after |
| 141 |
the positive alternate, potentially overriding it. |
| 142 |
When we report an error with %e, it seems necessary to strip the option |
| 143 |
before doing so, otherwise it survives to the cc1 command line (%e doesn't |
| 144 |
appear to abort the program before this). |
| 145 |
Right now there's no mechanism to split up the "variable portion" (%*) of |
| 146 |
the matched spec string, so where we have some driver specs that take 2 |
| 147 |
or 3 arguments, these cannot be processed here, but are deferred until the |
| 148 |
LINK_SPEC, where they are copied verbatim. */ |
| 149 |
|
| 150 |
#undef SUBTARGET_DRIVER_SELF_SPECS |
| 151 |
#define SUBTARGET_DRIVER_SELF_SPECS \ |
| 152 |
"%{static|fapple-kext|mkernel:%{shared|dynamic|dynamiclib: \ |
| 153 |
%econflicting code generation switches}}",\ |
| 154 |
"%{shared|dynamiclib:-Xlinker -dylib \ |
| 155 |
%{allowable_client*:-Xlinker -allowable_client -Xlinker %*} \ |
| 156 |
%<allowable_client* \ |
| 157 |
%{bundle_loader*: %<bundle_loader* \ |
| 158 |
%e-bundle_loader not allowed with -dynamiclib} \ |
| 159 |
%{client_name*: %<client_name* \ |
| 160 |
%e-client_name not allowed with -dynamiclib} \ |
| 161 |
%{compatibility_version*:\ |
| 162 |
-Xlinker -dylib_compatibility_version -Xlinker %*} \ |
| 163 |
%<compatibility_version* \ |
| 164 |
%{current_version*:-Xlinker -dylib_current_version -Xlinker %*} \ |
| 165 |
%<current_version* \ |
| 166 |
%{install_name*:-Xlinker -dylib_install_name -Xlinker %* } \ |
| 167 |
%<install_name* \ |
| 168 |
%{keep_private_externs: %<keep_private_externs \ |
| 169 |
%e-keep_private_externs not allowed with -dynamiclib} \ |
| 170 |
%{private_bundle: %<private_bundle \ |
| 171 |
%e-private_bundle not allowed with -dynamiclib} \ |
| 172 |
}", \ |
| 173 |
"%{!dynamiclib:%{!shared: \ |
| 174 |
%{bundle_loader*:-Xlinker -bundle_loader -Xlinker %*} \ |
| 175 |
%<bundle_loader* \ |
| 176 |
%{client_name*:-Xlinker -client_name -Xlinker %*} \ |
| 177 |
%<client_name* \ |
| 178 |
%{compatibility_version*: %<compatibility_version* \ |
| 179 |
%e-compatibility_version only allowed with -dynamiclib} \ |
| 180 |
%{current_version*: %<current_version* \ |
| 181 |
%e-current_version only allowed with -dynamiclib} \ |
| 182 |
%{install_name*: %<install_name* \ |
| 183 |
%e-install_name only allowed with -dynamiclib} \ |
| 184 |
%{keep_private_externs:-Xlinker -keep_private_externs} \ |
| 185 |
%<keep_private_externs \ |
| 186 |
%{private_bundle:-Xlinker -private_bundle} \ |
| 187 |
%<private_bundle \ |
| 188 |
}}", \ |
| 189 |
"%{all_load:-Xlinker -all_load} %<all_load", \ |
| 190 |
"%{arch_errors_fatal:-Xlinker -arch_errors_fatal} \ |
| 191 |
%<arch_errors_fatal", \ |
| 192 |
"%{bind_at_load:-Xlinker -bind_at_load} %<bind_at_load", \ |
| 193 |
"%{bundle:%{!dynamiclib:%{!shared: -Xlinker -bundle; \ |
| 194 |
:%e-bundle not allowed with -shared}; \ |
| 195 |
:%e-bundle not allowed with -dynamiclib}}", \ |
| 196 |
"%{dead_strip:-Xlinker -dead_strip} %<dead_strip", \ |
| 197 |
"%{dylib_file*:-Xlinker -dylib_file -Xlinker %*} %<dylib_file*", \ |
| 198 |
"%{dylinker:-Xlinker -dylinker} %<dylinker", \ |
| 199 |
"%{dylinker_install_name*:-Xlinker -dylinker_install_name -Xlinker %*}\ |
| 200 |
%<dylinker_install_name*", \ |
| 201 |
"%{exported_symbols_list*:-Xlinker -exported_symbols_list -Xlinker %*}\ |
| 202 |
%<exported_symbols_list", \ |
| 203 |
"%{findirect-virtual-calls: -fapple-kext} %<findirect-virtual-calls", \ |
| 204 |
"%{fterminated-vtables: -fapple-kext} %<fterminated-vtables", \ |
| 205 |
"%{fapple-kext|mkernel:-static}", \ |
| 206 |
"%{filelist*:-Xlinker -filelist -Xlinker %*} %<filelist*", \ |
| 207 |
"%{flat_namespace:-Xlinker -flat_namespace} %<flat_namespace", \ |
| 208 |
"%{force_cpusubtype_ALL:-Xassembler -force_cpusubtype_ALL} ", \ |
| 209 |
"%{force_flat_namespace: \ |
| 210 |
%{!dynamiclib:-Xlinker -force_flat_namespace; \ |
| 211 |
:%e-force_flat_namespace not allowed with -dynamiclib}} \ |
| 212 |
%<force_flat_namespace", \ |
| 213 |
"%{framework*:-Xlinker -framework -Xlinker %*} %<framework*", \ |
| 214 |
"%{gfull:-g -fno-eliminate-unused-debug-symbols} %<gfull", \ |
| 215 |
"%{gused:-g -feliminate-unused-debug-symbols} %<gused", \ |
| 216 |
"%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} \ |
| 217 |
%<gsplit-dwarf", \ |
| 218 |
"%{headerpad_max_install_names:-Xlinker -headerpad_max_install_names}\ |
| 219 |
%<headerpad_max_install_names", \ |
| 220 |
"%{image_base*:-Xlinker -image_base -Xlinker %*} %<image_base*", \ |
| 221 |
"%{init*:-Xlinker -init -Xlinker %*} %<init*", \ |
| 222 |
"%{multi_module:-Xlinker -multi_module} %<multi_module", \ |
| 223 |
"%{multiply_defined*:-Xlinker -multiply_defined -Xlinker %*} ", \ |
| 224 |
"%{multiplydefinedunused*:\ |
| 225 |
-Xlinker -multiply_defined_unused -Xlinker %*} \ |
| 226 |
%<multiplydefinedunused* ", \ |
| 227 |
"%{no_dead_strip_inits_and_terms:\ |
| 228 |
-Xlinker -no_dead_strip_inits_and_terms} \ |
| 229 |
%<no_dead_strip_inits_and_terms", \ |
| 230 |
"%{nofixprebinding:-Xlinker -nofixprebinding} %<nofixprebinding", \ |
| 231 |
"%{nomultidefs:-Xlinker -nomultidefs} %<nomultidefs", \ |
| 232 |
"%{pagezero_size*:-Xlinker -pagezero_size -Xlinker %*} \ |
| 233 |
%<pagezero_size", \ |
| 234 |
"%{prebind:-Xlinker -prebind} %<prebind", \ |
| 235 |
"%{noprebind:-Xlinker -noprebind} %<noprebind", \ |
| 236 |
"%{prebind_all_twolevel_modules:\ |
| 237 |
-Xlinker -prebind_all_twolevel_modules} \ |
| 238 |
%<prebind_all_twolevel_modules", \ |
| 239 |
"%{preload:-Xlinker -preload} %<preload", \ |
| 240 |
"%{read_only_relocs*:-Xlinker -read_only_relocs -Xlinker %*} \ |
| 241 |
%<read_only_relocs*", \ |
| 242 |
"%{rpath*: -Xlinker -rpath -Xlinker %*}", \ |
| 243 |
"%{seg_addr_table_filename*: \ |
| 244 |
-Xlinker -seg_addr_table_filename -Xlinker %*} \ |
| 245 |
%<seg_addr_table_filename*", \ |
| 246 |
"%{seg_addr_table*:-Xlinker -seg_addr_table -Xlinker %*} \ |
| 247 |
%<seg_addr_table*", \ |
| 248 |
"%{seg1addr*:-Xlinker -image_base -Xlinker %*} %<seg1addr*", \ |
| 249 |
"%{seglinkedit:-Xlinker -seglinkedit} %<seglinkedit", \ |
| 250 |
"%{noseglinkedit:-Xlinker -noseglinkedit} %<noseglinkedit", \ |
| 251 |
"%{segs_read_only_addr*:-Xlinker -segs_read_only_addr -Xlinker %*} \ |
| 252 |
%<segs_read_only_addr*", \ |
| 253 |
"%{segs_read_write_addr*:-Xlinker -segs_read_write_addr -Xlinker %*} \ |
| 254 |
%<segs_read_write_addr*", \ |
| 255 |
"%{single_module:-Xlinker -single_module} %<single_module", \ |
| 256 |
"%{sub_library*:-Xlinker -sub_library -Xlinker %*} %<sub_library*", \ |
| 257 |
"%{sub_umbrella*:-Xlinker -sub_umbrella -Xlinker %*} %<sub_umbrella*",\ |
| 258 |
"%{twolevel_namespace:-Xlinker -twolevel_namespace} \ |
| 259 |
%<twolevel_namespace", \ |
| 260 |
"%{twolevel_namespace_hints:-Xlinker -twolevel_namespace_hints} \ |
| 261 |
%<twolevel_namespace_hints", \ |
| 262 |
"%{umbrella*:-Xlinker -umbrella -Xlinker %*} %<umbrella*", \ |
| 263 |
"%{undefined*:-Xlinker -undefined -Xlinker %*} %<undefined*", \ |
| 264 |
"%{unexported_symbols_list*:\ |
| 265 |
-Xlinker -unexported_symbols_list -Xlinker %*} \ |
| 266 |
%<unexported_symbols_list*", \ |
| 267 |
"%{weak_reference_mismatches*:\ |
| 268 |
-Xlinker -weak_reference_mismatches -Xlinker %*} \ |
| 269 |
%<weak_reference_mismatches*", \ |
| 270 |
"%{weak_framework*: -Xlinker -weak_framework -Xlinker %*} \ |
| 271 |
%<weak_framework*", \ |
| 272 |
"%{whyload:-Xlinker -whyload} %<whyload", \ |
| 273 |
"%{whatsloaded:-Xlinker -whatsloaded} %<whatsloaded", \ |
| 274 |
"%{w:-Xlinker -w}", \ |
| 275 |
"%<y*", \ |
| 276 |
"%<Mach " |
| 277 |
|
| 278 |
#if LD64_HAS_DEMANGLE |
| 279 |
#define DARWIN_LD_DEMANGLE " -demangle " |
| 280 |
#else |
| 281 |
#define DARWIN_LD_DEMANGLE "" |
| 282 |
#endif |
| 283 |
|
| 284 |
#if LD64_HAS_EXPORT_DYNAMIC |
| 285 |
#define DARWIN_RDYNAMIC "%{rdynamic:-export_dynamic}" |
| 286 |
#else |
| 287 |
#define DARWIN_RDYNAMIC "%{rdynamic:%nrdynamic is not supported}" |
| 288 |
#endif |
| 289 |
|
| 290 |
#if LD64_HAS_MACOS_VERSION_MIN |
| 291 |
# define DARWIN_PLATFORM_ID \ |
| 292 |
"%{mmacosx-version-min=*:-macos_version_min %*} " |
| 293 |
#else |
| 294 |
# if LD64_HAS_PLATFORM_VERSION |
| 295 |
# define DARWIN_PLATFORM_ID \ |
| 296 |
"%{mmacosx-version-min=*: -platform_version macos %* 0.0} " |
| 297 |
# else |
| 298 |
# define DARWIN_PLATFORM_ID \ |
| 299 |
"%{mmacosx-version-min=*:-macosx_version_min %*} " |
| 300 |
# endif |
| 301 |
#endif |
| 302 |
|
| 303 |
/* Code built with mdynamic-no-pic does not support PIE/PIC, so we disallow |
| 304 |
these combinations; we also ensure that the no_pie option is passed to |
| 305 |
ld64 on system versions that default to PIE when mdynamic-no-pic is given. |
| 306 |
FIXME: we should check that the linker supports the -pie and -no_pie. |
| 307 |
options. */ |
| 308 |
#define DARWIN_PIE_SPEC \ |
| 309 |
"%{pie|fpie|fPIE:\ |
| 310 |
%{mdynamic-no-pic: \ |
| 311 |
%n'-mdynamic-no-pic' overrides '-pie', '-fpie' or '-fPIE'; \ |
| 312 |
:%:version-compare(>= 10.5 mmacosx-version-min= -pie) }; \ |
| 313 |
mdynamic-no-pic:%:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } " |
| 314 |
|
| 315 |
#define DARWIN_NOPIE_SPEC \ |
| 316 |
"%{no-pie|fno-pie|fno-PIE: \ |
| 317 |
%:version-compare(>= 10.7 mmacosx-version-min= -no_pie) }" |
| 318 |
|
| 319 |
#define DARWIN_CC1_SPEC \ |
| 320 |
"%<dynamic %<force_cpusubtype_ALL %<multiply_defined* %<dynamiclib" |
| 321 |
|
| 322 |
/* When we are using embedded runpaths DARWIN_AT_RPATH is set. */ |
| 323 |
#if DARWIN_AT_RPATH |
| 324 |
# define DARWIN_RPATH_LINK \ |
| 325 |
"%{!r:%{!nostdlib:%{!nodefaultrpaths:%(darwin_rpaths)}}}" |
| 326 |
# define DARWIN_SHARED_LIBGCC "-lgcc_s.1.1" |
| 327 |
# define DARWIN_SHARED_WEAK_ADDS " " |
| 328 |
#else |
| 329 |
# define DARWIN_RPATH_LINK "" |
| 330 |
# define DARWIN_SHARED_LIBGCC \ |
| 331 |
"%:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1)" |
| 332 |
# define DARWIN_SHARED_WEAK_ADDS \ |
| 333 |
"%{%:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w): \ |
| 334 |
" DARWIN_HEAP_T_LIB "}" |
| 335 |
#endif |
| 336 |
|
| 337 |
|
| 338 |
/* We might elect to add a path even when this compiler does not use embedded |
| 339 |
run paths, so that we can use libraries from an alternate compiler that is |
| 340 |
using embedded runpaths. */ |
| 341 |
#if DARWIN_DO_EXTRA_RPATH |
| 342 |
# define DARWIN_EXTRA_RPATH \ |
| 343 |
"%{!r:%{!nostdlib:%{!nodefaultrpaths:\ |
| 344 |
%:version-compare(>= 10.5 mmacosx-version-min= -rpath) \ |
| 345 |
%:version-compare(>= 10.5 mmacosx-version-min= " DARWIN_ADD_RPATH ") \ |
| 346 |
}}}" |
| 347 |
#else |
| 348 |
# define DARWIN_EXTRA_RPATH "" |
| 349 |
#endif |
| 350 |
|
| 351 |
#define SUBSUBTARGET_OVERRIDE_OPTIONS \ |
| 352 |
do { \ |
| 353 |
darwin_override_options (); \ |
| 354 |
} while (0) |
| 355 |
|
| 356 |
#define SUBTARGET_C_COMMON_OVERRIDE_OPTIONS do { \ |
| 357 |
if (flag_mkernel || flag_apple_kext) \ |
| 358 |
{ \ |
| 359 |
if (flag_use_cxa_atexit == 2) \ |
| 360 |
flag_use_cxa_atexit = 0; \ |
| 361 |
/* kexts should always be built without the coalesced sections \ |
| 362 |
because the kernel loader doesn't grok such sections. */ \ |
| 363 |
flag_weak = 0; \ |
| 364 |
/* No RTTI in kexts. */ \ |
| 365 |
flag_rtti = 0; \ |
| 366 |
} \ |
| 367 |
} while (0) |
| 368 |
|
| 369 |
/* Machine dependent cpp options. Don't add more options here, add |
| 370 |
them to darwin_cpp_builtins in darwin-c.cc. */ |
| 371 |
|
| 372 |
#undef CPP_SPEC |
| 373 |
#define CPP_SPEC "%{static:%{!dynamic:-D__STATIC__}}%{!static:-D__DYNAMIC__}" \ |
| 374 |
" %{pthread:-D_REENTRANT} " |
| 375 |
|
| 376 |
/* This is a fix for PR41260 by passing -no_compact_unwind on darwin10 and |
| 377 |
later until the assembler, linker and libunwind are able to deal with the |
| 378 |
output from GCC. |
| 379 |
|
| 380 |
FIXME: we should check that the linker supports the option. |
| 381 |
*/ |
| 382 |
|
| 383 |
#define DARWIN_NOCOMPACT_UNWIND \ |
| 384 |
" %:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) " |
| 385 |
|
| 386 |
/* In Darwin linker specs we can put -lcrt0.o and ld will search the library |
| 387 |
path for crt0.o or -lcrtx.a and it will search for libcrtx.a. As for |
| 388 |
other ports, we can also put xxx.{o,a}%s and get the appropriate complete |
| 389 |
startfile absolute directory. This latter point is important when we want |
| 390 |
to override ld's rule of .dylib being found ahead of .a and the user wants |
| 391 |
the convenience library to be linked. */ |
| 392 |
|
| 393 |
/* The LINK_COMMAND spec is mostly a clone of the standard LINK_COMMAND_SPEC, |
| 394 |
plus precomp, libtool, and fat build additions. |
| 395 |
|
| 396 |
In general, random Darwin linker flags should go into LINK_SPEC |
| 397 |
instead of LINK_COMMAND_SPEC. The command spec is better for |
| 398 |
specifying the handling of options understood by generic Unix |
| 399 |
linkers, and for positional arguments like libraries. */ |
| 400 |
|
| 401 |
#define LINK_COMMAND_SPEC_A \ |
| 402 |
"%{!c:%{!E:%{!S:%{!M:%{!MM:%{!fsyntax-only:%{!fdump=*: \ |
| 403 |
%(linker)" \ |
| 404 |
DARWIN_LD_DEMANGLE \ |
| 405 |
LINK_PLUGIN_SPEC \ |
| 406 |
"%{flto*:%<fcompare-debug*} \ |
| 407 |
%{flto} %{fno-lto} %{flto=*} \ |
| 408 |
%l " \ |
| 409 |
DARWIN_PLATFORM_ID \ |
| 410 |
LINK_COMPRESS_DEBUG_SPEC \ |
| 411 |
"%X %{s} %{t} %{Z} %{u*} \ |
| 412 |
%{e*} %{r} \ |
| 413 |
%{o*}%{!o:-o a.out} \ |
| 414 |
%{!r:%{!nostdlib:%{!nostartfiles:%S}}} \ |
| 415 |
%{L*} %(link_libgcc) \ |
| 416 |
%{!r:%{!nostdlib:%{!nodefaultlibs: " DARWIN_WEAK_CRTS "}}} \ |
| 417 |
%o \ |
| 418 |
%{!r:%{!nostdlib:%{!nodefaultlibs:\ |
| 419 |
%{fprofile-arcs|fcondition-coverage|fprofile-generate*|coverage:-lgcov} \ |
| 420 |
%{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): \ |
| 421 |
%{static|static-libgcc|static-libstdc++|static-libgfortran: \ |
| 422 |
libgomp.a%s; : -lgomp }} \ |
| 423 |
%{fgnu-tm: \ |
| 424 |
%{static|static-libgcc|static-libstdc++|static-libgfortran: \ |
| 425 |
libitm.a%s; : -litm }} \ |
| 426 |
%{%:sanitize(address): -lasan } \ |
| 427 |
%{%:sanitize(undefined): -lubsan } \ |
| 428 |
%(link_ssp) \ |
| 429 |
%:version-compare(>< 10.6 10.7 mmacosx-version-min= -ld10-uwfef) \ |
| 430 |
%(link_gcc_c_sequence) \ |
| 431 |
%{!nodefaultexport: \ |
| 432 |
%{%:version-compare(>= 10.11 asm_macosx_version_min= -U): \ |
| 433 |
___emutls_get_address -exported_symbol ___emutls_get_address \ |
| 434 |
-U ___emutls_register_common \ |
| 435 |
-exported_symbol ___emutls_register_common \ |
| 436 |
-U ___gcc_nested_func_ptr_created \ |
| 437 |
-exported_symbol ___gcc_nested_func_ptr_created \ |
| 438 |
-U ___gcc_nested_func_ptr_deleted \ |
| 439 |
-exported_symbol ___gcc_nested_func_ptr_deleted \ |
| 440 |
}} \ |
| 441 |
}}}\ |
| 442 |
%{!r:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} "\ |
| 443 |
DARWIN_PIE_SPEC \ |
| 444 |
DARWIN_NOPIE_SPEC \ |
| 445 |
DARWIN_RDYNAMIC \ |
| 446 |
DARWIN_NOCOMPACT_UNWIND \ |
| 447 |
DARWIN_EXTRA_RPATH \ |
| 448 |
DARWIN_RPATH_LINK \ |
| 449 |
"}}}}}}} %<pie %<no-pie %<rdynamic %<X %<rpath %<nodefaultrpaths " |
| 450 |
|
| 451 |
/* Spec that controls whether the debug linker is run automatically for |
| 452 |
a link step. This needs to be done if there is a source file on the |
| 453 |
command line which will result in a temporary object (and debug is |
| 454 |
enabled). */ |
| 455 |
|
| 456 |
#define DSYMUTIL_SPEC \ |
| 457 |
"%{!c:%{!E:%{!S:%{!r:%{!M:%{!MM:%{!fsyntax-only:%{!fdump=*:\ |
| 458 |
%{g*:%{!gctf:%{!gbtf:%{%:debug-level-gt(0): -idsym \ |
| 459 |
%{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm|.s|.f|.f90|\ |
| 460 |
.f95|.f03|.f77|.for|.F|.F90|.F95|.F03|.d: -dsym }\ |
| 461 |
}}}}\ |
| 462 |
}}}}}}}}" |
| 463 |
|
| 464 |
#define LINK_COMMAND_SPEC LINK_COMMAND_SPEC_A DSYMUTIL_SPEC |
| 465 |
|
| 466 |
/* Tell collect2 to run dsymutil for us as necessary. */ |
| 467 |
#define COLLECT_RUN_DSYMUTIL 1 |
| 468 |
|
| 469 |
/* We only want one instance of %G, since libSystem (Darwin's -lc) does not |
| 470 |
depend on libgcc. */ |
| 471 |
#undef LINK_GCC_C_SEQUENCE_SPEC |
| 472 |
#define LINK_GCC_C_SEQUENCE_SPEC \ |
| 473 |
"%G %{!nolibc:%L} " |
| 474 |
|
| 475 |
/* ld64 supports a sysroot, it just has a different name and there's no easy |
| 476 |
way to check for it at config time. */ |
| 477 |
#undef HAVE_LD_SYSROOT |
| 478 |
#define HAVE_LD_SYSROOT 1 |
| 479 |
/* It seems the only (working) way to get a space after %R is to append a |
| 480 |
dangling '/'. */ |
| 481 |
#define SYSROOT_SPEC "%{!isysroot*:-syslibroot %R/ } " |
| 482 |
|
| 483 |
/* Do the same as clang, for now, and insert the sysroot for ld when an |
| 484 |
isysroot is specified. */ |
| 485 |
#define LINK_SYSROOT_SPEC "%{isysroot*:-syslibroot %*} " |
| 486 |
|
| 487 |
/* Suppress the addition of extra prefix paths when a sysroot is in use. */ |
| 488 |
#define STANDARD_STARTFILE_PREFIX_1 "" |
| 489 |
#define STANDARD_STARTFILE_PREFIX_2 "" |
| 490 |
|
| 491 |
|
| 492 |
/* Please keep the random linker options in alphabetical order. |
| 493 |
Note that options taking arguments may appear multiple times on a command |
| 494 |
line with different arguments each time, so put a * after their names so |
| 495 |
all of them get passed. */ |
| 496 |
#define LINK_SPEC \ |
| 497 |
"%{static}%{!static:%{!dynamic:-dynamic}} \ |
| 498 |
%:remove-outfile(-ldl) \ |
| 499 |
%:remove-outfile(-lm) \ |
| 500 |
%:remove-outfile(-lpthread) \ |
| 501 |
%{fgnu-runtime: %{static|static-libgcc: \ |
| 502 |
%:replace-outfile(-lobjc libobjc-gnu.a%s); \ |
| 503 |
:%:replace-outfile(-lobjc -lobjc-gnu )}}\ |
| 504 |
%{static|static-libgcc|static-libgfortran:%:replace-outfile(-lgfortran libgfortran.a%s)}\ |
| 505 |
%{static|static-libgcc|static-libquadmath:%:replace-outfile(-lquadmath libquadmath.a%s)}\ |
| 506 |
%{static|static-libgcc|static-libphobos:%:replace-outfile(-lgphobos libgphobos.a%s)}\ |
| 507 |
%{static|static-libgcc|static-libgcobol:%:replace-outfile(-lgcobol libgcobol.a%s)}\ |
| 508 |
%{static|static-libgcc|static-libstdc++|static-libgfortran:%:replace-outfile(-lgomp libgomp.a%s)}\ |
| 509 |
%{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ libstdc++.a%s)}\ |
| 510 |
%{static|static-libgm2:%:replace-outfile(-lm2pim libm2pim.a%s)}\ |
| 511 |
%{static|static-libgm2:%:replace-outfile(-lm2iso libm2iso.a%s)}\ |
| 512 |
%{static|static-libgm2:%:replace-outfile(-lm2min libm2min.a%s)}\ |
| 513 |
%{static|static-libgm2:%:replace-outfile(-lm2log libm2log.a%s)}\ |
| 514 |
%{static|static-libgm2:%:replace-outfile(-lm2cor libm2cor.a%s)}\ |
| 515 |
%{force_cpusubtype_ALL:-arch %(darwin_arch)} \ |
| 516 |
%{!force_cpusubtype_ALL:-arch %(darwin_subarch)} "\ |
| 517 |
LINK_SYSROOT_SPEC \ |
| 518 |
"%{!multiply_defined*:%{shared-libgcc: \ |
| 519 |
%:version-compare(< 10.5 mmacosx-version-min= -multiply_defined) \ |
| 520 |
%:version-compare(< 10.5 mmacosx-version-min= suppress) }} \ |
| 521 |
%{sectalign*} %{sectcreate*} %{sectobjectsymbols*} %{sectorder*} \ |
| 522 |
%{segaddr*} %{segcreate*} %{segprot*} " |
| 523 |
|
| 524 |
/* Machine dependent libraries. */ |
| 525 |
|
| 526 |
#define LIB_SPEC "%{!static:-lSystem}" |
| 527 |
|
| 528 |
/* Note that by default, -lgcc_eh (which provides a statically-linked unwinder) |
| 529 |
is not used. This is because, in general, we need to unwind through system |
| 530 |
libraries that are linked with the shared unwinder in libunwind (or libgcc_s |
| 531 |
for OSX 10.4/5 [darwin8/9]). |
| 532 |
|
| 533 |
When -static-libgcc is forced: < 10.6, use the unwinder in libgcc_eh (and |
| 534 |
find the emultls impl. there too). |
| 535 |
|
| 536 |
For -static-libgcc: >= 10.6, the unwinder *still* comes from libSystem and |
| 537 |
we find the emutls impl from lemutls_w. In either case, the builtins etc. |
| 538 |
are linked from -lgcc. The eh library is still available so that it could |
| 539 |
be specified explicitly if there is some reason to do so. |
| 540 |
|
| 541 |
When we have specified shared-libgcc or any case that might require |
| 542 |
exceptions, we pull the libgcc content (including emulated tls) from |
| 543 |
-lgcc_s.1.1 in GCC and the unwinder from /usr/lib/libgcc_s.1 for < 10.6 and |
| 544 |
libSystem for >= 10.6 respectively. |
| 545 |
Otherwise, we just link the emutls/builtins from convenience libs. |
| 546 |
|
| 547 |
We have to work around that DYLD_XXXX are disabled in macOS 10.11+ which |
| 548 |
means that any bootstrap trying to use a shared libgcc with a bumped SO- |
| 549 |
name will fail. This means that we do not accept shared libgcc for these |
| 550 |
versions (the primary reason for forcing a shared libgcc was that it |
| 551 |
contained the unwinder on Darwin8 and 9). |
| 552 |
|
| 553 |
When using the shared version of gcc_s.1.1 the unwinder is provided by: |
| 554 |
* Prior to 10.3.9, then we have to link the static eh lib, since there |
| 555 |
is no shared unwinder version on the system. |
| 556 |
* from 10.3.9 to 10.5, from /usr/lib/libgcc_s.1.dylib |
| 557 |
* from 10.6 onwards, from libSystem.dylib |
| 558 |
*/ |
| 559 |
#undef REAL_LIBGCC_SPEC |
| 560 |
#define REAL_LIBGCC_SPEC \ |
| 561 |
"%{static-libgcc|static: \ |
| 562 |
%:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh); \ |
| 563 |
shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \ |
| 564 |
" DARWIN_SHARED_LIBGCC " \ |
| 565 |
%:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh) \ |
| 566 |
%:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \ |
| 567 |
%:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5) \ |
| 568 |
} -lgcc " |
| 569 |
|
| 570 |
#define DARWIN_WEAK_CRTS \ |
| 571 |
"%{static-libgcc|static: \ |
| 572 |
%{%:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w): \ |
| 573 |
" DARWIN_HEAP_T_LIB "} ; \ |
| 574 |
: -lemutls_w " DARWIN_HEAP_T_LIB " \ |
| 575 |
}" |
| 576 |
|
| 577 |
/* We specify crt0.o as -lcrt0.o so that ld will search the library path. */ |
| 578 |
|
| 579 |
#undef STARTFILE_SPEC |
| 580 |
#define STARTFILE_SPEC \ |
| 581 |
"%{dynamiclib|shared: %(darwin_dylib1) %{fgnu-tm: -lcrttms.o}} \ |
| 582 |
%{!dynamiclib:%{!shared:%{bundle:%(darwin_bundle1)} \ |
| 583 |
%{!bundle:%{pg:%{static:-lgcrt0.o} \ |
| 584 |
%{!static:%{object:-lgcrt0.o} \ |
| 585 |
%{!object:%{preload:-lgcrt0.o} \ |
| 586 |
%{!preload:-lgcrt1.o \ |
| 587 |
%:version-compare(>= 10.8 mmacosx-version-min= -no_new_main) \ |
| 588 |
%(darwin_crt2)}}}} \ |
| 589 |
%{!pg:%{static:-lcrt0.o} \ |
| 590 |
%{!static:%{object:-lcrt0.o} \ |
| 591 |
%{!object:%{preload:-lcrt0.o} \ |
| 592 |
%{!preload: %(darwin_crt1) \ |
| 593 |
%(darwin_crt2)}}}}}}} \ |
| 594 |
%(darwin_crt3) " |
| 595 |
|
| 596 |
/* We want a destructor last in the list. */ |
| 597 |
#define TM_DESTRUCTOR "%{fgnu-tm: -lcrttme.o}" |
| 598 |
#define ENDFILE_SPEC TM_DESTRUCTOR |
| 599 |
|
| 600 |
#define DARWIN_EXTRA_SPECS \ |
| 601 |
{ "darwin_crt1", DARWIN_CRT1_SPEC }, \ |
| 602 |
{ "darwin_crt2", DARWIN_CRT2_SPEC }, \ |
| 603 |
{ "darwin_crt3", DARWIN_CRT3_SPEC }, \ |
| 604 |
{ "darwin_dylib1", DARWIN_DYLIB1_SPEC }, \ |
| 605 |
{ "darwin_bundle1", DARWIN_BUNDLE1_SPEC }, \ |
| 606 |
{ "darwin_rpaths", DARWIN_RPATH_SPEC }, |
| 607 |
|
| 608 |
#define DARWIN_CRT1_SPEC \ |
| 609 |
"%:version-compare(!> 10.5 mmacosx-version-min= -lcrt1.o) \ |
| 610 |
%:version-compare(>< 10.5 10.6 mmacosx-version-min= -lcrt1.10.5.o) \ |
| 611 |
%:version-compare(>< 10.6 10.8 mmacosx-version-min= -lcrt1.10.6.o) \ |
| 612 |
%{fgnu-tm: -lcrttms.o}" |
| 613 |
|
| 614 |
#define DARWIN_CRT2_SPEC "" |
| 615 |
|
| 616 |
/* crt3.o provides __cxa_atexit on systems that don't have it (and a fix |
| 617 |
up for faulty versions on 10.4). Since it's only used with C++, which |
| 618 |
requires passing -shared-libgcc, key off that to avoid unnecessarily |
| 619 |
adding a destructor to every program built for 10.4 or earlier. */ |
| 620 |
|
| 621 |
#define DARWIN_CRT3_SPEC \ |
| 622 |
"%{shared-libgcc:%:version-compare(< 10.5 mmacosx-version-min= crt3.o%s)}" |
| 623 |
|
| 624 |
#define DARWIN_DYLIB1_SPEC \ |
| 625 |
"%:version-compare(!> 10.5 mmacosx-version-min= -ldylib1.o) \ |
| 626 |
%:version-compare(>< 10.5 10.6 mmacosx-version-min= -ldylib1.10.5.o)" |
| 627 |
|
| 628 |
#define DARWIN_BUNDLE1_SPEC \ |
| 629 |
"%{!static:%:version-compare(< 10.6 mmacosx-version-min= -lbundle1.o) \ |
| 630 |
%{fgnu-tm: -lcrttms.o}}" |
| 631 |
|
| 632 |
#if DARWIN_AT_RPATH |
| 633 |
/* A default rpath, that picks up dependent libraries installed in the same |
| 634 |
director as one being loaded. */ |
| 635 |
#define DARWIN_RPATH_SPEC \ |
| 636 |
"%:version-compare(>= 10.5 mmacosx-version-min= -rpath) \ |
| 637 |
%{%:version-compare(>= 10.5 mmacosx-version-min= @loader_path): %P }" |
| 638 |
#else |
| 639 |
#define DARWIN_RPATH_SPEC "" |
| 640 |
#endif |
| 641 |
|
| 642 |
#ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION |
| 643 |
/* Emit macosx version (but only major). */ |
| 644 |
#define ASM_MMACOSX_VERSION_MIN_SPEC \ |
| 645 |
"%{asm_macosx_version_min=*: -mmacosx-version-min=%* } \ |
| 646 |
%<asm_macosx_version_min=* " |
| 647 |
#else |
| 648 |
#define ASM_MMACOSX_VERSION_MIN_SPEC " %<asm_macosx_version_min=* " |
| 649 |
#endif |
| 650 |
|
| 651 |
#if HAVE_GNU_AS |
| 652 |
/* The options are added in gcc.cc for this case. */ |
| 653 |
#define ASM_OPTIONS "" |
| 654 |
#else |
| 655 |
/* When we detect that we're cctools or llvm as, we need to insert the right |
| 656 |
additional options. Actually, currently these are the same as GAS. */ |
| 657 |
#define ASM_OPTIONS "%{v} %{w:-W} %{I*}" |
| 658 |
#endif |
| 659 |
|
| 660 |
#define AS_NEEDS_DASH_FOR_PIPED_INPUT |
| 661 |
|
| 662 |
/* Default Darwin ASM_SPEC, very simple. */ |
| 663 |
#define ASM_SPEC \ |
| 664 |
"%{static} -arch %(darwin_arch) " \ |
| 665 |
ASM_OPTIONS ASM_MMACOSX_VERSION_MIN_SPEC |
| 666 |
|
| 667 |
#define ASM_DEBUG_SPEC "" |
| 668 |
#undef ASM_DEBUG_OPTION_SPEC |
| 669 |
#define ASM_DEBUG_OPTION_SPEC "" |
| 670 |
|
| 671 |
#define ASM_FINAL_SPEC \ |
| 672 |
"%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} \ |
| 673 |
%<gsplit-dwarf" |
| 674 |
|
| 675 |
/* We now require C++11 to bootstrap and newer tools than those based on |
| 676 |
stabs, so require DWARF-2, even if stabs is supported by the assembler. */ |
| 677 |
|
| 678 |
#define DWARF2_DEBUGGING_INFO 1 |
| 679 |
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG |
| 680 |
|
| 681 |
#define DEBUG_FRAME_SECTION "__DWARF,__debug_frame,regular,debug" |
| 682 |
#define DEBUG_INFO_SECTION "__DWARF,__debug_info,regular,debug" |
| 683 |
#define DEBUG_ABBREV_SECTION "__DWARF,__debug_abbrev,regular,debug" |
| 684 |
#define DEBUG_ARANGES_SECTION "__DWARF,__debug_aranges,regular,debug" |
| 685 |
#define DEBUG_MACINFO_SECTION "__DWARF,__debug_macinfo,regular,debug" |
| 686 |
#define DEBUG_LINE_SECTION "__DWARF,__debug_line,regular,debug" |
| 687 |
#define DEBUG_LOC_SECTION "__DWARF,__debug_loc,regular,debug" |
| 688 |
#define DEBUG_LOCLISTS_SECTION "__DWARF,__debug_loclists,regular,debug" |
| 689 |
|
| 690 |
#define DEBUG_STR_SECTION "__DWARF,__debug_str,regular,debug" |
| 691 |
#define DEBUG_STR_OFFSETS_SECTION "__DWARF,__debug_str_offs,regular,debug" |
| 692 |
#define DEBUG_RANGES_SECTION "__DWARF,__debug_ranges,regular,debug" |
| 693 |
#define DEBUG_RNGLISTS_SECTION "__DWARF,__debug_rnglists,regular,debug" |
| 694 |
#define DEBUG_MACRO_SECTION "__DWARF,__debug_macro,regular,debug" |
| 695 |
|
| 696 |
#define DEBUG_LTO_INFO_SECTION "__GNU_DWARF_LTO,__debug_info,regular,debug" |
| 697 |
#define DEBUG_LTO_ABBREV_SECTION "__GNU_DWARF_LTO,__debug_abbrev,regular,debug" |
| 698 |
#define DEBUG_LTO_MACINFO_SECTION "__GNU_DWARF_LTO,__debug_macinfo,regular,debug" |
| 699 |
#define DEBUG_LTO_LINE_SECTION "__GNU_DWARF_LTO,__debug_line,regular,debug" |
| 700 |
#define DEBUG_LTO_STR_SECTION "__GNU_DWARF_LTO,__debug_str,regular,debug" |
| 701 |
#define DEBUG_LTO_MACRO_SECTION "__GNU_DWARF_LTO,__debug_macro,regular,debug" |
| 702 |
|
| 703 |
#define TARGET_WANT_DEBUG_PUB_SECTIONS true |
| 704 |
#define DEBUG_PUBNAMES_SECTION ((debug_generate_pub_sections == 2) \ |
| 705 |
? "__DWARF,__debug_gnu_pubn,regular,debug" \ |
| 706 |
: "__DWARF,__debug_pubnames,regular,debug") |
| 707 |
|
| 708 |
#define DEBUG_PUBTYPES_SECTION ((debug_generate_pub_sections == 2) \ |
| 709 |
? "__DWARF,__debug_gnu_pubt,regular,debug" \ |
| 710 |
: "__DWARF,__debug_pubtypes,regular,debug") |
| 711 |
|
| 712 |
/* GCC's definition of 'one_only' is the same as its definition of 'weak'. */ |
| 713 |
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) |
| 714 |
|
| 715 |
/* Mach-O supports 'weak imports', and 'weak definitions' in coalesced |
| 716 |
sections. machopic_select_section ensures that weak variables go in |
| 717 |
coalesced sections. Weak aliases (or any other kind of aliases) are |
| 718 |
not supported. Weak symbols that aren't visible outside the .s file |
| 719 |
are not supported. */ |
| 720 |
#define ASM_WEAKEN_DECL(FILE, DECL, NAME, ALIAS) \ |
| 721 |
do { \ |
| 722 |
if (ALIAS) \ |
| 723 |
{ \ |
| 724 |
warning (0, "alias definitions not supported in Mach-O; ignored"); \ |
| 725 |
break; \ |
| 726 |
} \ |
| 727 |
\ |
| 728 |
if (! DECL_EXTERNAL (DECL) && TREE_PUBLIC (DECL)) \ |
| 729 |
targetm.asm_out.globalize_label (FILE, NAME); \ |
| 730 |
if (DECL_EXTERNAL (DECL)) \ |
| 731 |
fputs ("\t.weak_reference ", FILE); \ |
| 732 |
else if (lookup_attribute ("weak_import", DECL_ATTRIBUTES (DECL))) \ |
| 733 |
break; \ |
| 734 |
else if (TREE_PUBLIC (DECL)) \ |
| 735 |
fputs ("\t.weak_definition ", FILE); \ |
| 736 |
else \ |
| 737 |
break; \ |
| 738 |
assemble_name (FILE, NAME); \ |
| 739 |
fputc ('\n', FILE); \ |
| 740 |
} while (0) |
| 741 |
|
| 742 |
/* Darwin has the pthread routines in libSystem, which every program |
| 743 |
links to, so there's no need for weak-ness for that. */ |
| 744 |
#define GTHREAD_USE_WEAK 0 |
| 745 |
|
| 746 |
/* On Darwin, we don't (at the time of writing) have linkonce sections |
| 747 |
with names, so it's safe to make the class data not comdat. */ |
| 748 |
#define TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT hook_bool_void_false |
| 749 |
|
| 750 |
/* For efficiency, on Darwin the RTTI information that is always |
| 751 |
emitted in the standard C++ library should not be COMDAT. */ |
| 752 |
#define TARGET_CXX_LIBRARY_RTTI_COMDAT hook_bool_void_false |
| 753 |
|
| 754 |
/* We make exception information linkonce. */ |
| 755 |
#undef TARGET_USES_WEAK_UNWIND_INFO |
| 756 |
#define TARGET_USES_WEAK_UNWIND_INFO 1 |
| 757 |
|
| 758 |
/* We need to use a nonlocal label for the start of an EH frame: the |
| 759 |
Darwin linker requires that a coalesced section start with a label. |
| 760 |
Unfortunately, it also requires that 'debug' sections don't contain |
| 761 |
labels. */ |
| 762 |
#undef FRAME_BEGIN_LABEL |
| 763 |
#define FRAME_BEGIN_LABEL (for_eh ? "EH_frame" : "Lframe") |
| 764 |
|
| 765 |
/* Emit a label for the FDE corresponding to DECL. EMPTY means |
| 766 |
emit a label for an empty FDE. */ |
| 767 |
#define TARGET_ASM_EMIT_UNWIND_LABEL darwin_emit_unwind_label |
| 768 |
|
| 769 |
/* Emit a label to separate the exception table. */ |
| 770 |
#define TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL darwin_emit_except_table_label |
| 771 |
|
| 772 |
/* Make an EH (personality or LDSA) symbol indirect as needed. */ |
| 773 |
#define TARGET_ASM_MAKE_EH_SYMBOL_INDIRECT darwin_make_eh_symbol_indirect |
| 774 |
|
| 775 |
/* Some of Darwin's unwinders need current frame address state to be reset |
| 776 |
after a DW_CFA_restore_state recovers the register values. */ |
| 777 |
#undef TARGET_ASM_SHOULD_RESTORE_CFA_STATE |
| 778 |
#define TARGET_ASM_SHOULD_RESTORE_CFA_STATE darwin_should_restore_cfa_state |
| 779 |
|
| 780 |
/* Our profiling scheme doesn't LP labels and counter words. */ |
| 781 |
|
| 782 |
#define NO_PROFILE_COUNTERS 1 |
| 783 |
|
| 784 |
#undef INIT_SECTION_ASM_OP |
| 785 |
#define INIT_SECTION_ASM_OP "" |
| 786 |
|
| 787 |
#undef INVOKE__main |
| 788 |
|
| 789 |
#define TARGET_ASM_CONSTRUCTOR machopic_asm_out_constructor |
| 790 |
#define TARGET_ASM_DESTRUCTOR machopic_asm_out_destructor |
| 791 |
|
| 792 |
/* Always prefix with an underscore. */ |
| 793 |
|
| 794 |
#define USER_LABEL_PREFIX "_" |
| 795 |
|
| 796 |
/* A dummy symbol that will be replaced with the function base name. */ |
| 797 |
#define MACHOPIC_FUNCTION_BASE_NAME "<pic base>" |
| 798 |
|
| 799 |
/* Don't output a .file directive. That is only used by the assembler for |
| 800 |
error reporting. */ |
| 801 |
#undef TARGET_ASM_FILE_START_FILE_DIRECTIVE |
| 802 |
#define TARGET_ASM_FILE_START_FILE_DIRECTIVE false |
| 803 |
|
| 804 |
#undef TARGET_ASM_FILE_END |
| 805 |
#define TARGET_ASM_FILE_END darwin_file_end |
| 806 |
|
| 807 |
/* Because Mach-O relocations have a counter from 1 to 255 for the |
| 808 |
section number they apply to, it is necessary to output all |
| 809 |
normal sections before the LTO sections, to make sure that the |
| 810 |
sections that may have relocations always have a section number |
| 811 |
smaller than 255. */ |
| 812 |
#undef TARGET_ASM_LTO_START |
| 813 |
#define TARGET_ASM_LTO_START darwin_asm_lto_start |
| 814 |
#undef TARGET_ASM_LTO_END |
| 815 |
#define TARGET_ASM_LTO_END darwin_asm_lto_end |
| 816 |
|
| 817 |
#define ASM_OUTPUT_SKIP(FILE,SIZE) \ |
| 818 |
fprintf (FILE, "\t.space " HOST_WIDE_INT_PRINT_UNSIGNED"\n", SIZE) |
| 819 |
|
| 820 |
/* Give ObjC methods pretty symbol names. */ |
| 821 |
|
| 822 |
#undef OBJC_GEN_METHOD_LABEL |
| 823 |
#define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \ |
| 824 |
do { if (CAT_NAME) \ |
| 825 |
sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+', \ |
| 826 |
(CLASS_NAME), (CAT_NAME), (SEL_NAME)); \ |
| 827 |
else \ |
| 828 |
sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+', \ |
| 829 |
(CLASS_NAME), (SEL_NAME)); \ |
| 830 |
} while (0) |
| 831 |
|
| 832 |
#undef ASM_DECLARE_OBJECT_NAME |
| 833 |
#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ |
| 834 |
darwin_asm_declare_object_name ((FILE), (NAME), (DECL)) |
| 835 |
|
| 836 |
/* The RTTI data (e.g., __ti4name) is common and public (and static), |
| 837 |
but it does need to be referenced via indirect PIC data pointers. |
| 838 |
The machopic_define_symbol calls are telling the machopic subsystem |
| 839 |
that the name *is* defined in this module, so it doesn't need to |
| 840 |
make them indirect. */ |
| 841 |
|
| 842 |
#undef ASM_DECLARE_FUNCTION_NAME |
| 843 |
#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ |
| 844 |
do { \ |
| 845 |
const char *xname = NAME; \ |
| 846 |
if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \ |
| 847 |
xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \ |
| 848 |
if (! DECL_WEAK (DECL) \ |
| 849 |
&& ((TREE_STATIC (DECL) \ |
| 850 |
&& (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \ |
| 851 |
|| DECL_INITIAL (DECL))) \ |
| 852 |
machopic_define_symbol (DECL_RTL (DECL)); \ |
| 853 |
if ((TREE_STATIC (DECL) \ |
| 854 |
&& (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \ |
| 855 |
|| DECL_INITIAL (DECL)) \ |
| 856 |
(* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \ |
| 857 |
ASM_OUTPUT_FUNCTION_LABEL (FILE, xname, DECL); \ |
| 858 |
} while (0) |
| 859 |
|
| 860 |
#undef TARGET_ASM_DECLARE_CONSTANT_NAME |
| 861 |
#define TARGET_ASM_DECLARE_CONSTANT_NAME darwin_asm_declare_constant_name |
| 862 |
|
| 863 |
/* Wrap new method names in quotes so the assembler doesn't gag. |
| 864 |
Make Objective-C internal symbols local and in doing this, we need |
| 865 |
to accommodate the name mangling done by c++ on file scope locals. */ |
| 866 |
|
| 867 |
int darwin_label_is_anonymous_local_objc_name (const char *name); |
| 868 |
|
| 869 |
#undef ASM_OUTPUT_LABELREF |
| 870 |
#define ASM_OUTPUT_LABELREF(FILE,NAME) \ |
| 871 |
do { \ |
| 872 |
const char *xname = (NAME); \ |
| 873 |
if (! strcmp (xname, MACHOPIC_FUNCTION_BASE_NAME)) \ |
| 874 |
machopic_output_function_base_name(FILE); \ |
| 875 |
else if (xname[0] == '&' || xname[0] == '*') \ |
| 876 |
{ \ |
| 877 |
int len = strlen (xname); \ |
| 878 |
if (len > 6 && !strcmp ("$stub", xname + len - 5)) \ |
| 879 |
machopic_validate_stub_or_non_lazy_ptr (xname); \ |
| 880 |
else if (len > 7 && !strcmp ("$stub\"", xname + len - 6)) \ |
| 881 |
machopic_validate_stub_or_non_lazy_ptr (xname); \ |
| 882 |
else if (len > 14 && !strcmp ("$non_lazy_ptr", xname + len - 13)) \ |
| 883 |
machopic_validate_stub_or_non_lazy_ptr (xname); \ |
| 884 |
else if (len > 15 && !strcmp ("$non_lazy_ptr\"", xname + len - 14)) \ |
| 885 |
machopic_validate_stub_or_non_lazy_ptr (xname); \ |
| 886 |
if (xname[1] != '"' && name_needs_quotes (&xname[1])) \ |
| 887 |
fprintf (FILE, "\"%s\"", &xname[1]); \ |
| 888 |
else \ |
| 889 |
fputs (&xname[1], FILE); \ |
| 890 |
} \ |
| 891 |
else if (xname[0] == '+' || xname[0] == '-') \ |
| 892 |
fprintf (FILE, "\"%s\"", xname); \ |
| 893 |
else if (darwin_label_is_anonymous_local_objc_name (xname)) \ |
| 894 |
fprintf (FILE, "%c%s", flag_next_runtime ? 'L' : 'l', xname); \ |
| 895 |
else if (strncmp (xname, "__anon_cfstring", 15) == 0) \ |
| 896 |
fprintf (FILE, "L%s", xname); \ |
| 897 |
else if (xname[0] != '"' && name_needs_quotes (xname)) \ |
| 898 |
asm_fprintf (FILE, "\"%U%s\"", xname); \ |
| 899 |
else \ |
| 900 |
asm_fprintf (FILE, "%U%s", xname); \ |
| 901 |
} while (0) |
| 902 |
|
| 903 |
/* Output before executable code. */ |
| 904 |
#undef TEXT_SECTION_ASM_OP |
| 905 |
#define TEXT_SECTION_ASM_OP "\t.text" |
| 906 |
|
| 907 |
/* Output before writable data. */ |
| 908 |
|
| 909 |
#undef DATA_SECTION_ASM_OP |
| 910 |
#define DATA_SECTION_ASM_OP "\t.data" |
| 911 |
|
| 912 |
#undef ALIGN_ASM_OP |
| 913 |
#define ALIGN_ASM_OP ".align" |
| 914 |
|
| 915 |
#undef ASM_OUTPUT_ALIGN |
| 916 |
#define ASM_OUTPUT_ALIGN(FILE,LOG) \ |
| 917 |
if ((LOG) != 0) \ |
| 918 |
fprintf (FILE, "\t%s\t%d\n", ALIGN_ASM_OP, (LOG)) |
| 919 |
|
| 920 |
/* The maximum alignment which the object file format can support in bits |
| 921 |
which depends on the OS version and whether the object is a common |
| 922 |
variable. */ |
| 923 |
|
| 924 |
#undef MAX_OFILE_ALIGNMENT |
| 925 |
#define MAX_OFILE_ALIGNMENT ((1U << L2_MAX_OFILE_ALIGNMENT) * 8U) |
| 926 |
|
| 927 |
/* These are the three variants that emit referenced blank space. */ |
| 928 |
#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ |
| 929 |
darwin_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN)) |
| 930 |
|
| 931 |
#undef ASM_OUTPUT_ALIGNED_DECL_LOCAL |
| 932 |
#define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \ |
| 933 |
darwin_asm_output_aligned_decl_local \ |
| 934 |
((FILE), (DECL), (NAME), (SIZE), (ALIGN)) |
| 935 |
|
| 936 |
#undef ASM_OUTPUT_ALIGNED_DECL_COMMON |
| 937 |
#define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \ |
| 938 |
darwin_asm_output_aligned_decl_common \ |
| 939 |
((FILE), (DECL), (NAME), (SIZE), (ALIGN)) |
| 940 |
|
| 941 |
/* The generic version, archs should over-ride where required. */ |
| 942 |
#define MACHOPIC_NL_SYMBOL_PTR_SECTION ".non_lazy_symbol_pointer" |
| 943 |
|
| 944 |
/* Declare the section variables. */ |
| 945 |
#ifndef USED_FOR_TARGET |
| 946 |
enum darwin_section_enum { |
| 947 |
#define DEF_SECTION(NAME, FLAGS, DIRECTIVE, OBJC) NAME, |
| 948 |
#include "darwin-sections.def" |
| 949 |
#undef DEF_SECTION |
| 950 |
NUM_DARWIN_SECTIONS |
| 951 |
}; |
| 952 |
extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS]; |
| 953 |
#endif |
| 954 |
|
| 955 |
#undef TARGET_ASM_SELECT_SECTION |
| 956 |
#define TARGET_ASM_SELECT_SECTION machopic_select_section |
| 957 |
|
| 958 |
#undef TARGET_ASM_FUNCTION_SECTION |
| 959 |
#define TARGET_ASM_FUNCTION_SECTION darwin_function_section |
| 960 |
|
| 961 |
#undef TARGET_ASM_SELECT_RTX_SECTION |
| 962 |
#define TARGET_ASM_SELECT_RTX_SECTION machopic_select_rtx_section |
| 963 |
#undef TARGET_ASM_UNIQUE_SECTION |
| 964 |
#define TARGET_ASM_UNIQUE_SECTION darwin_unique_section |
| 965 |
#undef TARGET_ASM_FUNCTION_RODATA_SECTION |
| 966 |
#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section |
| 967 |
|
| 968 |
#undef TARGET_ASM_TM_CLONE_TABLE_SECTION |
| 969 |
#define TARGET_ASM_TM_CLONE_TABLE_SECTION darwin_tm_clone_table_section |
| 970 |
|
| 971 |
#undef TARGET_ASM_RELOC_RW_MASK |
| 972 |
#define TARGET_ASM_RELOC_RW_MASK machopic_reloc_rw_mask |
| 973 |
|
| 974 |
/* Globalizing directive for a label. */ |
| 975 |
#define GLOBAL_ASM_OP "\t.globl " |
| 976 |
#define TARGET_ASM_GLOBALIZE_LABEL darwin_globalize_label |
| 977 |
|
| 978 |
/* Emit an assembler directive to set visibility for a symbol. Used |
| 979 |
to support visibility attribute and Darwin's private extern |
| 980 |
feature. */ |
| 981 |
#undef TARGET_ASM_ASSEMBLE_VISIBILITY |
| 982 |
#define TARGET_ASM_ASSEMBLE_VISIBILITY darwin_assemble_visibility |
| 983 |
|
| 984 |
/* Extra attributes for Darwin. */ |
| 985 |
#define SUBTARGET_ATTRIBUTE_TABLE \ |
| 986 |
/* { name, min_len, max_len, decl_req, type_req, fn_type_req, \ |
| 987 |
affects_type_identity, handler, exclude } */ \ |
| 988 |
{ "apple_kext_compatibility", 0, 0, false, true, false, false, \ |
| 989 |
darwin_handle_kext_attribute, NULL }, \ |
| 990 |
{ "weak_import", 0, 0, true, false, false, false, \ |
| 991 |
darwin_handle_weak_import_attribute, NULL } |
| 992 |
|
| 993 |
/* Make local constant labels linker-visible, so that if one follows a |
| 994 |
weak_global constant, ld64 will be able to separate the atoms. */ |
| 995 |
#undef ASM_GENERATE_INTERNAL_LABEL |
| 996 |
#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ |
| 997 |
do { \ |
| 998 |
if (strcmp ("LC", PREFIX) == 0) \ |
| 999 |
sprintf (LABEL, "*%s%ld", "lC", (long)(NUM)); \ |
| 1000 |
else if (strcmp ("Lubsan_data", PREFIX) == 0) \ |
| 1001 |
sprintf (LABEL, "*%s%ld", "lubsan_data", (long)(NUM));\ |
| 1002 |
else if (strcmp ("Lubsan_type", PREFIX) == 0) \ |
| 1003 |
sprintf (LABEL, "*%s%ld", "lubsan_type", (long)(NUM));\ |
| 1004 |
else if (strcmp ("LASAN", PREFIX) == 0) \ |
| 1005 |
sprintf (LABEL, "*%s%ld", "lASAN", (long)(NUM));\ |
| 1006 |
else if (strcmp ("LTRAMP", PREFIX) == 0) \ |
| 1007 |
sprintf (LABEL, "*%s%ld", "lTRAMP", (long)(NUM));\ |
| 1008 |
else \ |
| 1009 |
sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM)); \ |
| 1010 |
} while (0) |
| 1011 |
|
| 1012 |
#undef TARGET_ASM_MARK_DECL_PRESERVED |
| 1013 |
#define TARGET_ASM_MARK_DECL_PRESERVED darwin_mark_decl_preserved |
| 1014 |
|
| 1015 |
/* Any port using this header needs to define the first available |
| 1016 |
subtarget symbol bit: SYMBOL_FLAG_SUBT_DEP. */ |
| 1017 |
|
| 1018 |
/* Is a variable. */ |
| 1019 |
#define MACHO_SYMBOL_FLAG_VARIABLE (SYMBOL_FLAG_SUBT_DEP) |
| 1020 |
#define MACHO_SYMBOL_VARIABLE_P(RTX) \ |
| 1021 |
((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_VARIABLE) != 0) |
| 1022 |
|
| 1023 |
/* Set on a symbol that must be indirected, even when there is a |
| 1024 |
definition in the TU. The ABI mandates that common symbols are so |
| 1025 |
indirected, as are weak. If 'fix-and-continue' is operational then |
| 1026 |
data symbols might also be. */ |
| 1027 |
|
| 1028 |
#define MACHO_SYMBOL_FLAG_MUST_INDIRECT ((SYMBOL_FLAG_SUBT_DEP) << 1) |
| 1029 |
#define MACHO_SYMBOL_MUST_INDIRECT_P(RTX) \ |
| 1030 |
((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_MUST_INDIRECT) != 0) |
| 1031 |
|
| 1032 |
/* Set on a symbol with SYMBOL_FLAG_FUNCTION or MACHO_SYMBOL_FLAG_VARIABLE |
| 1033 |
to indicate that the function or variable is considered defined in this |
| 1034 |
translation unit. */ |
| 1035 |
|
| 1036 |
#define MACHO_SYMBOL_FLAG_DEFINED ((SYMBOL_FLAG_SUBT_DEP) << 2) |
| 1037 |
#define MACHO_SYMBOL_DEFINED_P(RTX) \ |
| 1038 |
((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_DEFINED) != 0) |
| 1039 |
|
| 1040 |
/* Set on a symbol that has specified non-default visibility. */ |
| 1041 |
|
| 1042 |
#define MACHO_SYMBOL_FLAG_HIDDEN_VIS ((SYMBOL_FLAG_SUBT_DEP) << 3) |
| 1043 |
#define MACHO_SYMBOL_HIDDEN_VIS_P(RTX) \ |
| 1044 |
((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_HIDDEN_VIS) != 0) |
| 1045 |
|
| 1046 |
/* Set on a symbol that should be made visible to the linker (overriding |
| 1047 |
'L' symbol prefixes). */ |
| 1048 |
|
| 1049 |
#define MACHO_SYMBOL_FLAG_LINKER_VIS ((SYMBOL_FLAG_SUBT_DEP) << 4) |
| 1050 |
#define MACHO_SYMBOL_LINKER_VIS_P(RTX) \ |
| 1051 |
((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_LINKER_VIS) != 0) |
| 1052 |
|
| 1053 |
/* Set on a symbol that is a pic stub or symbol indirection (i.e. the |
| 1054 |
L_xxxxx${stub,non_lazy_ptr,lazy_ptr}. */ |
| 1055 |
|
| 1056 |
#define MACHO_SYMBOL_FLAG_INDIRECTION ((SYMBOL_FLAG_SUBT_DEP) << 5) |
| 1057 |
#define MACHO_SYMBOL_INDIRECTION_P(RTX) \ |
| 1058 |
((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_INDIRECTION) != 0) |
| 1059 |
|
| 1060 |
/* Set on a symbol to indicate when fix-and-continue style code |
| 1061 |
generation is being used and the symbol refers to a static symbol |
| 1062 |
that should be rebound from new instances of a translation unit to |
| 1063 |
the original instance of the data. */ |
| 1064 |
|
| 1065 |
#define MACHO_SYMBOL_FLAG_STATIC ((SYMBOL_FLAG_SUBT_DEP) << 6) |
| 1066 |
#define MACHO_SYMBOL_STATIC_P(RTX) \ |
| 1067 |
((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_STATIC) != 0) |
| 1068 |
|
| 1069 |
/* Symbolic names for various things we might know about a symbol. */ |
| 1070 |
|
| 1071 |
enum machopic_addr_class { |
| 1072 |
MACHOPIC_UNDEFINED, |
| 1073 |
MACHOPIC_DEFINED_DATA, |
| 1074 |
MACHOPIC_UNDEFINED_DATA, |
| 1075 |
MACHOPIC_DEFINED_FUNCTION, |
| 1076 |
MACHOPIC_UNDEFINED_FUNCTION |
| 1077 |
}; |
| 1078 |
|
| 1079 |
/* Macros defining the various PIC cases. */ |
| 1080 |
|
| 1081 |
#undef MACHO_DYNAMIC_NO_PIC_P |
| 1082 |
#define MACHO_DYNAMIC_NO_PIC_P (TARGET_MACHO_DYNAMIC_NO_PIC) |
| 1083 |
#undef MACHOPIC_INDIRECT |
| 1084 |
#define MACHOPIC_INDIRECT (flag_pic || MACHO_DYNAMIC_NO_PIC_P) |
| 1085 |
#define MACHOPIC_JUST_INDIRECT (MACHO_DYNAMIC_NO_PIC_P) |
| 1086 |
#undef MACHOPIC_PURE |
| 1087 |
#define MACHOPIC_PURE (flag_pic && ! MACHO_DYNAMIC_NO_PIC_P) |
| 1088 |
|
| 1089 |
#undef TARGET_ENCODE_SECTION_INFO |
| 1090 |
#define TARGET_ENCODE_SECTION_INFO darwin_encode_section_info |
| 1091 |
#undef TARGET_STRIP_NAME_ENCODING |
| 1092 |
#define TARGET_STRIP_NAME_ENCODING default_strip_name_encoding |
| 1093 |
|
| 1094 |
#define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH) \ |
| 1095 |
do { \ |
| 1096 |
const char *const stub_ = (STUB); \ |
| 1097 |
char *buffer_ = (BUF); \ |
| 1098 |
strcpy (buffer_, stub_); \ |
| 1099 |
if (stub_[0] == '"') \ |
| 1100 |
{ \ |
| 1101 |
strcpy (buffer_ + (STUB_LENGTH) - 1, "_binder\""); \ |
| 1102 |
} \ |
| 1103 |
else \ |
| 1104 |
{ \ |
| 1105 |
strcpy (buffer_ + (STUB_LENGTH), "_binder"); \ |
| 1106 |
} \ |
| 1107 |
} while (0) |
| 1108 |
|
| 1109 |
#define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \ |
| 1110 |
do { \ |
| 1111 |
const char *const symbol_ = (SYMBOL); \ |
| 1112 |
char *buffer_ = (BUF); \ |
| 1113 |
if (name_needs_quotes (symbol_) && symbol_[0] != '"') \ |
| 1114 |
{ \ |
| 1115 |
sprintf (buffer_, "\"%s\"", symbol_); \ |
| 1116 |
} \ |
| 1117 |
else \ |
| 1118 |
{ \ |
| 1119 |
strcpy (buffer_, symbol_); \ |
| 1120 |
} \ |
| 1121 |
} while (0) |
| 1122 |
|
| 1123 |
/* Given a symbol name string, create the lazy pointer version |
| 1124 |
of the symbol name. */ |
| 1125 |
|
| 1126 |
#define GEN_LAZY_PTR_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \ |
| 1127 |
do { \ |
| 1128 |
const char *symbol_ = (SYMBOL); \ |
| 1129 |
char *buffer_ = (BUF); \ |
| 1130 |
if (symbol_[0] == '"') \ |
| 1131 |
{ \ |
| 1132 |
strcpy (buffer_, "\"L"); \ |
| 1133 |
strcpy (buffer_ + 2, symbol_ + 1); \ |
| 1134 |
strcpy (buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\""); \ |
| 1135 |
} \ |
| 1136 |
else if (name_needs_quotes (symbol_)) \ |
| 1137 |
{ \ |
| 1138 |
strcpy (buffer_, "\"L"); \ |
| 1139 |
strcpy (buffer_ + 2, symbol_); \ |
| 1140 |
strcpy (buffer_ + (SYMBOL_LENGTH) + 2, "$lazy_ptr\""); \ |
| 1141 |
} \ |
| 1142 |
else \ |
| 1143 |
{ \ |
| 1144 |
strcpy (buffer_, "L"); \ |
| 1145 |
strcpy (buffer_ + 1, symbol_); \ |
| 1146 |
strcpy (buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr"); \ |
| 1147 |
} \ |
| 1148 |
} while (0) |
| 1149 |
|
| 1150 |
#define EH_FRAME_SECTION_NAME "__TEXT" |
| 1151 |
#define EH_FRAME_SECTION_ATTR ",coalesced,no_toc+strip_static_syms+live_support" |
| 1152 |
|
| 1153 |
#undef ASM_PREFERRED_EH_DATA_FORMAT |
| 1154 |
#define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \ |
| 1155 |
(((CODE) == 2 && (GLOBAL) == 1) || ((CODE) == 0 && (GLOBAL) == 1) \ |
| 1156 |
? (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4) : \ |
| 1157 |
((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr) |
| 1158 |
|
| 1159 |
#define ASM_OUTPUT_DWARF_DELTA(FILE,SIZE,LABEL1,LABEL2) \ |
| 1160 |
darwin_asm_output_dwarf_delta (FILE, SIZE, LABEL1, LABEL2, 0) |
| 1161 |
|
| 1162 |
#define ASM_OUTPUT_DWARF_OFFSET(FILE,SIZE,LABEL,OFFSET,BASE) \ |
| 1163 |
darwin_asm_output_dwarf_offset (FILE, SIZE, LABEL, OFFSET, BASE) |
| 1164 |
|
| 1165 |
#define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(ASM_OUT_FILE, ENCODING, SIZE, ADDR, DONE) \ |
| 1166 |
if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1)) { \ |
| 1167 |
darwin_non_lazy_pcrel (ASM_OUT_FILE, ADDR); \ |
| 1168 |
goto DONE; \ |
| 1169 |
} |
| 1170 |
|
| 1171 |
/* Experimentally, putting jump tables in text is faster on SPEC. |
| 1172 |
Also this is needed for correctness for coalesced functions. */ |
| 1173 |
|
| 1174 |
#ifndef JUMP_TABLES_IN_TEXT_SECTION |
| 1175 |
#define JUMP_TABLES_IN_TEXT_SECTION 1 |
| 1176 |
#endif |
| 1177 |
|
| 1178 |
#define TARGET_TERMINATE_DW2_EH_FRAME_INFO false |
| 1179 |
|
| 1180 |
#define TARGET_ASM_INIT_SECTIONS darwin_init_sections |
| 1181 |
#undef TARGET_ASM_NAMED_SECTION |
| 1182 |
#define TARGET_ASM_NAMED_SECTION darwin_asm_named_section |
| 1183 |
|
| 1184 |
#define DARWIN_REGISTER_TARGET_PRAGMAS() \ |
| 1185 |
do { \ |
| 1186 |
if (!flag_preprocess_only) \ |
| 1187 |
cpp_register_pragma (parse_in, NULL, "mark", \ |
| 1188 |
darwin_pragma_ignore, false); \ |
| 1189 |
c_register_pragma (0, "options", darwin_pragma_options); \ |
| 1190 |
c_register_pragma (0, "segment", darwin_pragma_ignore); \ |
| 1191 |
c_register_pragma (0, "unused", darwin_pragma_unused); \ |
| 1192 |
c_register_pragma (0, "ms_struct", darwin_pragma_ms_struct); \ |
| 1193 |
} while (0) |
| 1194 |
|
| 1195 |
#undef ASM_APP_ON |
| 1196 |
#define ASM_APP_ON "" |
| 1197 |
#undef ASM_APP_OFF |
| 1198 |
#define ASM_APP_OFF "" |
| 1199 |
|
| 1200 |
void darwin_register_frameworks (const char *, const char *, int); |
| 1201 |
void darwin_register_objc_includes (const char *, const char *, int); |
| 1202 |
#define TARGET_EXTRA_PRE_INCLUDES darwin_register_objc_includes |
| 1203 |
#define TARGET_EXTRA_INCLUDES darwin_register_frameworks |
| 1204 |
|
| 1205 |
void add_framework_path (char *); |
| 1206 |
#define TARGET_OPTF add_framework_path |
| 1207 |
|
| 1208 |
#define TARGET_POSIX_IO |
| 1209 |
|
| 1210 |
#define WINT_TYPE "int" |
| 1211 |
|
| 1212 |
/* Every program on darwin links against libSystem which contains the pthread |
| 1213 |
routines, so there's no need to explicitly call out when doing threaded |
| 1214 |
work. */ |
| 1215 |
|
| 1216 |
#undef GOMP_SELF_SPECS |
| 1217 |
#define GOMP_SELF_SPECS "" |
| 1218 |
#undef GTM_SELF_SPECS |
| 1219 |
#define GTM_SELF_SPECS "" |
| 1220 |
|
| 1221 |
/* Darwin disables section anchors by default. |
| 1222 |
They should be enabled per arch where support exists in that arch. */ |
| 1223 |
#define TARGET_ASM_OUTPUT_ANCHOR NULL |
| 1224 |
#define DARWIN_SECTION_ANCHORS 0 |
| 1225 |
|
| 1226 |
#define HAVE_ENABLE_EXECUTE_STACK |
| 1227 |
|
| 1228 |
/* For Apple KEXTs, we make the constructors return this to match gcc |
| 1229 |
2.95. */ |
| 1230 |
#define TARGET_CXX_CDTOR_RETURNS_THIS (darwin_kextabi_p) |
| 1231 |
#define TARGET_KEXTABI flag_apple_kext |
| 1232 |
|
| 1233 |
/* We have target-specific builtins. */ |
| 1234 |
#define SUBTARGET_FOLD_BUILTIN darwin_fold_builtin |
| 1235 |
|
| 1236 |
#define TARGET_N_FORMAT_TYPES 1 |
| 1237 |
#define TARGET_FORMAT_TYPES darwin_additional_format_types |
| 1238 |
|
| 1239 |
#ifndef USED_FOR_TARGET |
| 1240 |
extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **); |
| 1241 |
#define GCC_DRIVER_HOST_INITIALIZATION \ |
| 1242 |
darwin_driver_init (&decoded_options_count, &decoded_options) |
| 1243 |
#endif |
| 1244 |
|
| 1245 |
/* The Apple assembler and linker do not support constructor priorities. */ |
| 1246 |
#undef SUPPORTS_INIT_PRIORITY |
| 1247 |
#define SUPPORTS_INIT_PRIORITY 0 |
| 1248 |
|
| 1249 |
#undef STACK_CHECK_STATIC_BUILTIN |
| 1250 |
#define STACK_CHECK_STATIC_BUILTIN 1 |
| 1251 |
|
| 1252 |
/* When building cross-compilers (and native crosses) we shall default to |
| 1253 |
providing an osx-version-min of this unless overridden by the User. |
| 1254 |
10.5 is the only version that fully supports all our archs so that's the |
| 1255 |
fall-back default. */ |
| 1256 |
#ifndef DEF_MIN_OSX_VERSION |
| 1257 |
#define DEF_MIN_OSX_VERSION "10.5" |
| 1258 |
#endif |
| 1259 |
|
| 1260 |
/* Later versions of ld64 support coalescing weak code/data without requiring |
| 1261 |
that they be placed in specially identified sections. This is the earliest |
| 1262 |
_tested_ version known to support this so far. */ |
| 1263 |
#define MIN_LD64_NO_COAL_SECTS "236.3" |
| 1264 |
|
| 1265 |
/* From at least version 62.1, ld64 can build symbol indirection stubs as |
| 1266 |
needed, and there is no need for the compiler to emit them. */ |
| 1267 |
#define MIN_LD64_OMIT_STUBS "62.1" |
| 1268 |
|
| 1269 |
/* Emit start labels for init and term sections from this version. */ |
| 1270 |
#define MIN_LD64_INIT_TERM_START_LABELS "136.0" |
| 1271 |
|
| 1272 |
/* If we have no definition for the linker version, pick the minimum version |
| 1273 |
that will bootstrap the compiler. */ |
| 1274 |
#ifndef LD64_VERSION |
| 1275 |
# ifndef DEF_LD64 |
| 1276 |
# define LD64_VERSION "85.2.1" |
| 1277 |
# else |
| 1278 |
# define LD64_VERSION DEF_LD64 |
| 1279 |
# endif |
| 1280 |
#endif |
| 1281 |
|
| 1282 |
/* CTF and BTF support. */ |
| 1283 |
#undef CTF_INFO_SECTION_NAME |
| 1284 |
#define CTF_INFO_SECTION_NAME "__CTF_BTF,__ctf,regular,debug" |
| 1285 |
#undef BTF_INFO_SECTION_NAME |
| 1286 |
#define BTF_INFO_SECTION_NAME "__CTF_BTF,__btf,regular,debug" |
| 1287 |
|
| 1288 |
#endif /* CONFIG_DARWIN_H */ |