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