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