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