1 /* Target definitions for Darwin (Mac OS X) systems.
2 Copyright (C) 1989, 1990, 1991, 1992, 1993, 2000, 2001
3 Free Software Foundation, Inc.
4 Contributed by Apple Computer Inc.
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 /* The definitions in this file are common to all processor types
24 running Darwin, which is the kernel for Mac OS X. Darwin is
25 basically a BSD user layer laid over a Mach kernel, then evolved
26 for many years (at NeXT) in parallel with other Unix systems. So
27 while the runtime is a somewhat idiosyncratic Mach-based thing,
28 other definitions look like they would for a BSD variant. */
30 /* Although NeXT ran on many different architectures, as of Jan 2001
31 the only supported Darwin targets are PowerPC and x86. */
33 /* Technically, STANDARD_EXEC_PREFIX should be /usr/libexec/, but in
34 practice this makes it hard to install new compilers elsewhere, so
35 leave it undefined and expect system builders to set configure args
38 /* Name of the command that invokes the compiler - used in g++.c. */
43 /* Never try linking with -lm - used in g++.c. */
45 #define NO_MATH_LIBRARY
51 /* Define an empty body for the function do_global_dtors() in libgcc2.c. */
53 #define DO_GLOBAL_DTORS_BODY
55 /* The string value for __SIZE_TYPE__. */
58 #define SIZE_TYPE "long unsigned int"
61 /* Type used for ptrdiff_t, as a string used in a declaration. */
64 #define PTRDIFF_TYPE "int"
69 #define WCHAR_TYPE "int"
70 #undef WCHAR_TYPE_SIZE
71 #define WCHAR_TYPE_SIZE 32
73 /* Default to using the NeXT-style runtime, since that's what is
74 pre-installed on Darwin systems. */
76 #define NEXT_OBJC_RUNTIME
78 /* Don't default to pcc-struct-return, because gcc is the only compiler, and
79 we want to retain compatibility with older gcc versions. */
81 #undef DEFAULT_PCC_STRUCT_RETURN
82 #define DEFAULT_PCC_STRUCT_RETURN 0
84 /* Don't warn about MacOS-style 'APPL' four-char-constants. */
86 #undef WARN_FOUR_CHAR_CONSTANTS
87 #define WARN_FOUR_CHAR_CONSTANTS 0
89 /* Machine dependent cpp options. */
91 /* The sequence here allows us to get a more specific version number
92 glued into __APPLE_CC__. Normally this number would be updated as
93 part of submitting to a release engineering organization. */
99 #define STRINGIFY_THIS(x) # x
100 #define REALLY_STRINGIFY(x) STRINGIFY_THIS(x)
103 #define CPP_SPEC "-D__APPLE_CC__=" REALLY_STRINGIFY(APPLE_CC) " \
104 %{static:-D__STATIC__}%{!static:-D__DYNAMIC__}"
106 /* Machine dependent libraries. */
109 #define LIB_SPEC "%{!static:-lSystem}"
111 /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
113 #undef STARTFILE_SPEC
114 #define STARTFILE_SPEC \
115 "%{pg:%{static:-lgcrt0.o}%{!static:-lgcrt1.o}} \
116 %{!pg:%{static:-lcrt0.o}%{!static:-lcrt1.o}}"
118 #undef DOLLARS_IN_IDENTIFIERS
119 #define DOLLARS_IN_IDENTIFIERS 2
121 /* Allow #sccs (but don't do anything). */
123 #define SCCS_DIRECTIVE
125 /* We use Dbx symbol format. */
127 #define DBX_DEBUGGING_INFO
129 /* When generating stabs debugging, use N_BINCL entries. */
131 #define DBX_USE_BINCL
133 /* There is no limit to the length of stabs strings. */
135 #define DBX_CONTIN_LENGTH 0
137 /* gdb needs a null N_SO at the end of each file for scattered loading. */
139 #undef DBX_OUTPUT_MAIN_SOURCE_FILE_END
140 #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \
141 do { text_section (); \
143 "\t.stabs \"%s\",%d,0,0,Letext\nLetext:\n", "" , N_SO); \
146 /* Our profiling scheme doesn't LP labels and counter words. */
148 #define NO_PROFILE_COUNTERS
150 /* Don't use .gcc_compiled symbols to communicate with GDB;
151 They interfere with numerically sorted symbol lists. */
153 #undef ASM_IDENTIFY_GCC
154 #define ASM_IDENTIFY_GCC(asm_out_file)
156 #undef INIT_SECTION_ASM_OP
157 #define INIT_SECTION_ASM_OP
161 #undef ASM_OUTPUT_CONSTRUCTOR
162 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
164 mod_init_section (); \
166 constructor_section (); \
167 ASM_OUTPUT_ALIGN (FILE, 1); \
168 fprintf (FILE, "\t.long "); \
169 assemble_name (FILE, NAME); \
170 fprintf (FILE, "\n"); \
172 fprintf (FILE, ".reference .constructors_used\n"); \
175 #undef ASM_OUTPUT_DESTRUCTOR
176 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
178 mod_term_section (); \
180 destructor_section (); \
181 ASM_OUTPUT_ALIGN (FILE, 1); \
182 fprintf (FILE, "\t.long "); \
183 assemble_name (FILE, NAME); \
184 fprintf (FILE, "\n"); \
186 fprintf (FILE, ".reference .destructors_used\n"); \
190 /* Don't output a .file directive. That is only used by the assembler for
193 #undef ASM_FILE_START
194 #define ASM_FILE_START(FILE)
197 #define ASM_FILE_END(FILE) \
199 machopic_finish (asm_out_file); \
200 if (strcmp (language_string, "GNU C++") == 0) \
202 constructor_section (); \
203 destructor_section (); \
204 ASM_OUTPUT_ALIGN (FILE, 1); \
208 /* Give ObjcC methods pretty symbol names. */
210 #undef OBJC_GEN_METHOD_LABEL
211 #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \
213 sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+', \
214 (CLASS_NAME), (CAT_NAME), (SEL_NAME)); \
216 sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+', \
217 (CLASS_NAME), (SEL_NAME)); \
220 /* The RTTI data (e.g., __ti4name) is common and public (and static),
221 but it does need to be referenced via indirect PIC data pointers.
222 The machopic_define_name calls are telling the machopic subsystem
223 that the name *is* defined in this module, so it doesn't need to
224 make them indirect. */
226 #undef ASM_DECLARE_OBJECT_NAME
227 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
229 char *xname = NAME; \
230 if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
231 xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
232 if ((TREE_STATIC (DECL) \
233 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
234 || DECL_INITIAL (DECL)) \
235 machopic_define_name (xname); \
236 if ((TREE_STATIC (DECL) \
237 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
238 || DECL_INITIAL (DECL)) \
239 ENCODE_SECTION_INFO (DECL); \
240 ASM_OUTPUT_LABEL (FILE, xname); \
243 /* Wrap new method names in quotes so the assembler doesn't gag.
244 Make Objective-C internal symbols local. */
246 #undef ASM_OUTPUT_LABELREF
247 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
249 STRIP_NAME_ENCODING (NAME, NAME); \
250 if (NAME[0] == '&') \
252 int len = strlen (NAME); \
253 if (len > 6 && !strcmp ("$stub", NAME + len - 5)) \
254 machopic_validate_stub_or_non_lazy_ptr (NAME, 1); \
255 else if (len > 7 && !strcmp ("$stub\"", NAME + len - 6)) \
256 machopic_validate_stub_or_non_lazy_ptr (NAME, 1); \
257 else if (len > 14 && !strcmp ("$non_lazy_ptr", NAME + len - 13)) \
258 machopic_validate_stub_or_non_lazy_ptr (NAME, 0); \
259 fputs (&NAME[1], FILE); \
261 else if (NAME[0] == '+' || NAME[0] == '-') \
262 fprintf (FILE, "\"%s\"", NAME); \
263 else if (!strncmp (NAME, "_OBJC_", 6)) \
264 fprintf (FILE, "L%s", NAME); \
265 else if (!strncmp (NAME, ".objc_class_name_", 17)) \
266 fprintf (FILE, "%s", NAME); \
268 fprintf (FILE, "_%s", NAME); \
272 #define ALIGN_ASM_OP ".align"
274 #undef ASM_OUTPUT_ALIGN
275 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
277 fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG))
279 /* Ensure correct alignment of bss data. */
281 #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
282 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
284 fputs (".lcomm ", (FILE)); \
285 assemble_name ((FILE), (NAME)); \
286 fprintf ((FILE), ",%u,%u\n", (SIZE), floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
287 if ((DECL) && ((TREE_STATIC (DECL) \
288 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
289 || DECL_INITIAL (DECL))) \
290 ENCODE_SECTION_INFO (DECL); \
291 if ((DECL) && ((TREE_STATIC (DECL) \
292 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
293 || DECL_INITIAL (DECL))) \
294 machopic_define_name (NAME); \
297 /* Output nothing for #ident. */
299 #undef ASM_OUTPUT_IDENT
300 #define ASM_OUTPUT_IDENT(FILE, NAME)
302 /* The maximum alignment which the object file format can support.
303 For Mach-O, this is 2^15. */
305 #undef MAX_OFILE_ALIGNMENT
306 #define MAX_OFILE_ALIGNMENT 0x8000
308 /* Create new Mach-O sections. */
310 #undef SECTION_FUNCTION
311 #define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, WAS_TEXT, OBJC) \
315 extern void text_section (); \
316 extern void objc_section_init (); \
317 extern int flag_no_mach_text_sections; \
319 if (WAS_TEXT && flag_no_mach_text_sections) \
321 else if (in_section != SECTION) \
324 objc_section_init (); \
327 fprintf (asm_out_file, "%s\n", DIRECTIVE); \
328 in_section = SECTION; \
332 #define ALIAS_SECTION(enum_value, alias_name) \
333 do { if (!strcmp (alias_name, name)) \
334 section_alias[enum_value] = (alias ? get_identifier (alias) : 0); \
337 /* Darwin uses many types of special sections. */
339 #undef EXTRA_SECTIONS
340 #define EXTRA_SECTIONS \
341 in_const, in_const_data, in_cstring, in_literal4, in_literal8, \
342 in_constructor, in_destructor, in_mod_init, in_mod_term, \
343 in_objc_class, in_objc_meta_class, in_objc_category, \
344 in_objc_class_vars, in_objc_instance_vars, \
345 in_objc_cls_meth, in_objc_inst_meth, \
346 in_objc_cat_cls_meth, in_objc_cat_inst_meth, \
347 in_objc_selector_refs, \
348 in_objc_selector_fixup, \
349 in_objc_symbols, in_objc_module_info, \
350 in_objc_protocol, in_objc_string_object, \
351 in_objc_constant_string_object, \
352 in_objc_class_names, in_objc_meth_var_names, \
353 in_objc_meth_var_types, in_objc_cls_refs, \
354 in_machopic_nl_symbol_ptr, \
355 in_machopic_lazy_symbol_ptr, \
356 in_machopic_symbol_stub, \
357 in_machopic_picsymbol_stub, \
360 #undef EXTRA_SECTION_FUNCTIONS
361 #define EXTRA_SECTION_FUNCTIONS \
362 SECTION_FUNCTION (const_section, \
365 SECTION_FUNCTION (const_data_section, \
367 ".const_data", 1, 0) \
368 SECTION_FUNCTION (cstring_section, \
371 SECTION_FUNCTION (literal4_section, \
374 SECTION_FUNCTION (literal8_section, \
377 SECTION_FUNCTION (constructor_section, \
379 ".constructor", 0, 0) \
380 SECTION_FUNCTION (mod_init_section, \
382 ".mod_init_func", 0, 0) \
383 SECTION_FUNCTION (mod_term_section, \
385 ".mod_term_func", 0, 0) \
386 SECTION_FUNCTION (destructor_section, \
388 ".destructor", 0, 0) \
389 SECTION_FUNCTION (objc_class_section, \
391 ".objc_class", 0, 1) \
392 SECTION_FUNCTION (objc_meta_class_section, \
393 in_objc_meta_class, \
394 ".objc_meta_class", 0, 1) \
395 SECTION_FUNCTION (objc_category_section, \
397 ".objc_category", 0, 1) \
398 SECTION_FUNCTION (objc_class_vars_section, \
399 in_objc_class_vars, \
400 ".objc_class_vars", 0, 1) \
401 SECTION_FUNCTION (objc_instance_vars_section, \
402 in_objc_instance_vars, \
403 ".objc_instance_vars", 0, 1) \
404 SECTION_FUNCTION (objc_cls_meth_section, \
406 ".objc_cls_meth", 0, 1) \
407 SECTION_FUNCTION (objc_inst_meth_section, \
409 ".objc_inst_meth", 0, 1) \
410 SECTION_FUNCTION (objc_cat_cls_meth_section, \
411 in_objc_cat_cls_meth, \
412 ".objc_cat_cls_meth", 0, 1) \
413 SECTION_FUNCTION (objc_cat_inst_meth_section, \
414 in_objc_cat_inst_meth, \
415 ".objc_cat_inst_meth", 0, 1) \
416 SECTION_FUNCTION (objc_selector_refs_section, \
417 in_objc_selector_refs, \
418 ".objc_message_refs", 0, 1) \
419 SECTION_FUNCTION (objc_selector_fixup_section, \
420 in_objc_selector_fixup, \
421 ".section __OBJC, __sel_fixup", 0, 1) \
422 SECTION_FUNCTION (objc_symbols_section, \
424 ".objc_symbols", 0, 1) \
425 SECTION_FUNCTION (objc_module_info_section, \
426 in_objc_module_info, \
427 ".objc_module_info", 0, 1) \
428 SECTION_FUNCTION (objc_protocol_section, \
430 ".objc_protocol", 0, 1) \
431 SECTION_FUNCTION (objc_string_object_section, \
432 in_objc_string_object, \
433 ".objc_string_object", 0, 1) \
434 SECTION_FUNCTION (objc_constant_string_object_section, \
435 in_objc_constant_string_object, \
436 ".section __OBJC, __cstring_object", 0, 1) \
437 SECTION_FUNCTION (objc_class_names_section, \
438 in_objc_class_names, \
439 ".objc_class_names", 0, 1) \
440 SECTION_FUNCTION (objc_meth_var_names_section, \
441 in_objc_meth_var_names, \
442 ".objc_meth_var_names", 0, 1) \
443 SECTION_FUNCTION (objc_meth_var_types_section, \
444 in_objc_meth_var_types, \
445 ".objc_meth_var_types", 0, 1) \
446 SECTION_FUNCTION (objc_cls_refs_section, \
448 ".objc_cls_refs", 0, 1) \
450 SECTION_FUNCTION (machopic_lazy_symbol_ptr_section, \
451 in_machopic_lazy_symbol_ptr, \
452 ".lazy_symbol_pointer", 0, 0) \
453 SECTION_FUNCTION (machopic_nl_symbol_ptr_section, \
454 in_machopic_nl_symbol_ptr, \
455 ".non_lazy_symbol_pointer", 0, 0) \
456 SECTION_FUNCTION (machopic_symbol_stub_section, \
457 in_machopic_symbol_stub, \
458 ".symbol_stub", 0, 0) \
459 SECTION_FUNCTION (machopic_picsymbol_stub_section, \
460 in_machopic_picsymbol_stub, \
461 ".picsymbol_stub", 0, 0) \
464 objc_section_init () \
466 static int been_here = 0; \
468 if (been_here == 0) \
471 /* written, cold -> hot */ \
472 objc_cat_cls_meth_section (); \
473 objc_cat_inst_meth_section (); \
474 objc_string_object_section (); \
475 objc_constant_string_object_section (); \
476 objc_selector_refs_section (); \
477 objc_selector_fixup_section (); \
478 objc_cls_refs_section (); \
479 objc_class_section (); \
480 objc_meta_class_section (); \
481 /* shared, hot -> cold */ \
482 objc_cls_meth_section (); \
483 objc_inst_meth_section (); \
484 objc_protocol_section (); \
485 objc_class_names_section (); \
486 objc_meth_var_types_section (); \
487 objc_meth_var_names_section (); \
488 objc_category_section (); \
489 objc_class_vars_section (); \
490 objc_instance_vars_section (); \
491 objc_module_info_section (); \
492 objc_symbols_section (); \
495 static tree section_alias[(int) num_sections]; \
496 void try_section_alias () \
498 if (section_alias[in_section] && asm_out_file) \
499 fprintf (asm_out_file, "%s\n", \
500 IDENTIFIER_POINTER (section_alias[in_section])); \
502 void alias_section (name, alias) \
503 char *name, *alias; \
505 ALIAS_SECTION (in_data, "data"); \
506 ALIAS_SECTION (in_text, "text"); \
507 ALIAS_SECTION (in_const, "const"); \
508 ALIAS_SECTION (in_const_data, "const_data"); \
509 ALIAS_SECTION (in_cstring, "cstring"); \
510 ALIAS_SECTION (in_literal4, "literal4"); \
511 ALIAS_SECTION (in_literal8, "literal8"); \
514 #undef READONLY_DATA_SECTION
515 #define READONLY_DATA_SECTION const_section
517 #undef SELECT_SECTION
518 #define SELECT_SECTION(exp,reloc) \
521 if (TREE_CODE (exp) == STRING_CST) \
523 if (flag_writable_strings) \
525 else if (TREE_STRING_LENGTH (exp) != \
526 strlen (TREE_STRING_POINTER (exp)) + 1) \
527 readonly_data_section (); \
529 cstring_section (); \
531 else if (TREE_CODE (exp) == INTEGER_CST \
532 || TREE_CODE (exp) == REAL_CST) \
534 tree size = TYPE_SIZE (TREE_TYPE (exp)); \
536 if (TREE_CODE (size) == INTEGER_CST && \
537 TREE_INT_CST_LOW (size) == 4 && \
538 TREE_INT_CST_HIGH (size) == 0) \
539 literal4_section (); \
540 else if (TREE_CODE (size) == INTEGER_CST && \
541 TREE_INT_CST_LOW (size) == 8 && \
542 TREE_INT_CST_HIGH (size) == 0) \
543 literal8_section (); \
545 readonly_data_section (); \
547 else if (TREE_CODE (exp) == CONSTRUCTOR \
549 && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE \
550 && TYPE_NAME (TREE_TYPE (exp))) \
552 tree name = TYPE_NAME (TREE_TYPE (exp)); \
553 if (TREE_CODE (name) == TYPE_DECL) \
554 name = DECL_NAME (name); \
555 if (!strcmp (IDENTIFIER_POINTER (name), "NSConstantString")) \
556 objc_constant_string_object_section (); \
557 else if (!strcmp (IDENTIFIER_POINTER (name), "NXConstantString")) \
558 objc_string_object_section (); \
559 else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
561 if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc) \
562 const_data_section (); \
564 readonly_data_section (); \
569 else if (TREE_CODE (exp) == VAR_DECL && \
571 TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE && \
572 IDENTIFIER_POINTER (DECL_NAME (exp)) && \
573 !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \
575 const char *name = IDENTIFIER_POINTER (DECL_NAME (exp)); \
577 if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20)) \
578 objc_cls_meth_section (); \
579 else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23)) \
580 objc_inst_meth_section (); \
581 else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \
582 objc_cat_cls_meth_section (); \
583 else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \
584 objc_cat_inst_meth_section (); \
585 else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22)) \
586 objc_class_vars_section (); \
587 else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25)) \
588 objc_instance_vars_section (); \
589 else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22)) \
590 objc_cat_cls_meth_section (); \
591 else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17)) \
592 objc_class_names_section (); \
593 else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20)) \
594 objc_meth_var_names_section (); \
595 else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20)) \
596 objc_meth_var_types_section (); \
597 else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22)) \
598 objc_cls_refs_section (); \
599 else if (!strncmp (name, "_OBJC_CLASS_", 12)) \
600 objc_class_section (); \
601 else if (!strncmp (name, "_OBJC_METACLASS_", 16)) \
602 objc_meta_class_section (); \
603 else if (!strncmp (name, "_OBJC_CATEGORY_", 15)) \
604 objc_category_section (); \
605 else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25)) \
606 objc_selector_refs_section (); \
607 else if (!strncmp (name, "_OBJC_SELECTOR_FIXUP", 20)) \
608 objc_selector_fixup_section (); \
609 else if (!strncmp (name, "_OBJC_SYMBOLS", 13)) \
610 objc_symbols_section (); \
611 else if (!strncmp (name, "_OBJC_MODULES", 13)) \
612 objc_module_info_section (); \
613 else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) \
614 objc_cat_inst_meth_section (); \
615 else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) \
616 objc_cat_cls_meth_section (); \
617 else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20)) \
618 objc_cat_cls_meth_section (); \
619 else if (!strncmp (name, "_OBJC_PROTOCOL_", 15)) \
620 objc_protocol_section (); \
621 else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
622 && !TREE_SIDE_EFFECTS (exp)) \
623 { if (flag_pic && reloc ) const_data_section (); \
624 else readonly_data_section (); } \
628 else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
630 if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc) \
631 const_data_section (); \
633 readonly_data_section (); \
637 try_section_alias (); \
641 #undef SELECT_RTX_SECTION
642 #define SELECT_RTX_SECTION(mode, rtx) \
645 if (GET_MODE_SIZE (mode) == 8) \
646 literal8_section (); \
647 else if (GET_MODE_SIZE (mode) == 4) \
648 literal4_section (); \
654 #define ASM_DECLARE_UNRESOLVED_REFERENCE(FILE,NAME) \
658 fprintf (FILE, "\t.lazy_reference "); \
660 fprintf (FILE, "\t.reference "); \
661 assemble_name (FILE, NAME); \
662 fprintf (FILE, "\n"); \
666 #define ASM_DECLARE_CLASS_REFERENCE(FILE,NAME) \
669 fprintf (FILE, "\t"); \
670 assemble_name (FILE, NAME); \
671 fprintf (FILE, "=0\n"); \
672 assemble_global (NAME); \
676 #undef ASM_GLOBALIZE_LABEL
677 #define ASM_GLOBALIZE_LABEL(FILE,NAME) \
678 do { const char* _x = (NAME); if (!!strncmp (_x, "_OBJC_", 6)) { \
679 (fputs (".globl ", FILE), assemble_name (FILE, _x), fputs ("\n", FILE)); \
682 #undef ASM_GENERATE_INTERNAL_LABEL
683 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
684 sprintf (LABEL, "*%s%d", PREFIX, NUM)
686 /* This is how to output an internal numbered label where PREFIX is
687 the class of label and NUM is the number within the class. */
689 #undef ASM_OUTPUT_INTERNAL_LABEL
690 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
691 fprintf (FILE, "%s%d:\n", PREFIX, NUM)
693 /* Since we have a separate readonly data section, define this so that
694 jump tables end up in text rather than data. */
696 #ifndef JUMP_TABLES_IN_TEXT_SECTION
697 #define JUMP_TABLES_IN_TEXT_SECTION 1
700 /* Symbolic names for various things we might know about a symbol. */
702 enum machopic_addr_class {
704 MACHOPIC_DEFINED_DATA,
705 MACHOPIC_UNDEFINED_DATA,
706 MACHOPIC_DEFINED_FUNCTION,
707 MACHOPIC_UNDEFINED_FUNCTION
710 /* Macros defining the various PIC cases. */
712 #define MACHOPIC_INDIRECT (flag_pic)
713 #define MACHOPIC_JUST_INDIRECT (flag_pic == 1)
714 #define MACHOPIC_PURE (flag_pic == 2)
716 #define ENCODE_SECTION_INFO(DECL) \
717 darwin_encode_section_info (DECL)
719 /* Be conservative and always redo the encoding. */
721 #define REDO_SECTION_INFO_P(DECL) (1)
723 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
724 ((VAR) = ((SYMBOL_NAME[0] == '!') ? (SYMBOL_NAME) + 4 : (SYMBOL_NAME)))
726 #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH) \
728 const char *stub_ = (STUB); \
729 char *buffer_ = (BUF); \
730 strcpy (buffer_, stub_); \
731 if (stub_[0] == '"') \
733 strcpy (buffer_ + (STUB_LENGTH) - 1, "_binder\""); \
737 strcpy (buffer_ + (STUB_LENGTH), "_binder"); \
741 #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
743 const char *symbol_ = (SYMBOL); \
744 char *buffer_ = (BUF); \
745 if (name_needs_quotes (symbol_) && symbol_[0] != '"') \
747 sprintf (buffer_, "\"%s\"", symbol_); \
751 strcpy (buffer_, symbol_); \
755 /* Given a symbol name string, create the lazy pointer version
756 of the symbol name. */
758 #define GEN_LAZY_PTR_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
760 const char *symbol_ = (SYMBOL); \
761 char *buffer_ = (BUF); \
762 STRIP_NAME_ENCODING (symbol_, symbol_); \
763 if (symbol_[0] == '"') \
765 strcpy (buffer_, "\"L"); \
766 strcpy (buffer_ + 2, symbol_ + 1); \
767 strcpy (buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\""); \
769 else if (name_needs_quotes (symbol_)) \
771 strcpy (buffer_, "\"L"); \
772 strcpy (buffer_ + 2, symbol_); \
773 strcpy (buffer_ + (SYMBOL_LENGTH) + 2, "$lazy_ptr\""); \
777 strcpy (buffer_, "L"); \
778 strcpy (buffer_ + 1, symbol_); \
779 strcpy (buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr"); \
783 #define REGISTER_TARGET_PRAGMAS(PFILE) \
785 cpp_register_pragma (PFILE, 0, "mark", darwin_pragma_ignore); \
786 cpp_register_pragma (PFILE, 0, "options", darwin_pragma_options); \
787 cpp_register_pragma (PFILE, 0, "segment", darwin_pragma_ignore); \
788 cpp_register_pragma (PFILE, 0, "unused", darwin_pragma_unused); \