* Makefile.in (rtlanal.o): Depend on $(TM_P_H).
[official-gcc.git] / gcc / config / darwin.h
blobd4a8197ce4a6ce9783ffc6e179edb5f68f0ed52b
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)
11 any later version.
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
36 correctly. */
38 /* Suppress g++ attempt to link in the math library automatically.
39 (Some Darwin versions have a libm, but they seem to cause problems
40 for C++ executables.) */
42 #define MATH_LIBRARY ""
44 /* We have atexit. */
46 #define HAVE_ATEXIT
48 /* Define an empty body for the function do_global_dtors() in libgcc2.c. */
50 #define DO_GLOBAL_DTORS_BODY
52 /* The string value for __SIZE_TYPE__. */
54 #ifndef SIZE_TYPE
55 #define SIZE_TYPE "long unsigned int"
56 #endif
58 /* Type used for ptrdiff_t, as a string used in a declaration. */
60 #undef PTRDIFF_TYPE
61 #define PTRDIFF_TYPE "int"
63 /* wchar_t is int. */
65 #undef WCHAR_TYPE
66 #define WCHAR_TYPE "int"
67 #undef WCHAR_TYPE_SIZE
68 #define WCHAR_TYPE_SIZE 32
70 /* Default to using the NeXT-style runtime, since that's what is
71 pre-installed on Darwin systems. */
73 #define NEXT_OBJC_RUNTIME
75 /* Don't default to pcc-struct-return, because gcc is the only compiler, and
76 we want to retain compatibility with older gcc versions. */
78 #undef DEFAULT_PCC_STRUCT_RETURN
79 #define DEFAULT_PCC_STRUCT_RETURN 0
81 /* Don't warn about MacOS-style 'APPL' four-char-constants. */
83 #undef WARN_FOUR_CHAR_CONSTANTS
84 #define WARN_FOUR_CHAR_CONSTANTS 0
86 /* Machine dependent cpp options. */
88 /* The sequence here allows us to get a more specific version number
89 glued into __APPLE_CC__. Normally this number would be updated as
90 part of submitting to a release engineering organization. */
92 #ifndef APPLE_CC
93 #define APPLE_CC 999
94 #endif
96 #define STRINGIFY_THIS(x) # x
97 #define REALLY_STRINGIFY(x) STRINGIFY_THIS(x)
99 #undef CPP_SPEC
100 #define CPP_SPEC "-D__APPLE_CC__=" REALLY_STRINGIFY(APPLE_CC) " \
101 %{static:-D__STATIC__}%{!static:-D__DYNAMIC__}"
103 /* Machine dependent libraries. */
105 #undef LIB_SPEC
106 #define LIB_SPEC "%{!static:-lSystem}"
108 /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
110 #undef STARTFILE_SPEC
111 #define STARTFILE_SPEC \
112 "%{pg:%{static:-lgcrt0.o}%{!static:-lgcrt1.o}} \
113 %{!pg:%{static:-lcrt0.o}%{!static:-lcrt1.o}}"
115 #undef DOLLARS_IN_IDENTIFIERS
116 #define DOLLARS_IN_IDENTIFIERS 2
118 /* Allow #sccs (but don't do anything). */
120 #define SCCS_DIRECTIVE
122 /* We use Dbx symbol format. */
124 #define DBX_DEBUGGING_INFO
126 /* Also enable Dwarf 2 as an option. */
128 #define DWARF2_DEBUGGING_INFO
130 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
132 /* When generating stabs debugging, use N_BINCL entries. */
134 #define DBX_USE_BINCL
136 /* There is no limit to the length of stabs strings. */
138 #define DBX_CONTIN_LENGTH 0
140 /* gdb needs a null N_SO at the end of each file for scattered loading. */
142 #undef DBX_OUTPUT_MAIN_SOURCE_FILE_END
143 #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \
144 do { text_section (); \
145 fprintf (FILE, \
146 "\t.stabs \"%s\",%d,0,0,Letext\nLetext:\n", "" , N_SO); \
147 } while (0)
149 /* Our profiling scheme doesn't LP labels and counter words. */
151 #define NO_PROFILE_COUNTERS
153 /* Don't use .gcc_compiled symbols to communicate with GDB;
154 They interfere with numerically sorted symbol lists. */
156 #undef ASM_IDENTIFY_GCC
157 #define ASM_IDENTIFY_GCC(asm_out_file)
159 #undef INIT_SECTION_ASM_OP
160 #define INIT_SECTION_ASM_OP
162 #undef INVOKE__main
164 #define TARGET_ASM_CONSTRUCTOR machopic_asm_out_constructor
165 #define TARGET_ASM_DESTRUCTOR machopic_asm_out_destructor
168 /* Don't output a .file directive. That is only used by the assembler for
169 error reporting. */
171 #undef ASM_FILE_START
172 #define ASM_FILE_START(FILE)
174 #undef ASM_FILE_END
175 #define ASM_FILE_END(FILE) \
176 do { \
177 machopic_finish (asm_out_file); \
178 if (strcmp (language_string, "GNU C++") == 0) \
180 constructor_section (); \
181 destructor_section (); \
182 ASM_OUTPUT_ALIGN (FILE, 1); \
184 } while (0)
186 /* Give ObjcC methods pretty symbol names. */
188 #undef OBJC_GEN_METHOD_LABEL
189 #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \
190 do { if (CAT_NAME) \
191 sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+', \
192 (CLASS_NAME), (CAT_NAME), (SEL_NAME)); \
193 else \
194 sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+', \
195 (CLASS_NAME), (SEL_NAME)); \
196 } while (0)
198 /* The RTTI data (e.g., __ti4name) is common and public (and static),
199 but it does need to be referenced via indirect PIC data pointers.
200 The machopic_define_name calls are telling the machopic subsystem
201 that the name *is* defined in this module, so it doesn't need to
202 make them indirect. */
204 #undef ASM_DECLARE_OBJECT_NAME
205 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
206 do { \
207 char *xname = NAME; \
208 if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
209 xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
210 if ((TREE_STATIC (DECL) \
211 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
212 || DECL_INITIAL (DECL)) \
213 machopic_define_name (xname); \
214 if ((TREE_STATIC (DECL) \
215 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
216 || DECL_INITIAL (DECL)) \
217 ENCODE_SECTION_INFO (DECL); \
218 ASM_OUTPUT_LABEL (FILE, xname); \
219 } while (0)
221 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
222 do { \
223 char *xname = NAME; \
224 if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
225 xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
226 if ((TREE_STATIC (DECL) \
227 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
228 || DECL_INITIAL (DECL)) \
229 machopic_define_name (xname); \
230 if ((TREE_STATIC (DECL) \
231 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
232 || DECL_INITIAL (DECL)) \
233 ENCODE_SECTION_INFO (DECL); \
234 ASM_OUTPUT_LABEL (FILE, xname); \
235 } while (0)
237 /* Wrap new method names in quotes so the assembler doesn't gag.
238 Make Objective-C internal symbols local. */
240 #undef ASM_OUTPUT_LABELREF
241 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
242 do { \
243 STRIP_NAME_ENCODING (NAME, NAME); \
244 if (NAME[0] == '&' || NAME[0] == '*') \
246 int len = strlen (NAME); \
247 if (len > 6 && !strcmp ("$stub", NAME + len - 5)) \
248 machopic_validate_stub_or_non_lazy_ptr (NAME, 1); \
249 else if (len > 7 && !strcmp ("$stub\"", NAME + len - 6)) \
250 machopic_validate_stub_or_non_lazy_ptr (NAME, 1); \
251 else if (len > 14 && !strcmp ("$non_lazy_ptr", NAME + len - 13)) \
252 machopic_validate_stub_or_non_lazy_ptr (NAME, 0); \
253 fputs (&NAME[1], FILE); \
255 else if (NAME[0] == '+' || NAME[0] == '-') \
256 fprintf (FILE, "\"%s\"", NAME); \
257 else if (!strncmp (NAME, "_OBJC_", 6)) \
258 fprintf (FILE, "L%s", NAME); \
259 else if (!strncmp (NAME, ".objc_class_name_", 17)) \
260 fprintf (FILE, "%s", NAME); \
261 else \
262 fprintf (FILE, "_%s", NAME); \
263 } while (0)
265 /* The standard fillin directives are unaligned. */
267 #define UNALIGNED_SHORT_ASM_OP "\t.short\t"
268 #define UNALIGNED_INT_ASM_OP "\t.long\t"
269 /* Don't try to use this before the assembler knows about it. */
270 /* #define UNALIGNED_DOUBLE_INT_ASM_OP "\t.quad\t" */
272 #undef ALIGN_ASM_OP
273 #define ALIGN_ASM_OP ".align"
275 #undef ASM_OUTPUT_ALIGN
276 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
277 if ((LOG) != 0) \
278 fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG))
280 /* Ensure correct alignment of bss data. */
282 #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
283 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
284 do { \
285 fputs (".lcomm ", (FILE)); \
286 assemble_name ((FILE), (NAME)); \
287 fprintf ((FILE), ",%u,%u\n", (SIZE), floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
288 if ((DECL) && ((TREE_STATIC (DECL) \
289 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
290 || DECL_INITIAL (DECL))) \
291 ENCODE_SECTION_INFO (DECL); \
292 if ((DECL) && ((TREE_STATIC (DECL) \
293 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
294 || DECL_INITIAL (DECL))) \
295 machopic_define_name (NAME); \
296 } while (0)
298 /* Output nothing for #ident. */
300 #undef ASM_OUTPUT_IDENT
301 #define ASM_OUTPUT_IDENT(FILE, NAME)
303 /* The maximum alignment which the object file format can support.
304 For Mach-O, this is 2^15. */
306 #undef MAX_OFILE_ALIGNMENT
307 #define MAX_OFILE_ALIGNMENT 0x8000
309 /* Create new Mach-O sections. */
311 #undef SECTION_FUNCTION
312 #define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, OBJC) \
313 void \
314 FUNCTION () \
316 extern void objc_section_init (); \
318 if (in_section != SECTION) \
320 if (OBJC) \
321 objc_section_init (); \
322 data_section (); \
323 if (asm_out_file) \
324 fprintf (asm_out_file, "%s\n", DIRECTIVE); \
325 in_section = SECTION; \
329 #define ALIAS_SECTION(enum_value, alias_name) \
330 do { if (!strcmp (alias_name, name)) \
331 section_alias[enum_value] = (alias ? get_identifier (alias) : 0); \
332 } while (0)
334 /* Darwin uses many types of special sections. */
336 #undef EXTRA_SECTIONS
337 #define EXTRA_SECTIONS \
338 in_const, in_const_data, in_cstring, in_literal4, in_literal8, \
339 in_constructor, in_destructor, in_mod_init, in_mod_term, \
340 in_objc_class, in_objc_meta_class, in_objc_category, \
341 in_objc_class_vars, in_objc_instance_vars, \
342 in_objc_cls_meth, in_objc_inst_meth, \
343 in_objc_cat_cls_meth, in_objc_cat_inst_meth, \
344 in_objc_selector_refs, \
345 in_objc_selector_fixup, \
346 in_objc_symbols, in_objc_module_info, \
347 in_objc_protocol, in_objc_string_object, \
348 in_objc_constant_string_object, \
349 in_objc_class_names, in_objc_meth_var_names, \
350 in_objc_meth_var_types, in_objc_cls_refs, \
351 in_machopic_nl_symbol_ptr, \
352 in_machopic_lazy_symbol_ptr, \
353 in_machopic_symbol_stub, \
354 in_machopic_picsymbol_stub, \
355 in_darwin_exception, \
356 num_sections
358 #undef EXTRA_SECTION_FUNCTIONS
359 #define EXTRA_SECTION_FUNCTIONS \
360 SECTION_FUNCTION (const_section, \
361 in_const, \
362 ".const", 0) \
363 SECTION_FUNCTION (const_data_section, \
364 in_const_data, \
365 ".const_data", 0) \
366 SECTION_FUNCTION (cstring_section, \
367 in_cstring, \
368 ".cstring", 0) \
369 SECTION_FUNCTION (literal4_section, \
370 in_literal4, \
371 ".literal4", 0) \
372 SECTION_FUNCTION (literal8_section, \
373 in_literal8, \
374 ".literal8", 0) \
375 SECTION_FUNCTION (constructor_section, \
376 in_constructor, \
377 ".constructor", 0) \
378 SECTION_FUNCTION (mod_init_section, \
379 in_mod_init, \
380 ".mod_init_func", 0) \
381 SECTION_FUNCTION (mod_term_section, \
382 in_mod_term, \
383 ".mod_term_func", 0) \
384 SECTION_FUNCTION (destructor_section, \
385 in_destructor, \
386 ".destructor", 0) \
387 SECTION_FUNCTION (objc_class_section, \
388 in_objc_class, \
389 ".objc_class", 1) \
390 SECTION_FUNCTION (objc_meta_class_section, \
391 in_objc_meta_class, \
392 ".objc_meta_class", 1) \
393 SECTION_FUNCTION (objc_category_section, \
394 in_objc_category, \
395 ".objc_category", 1) \
396 SECTION_FUNCTION (objc_class_vars_section, \
397 in_objc_class_vars, \
398 ".objc_class_vars", 1) \
399 SECTION_FUNCTION (objc_instance_vars_section, \
400 in_objc_instance_vars, \
401 ".objc_instance_vars", 1) \
402 SECTION_FUNCTION (objc_cls_meth_section, \
403 in_objc_cls_meth, \
404 ".objc_cls_meth", 1) \
405 SECTION_FUNCTION (objc_inst_meth_section, \
406 in_objc_inst_meth, \
407 ".objc_inst_meth", 1) \
408 SECTION_FUNCTION (objc_cat_cls_meth_section, \
409 in_objc_cat_cls_meth, \
410 ".objc_cat_cls_meth", 1) \
411 SECTION_FUNCTION (objc_cat_inst_meth_section, \
412 in_objc_cat_inst_meth, \
413 ".objc_cat_inst_meth", 1) \
414 SECTION_FUNCTION (objc_selector_refs_section, \
415 in_objc_selector_refs, \
416 ".objc_message_refs", 1) \
417 SECTION_FUNCTION (objc_selector_fixup_section, \
418 in_objc_selector_fixup, \
419 ".section __OBJC, __sel_fixup", 1) \
420 SECTION_FUNCTION (objc_symbols_section, \
421 in_objc_symbols, \
422 ".objc_symbols", 1) \
423 SECTION_FUNCTION (objc_module_info_section, \
424 in_objc_module_info, \
425 ".objc_module_info", 1) \
426 SECTION_FUNCTION (objc_protocol_section, \
427 in_objc_protocol, \
428 ".objc_protocol", 1) \
429 SECTION_FUNCTION (objc_string_object_section, \
430 in_objc_string_object, \
431 ".objc_string_object", 1) \
432 SECTION_FUNCTION (objc_constant_string_object_section, \
433 in_objc_constant_string_object, \
434 ".section __OBJC, __cstring_object", 1) \
435 SECTION_FUNCTION (objc_class_names_section, \
436 in_objc_class_names, \
437 ".objc_class_names", 1) \
438 SECTION_FUNCTION (objc_meth_var_names_section, \
439 in_objc_meth_var_names, \
440 ".objc_meth_var_names", 1) \
441 SECTION_FUNCTION (objc_meth_var_types_section, \
442 in_objc_meth_var_types, \
443 ".objc_meth_var_types", 1) \
444 SECTION_FUNCTION (objc_cls_refs_section, \
445 in_objc_cls_refs, \
446 ".objc_cls_refs", 1) \
448 SECTION_FUNCTION (machopic_lazy_symbol_ptr_section, \
449 in_machopic_lazy_symbol_ptr, \
450 ".lazy_symbol_pointer", 0) \
451 SECTION_FUNCTION (machopic_nl_symbol_ptr_section, \
452 in_machopic_nl_symbol_ptr, \
453 ".non_lazy_symbol_pointer", 0) \
454 SECTION_FUNCTION (machopic_symbol_stub_section, \
455 in_machopic_symbol_stub, \
456 ".symbol_stub", 0) \
457 SECTION_FUNCTION (machopic_picsymbol_stub_section, \
458 in_machopic_picsymbol_stub, \
459 ".picsymbol_stub", 0) \
460 SECTION_FUNCTION (darwin_exception_section, \
461 in_darwin_exception, \
462 ".section __TEXT,__gcc_except_tab", 0) \
464 void \
465 objc_section_init () \
467 static int been_here = 0; \
469 if (been_here == 0) \
471 been_here = 1; \
472 /* written, cold -> hot */ \
473 objc_cat_cls_meth_section (); \
474 objc_cat_inst_meth_section (); \
475 objc_string_object_section (); \
476 objc_constant_string_object_section (); \
477 objc_selector_refs_section (); \
478 objc_selector_fixup_section (); \
479 objc_cls_refs_section (); \
480 objc_class_section (); \
481 objc_meta_class_section (); \
482 /* shared, hot -> cold */ \
483 objc_cls_meth_section (); \
484 objc_inst_meth_section (); \
485 objc_protocol_section (); \
486 objc_class_names_section (); \
487 objc_meth_var_types_section (); \
488 objc_meth_var_names_section (); \
489 objc_category_section (); \
490 objc_class_vars_section (); \
491 objc_instance_vars_section (); \
492 objc_module_info_section (); \
493 objc_symbols_section (); \
496 static tree section_alias[(int) num_sections]; \
497 void try_section_alias () \
499 if (section_alias[in_section] && asm_out_file) \
500 fprintf (asm_out_file, "%s\n", \
501 IDENTIFIER_POINTER (section_alias[in_section])); \
503 void alias_section (name, alias) \
504 char *name, *alias; \
506 ALIAS_SECTION (in_data, "data"); \
507 ALIAS_SECTION (in_text, "text"); \
508 ALIAS_SECTION (in_const, "const"); \
509 ALIAS_SECTION (in_const_data, "const_data"); \
510 ALIAS_SECTION (in_cstring, "cstring"); \
511 ALIAS_SECTION (in_literal4, "literal4"); \
512 ALIAS_SECTION (in_literal8, "literal8"); \
515 #undef READONLY_DATA_SECTION
516 #define READONLY_DATA_SECTION const_section
518 #undef SELECT_SECTION
519 #define SELECT_SECTION(exp,reloc,align) \
520 do \
522 if (TREE_CODE (exp) == STRING_CST) \
524 if (flag_writable_strings) \
525 data_section (); \
526 else if (TREE_STRING_LENGTH (exp) != \
527 strlen (TREE_STRING_POINTER (exp)) + 1) \
528 readonly_data_section (); \
529 else \
530 cstring_section (); \
532 else if (TREE_CODE (exp) == INTEGER_CST \
533 || TREE_CODE (exp) == REAL_CST) \
535 tree size = TYPE_SIZE (TREE_TYPE (exp)); \
537 if (TREE_CODE (size) == INTEGER_CST && \
538 TREE_INT_CST_LOW (size) == 4 && \
539 TREE_INT_CST_HIGH (size) == 0) \
540 literal4_section (); \
541 else if (TREE_CODE (size) == INTEGER_CST && \
542 TREE_INT_CST_LOW (size) == 8 && \
543 TREE_INT_CST_HIGH (size) == 0) \
544 literal8_section (); \
545 else \
546 readonly_data_section (); \
548 else if (TREE_CODE (exp) == CONSTRUCTOR \
549 && TREE_TYPE (exp) \
550 && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE \
551 && TYPE_NAME (TREE_TYPE (exp))) \
553 tree name = TYPE_NAME (TREE_TYPE (exp)); \
554 if (TREE_CODE (name) == TYPE_DECL) \
555 name = DECL_NAME (name); \
556 if (!strcmp (IDENTIFIER_POINTER (name), "NSConstantString")) \
557 objc_constant_string_object_section (); \
558 else if (!strcmp (IDENTIFIER_POINTER (name), "NXConstantString")) \
559 objc_string_object_section (); \
560 else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
562 if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc) \
563 const_data_section (); \
564 else \
565 readonly_data_section (); \
567 else \
568 data_section (); \
570 else if (TREE_CODE (exp) == VAR_DECL && \
571 DECL_NAME (exp) && \
572 TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE && \
573 IDENTIFIER_POINTER (DECL_NAME (exp)) && \
574 !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \
576 const char *name = IDENTIFIER_POINTER (DECL_NAME (exp)); \
578 if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20)) \
579 objc_cls_meth_section (); \
580 else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23)) \
581 objc_inst_meth_section (); \
582 else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \
583 objc_cat_cls_meth_section (); \
584 else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \
585 objc_cat_inst_meth_section (); \
586 else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22)) \
587 objc_class_vars_section (); \
588 else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25)) \
589 objc_instance_vars_section (); \
590 else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22)) \
591 objc_cat_cls_meth_section (); \
592 else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17)) \
593 objc_class_names_section (); \
594 else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20)) \
595 objc_meth_var_names_section (); \
596 else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20)) \
597 objc_meth_var_types_section (); \
598 else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22)) \
599 objc_cls_refs_section (); \
600 else if (!strncmp (name, "_OBJC_CLASS_", 12)) \
601 objc_class_section (); \
602 else if (!strncmp (name, "_OBJC_METACLASS_", 16)) \
603 objc_meta_class_section (); \
604 else if (!strncmp (name, "_OBJC_CATEGORY_", 15)) \
605 objc_category_section (); \
606 else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25)) \
607 objc_selector_refs_section (); \
608 else if (!strncmp (name, "_OBJC_SELECTOR_FIXUP", 20)) \
609 objc_selector_fixup_section (); \
610 else if (!strncmp (name, "_OBJC_SYMBOLS", 13)) \
611 objc_symbols_section (); \
612 else if (!strncmp (name, "_OBJC_MODULES", 13)) \
613 objc_module_info_section (); \
614 else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) \
615 objc_cat_inst_meth_section (); \
616 else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) \
617 objc_cat_cls_meth_section (); \
618 else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20)) \
619 objc_cat_cls_meth_section (); \
620 else if (!strncmp (name, "_OBJC_PROTOCOL_", 15)) \
621 objc_protocol_section (); \
622 else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
623 && !TREE_SIDE_EFFECTS (exp)) \
624 { if (flag_pic && reloc ) const_data_section (); \
625 else readonly_data_section (); } \
626 else \
627 data_section (); \
629 else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
631 if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc) \
632 const_data_section (); \
633 else \
634 readonly_data_section (); \
636 else \
637 data_section (); \
638 try_section_alias (); \
640 while (0)
642 #undef SELECT_RTX_SECTION
643 #define SELECT_RTX_SECTION(mode, rtx, align) \
644 do \
646 if (GET_MODE_SIZE (mode) == 8) \
647 literal8_section (); \
648 else if (GET_MODE_SIZE (mode) == 4) \
649 literal4_section (); \
650 else \
651 const_section (); \
653 while (0)
655 #define ASM_DECLARE_UNRESOLVED_REFERENCE(FILE,NAME) \
656 do { \
657 if (FILE) { \
658 if (flag_pic) \
659 fprintf (FILE, "\t.lazy_reference "); \
660 else \
661 fprintf (FILE, "\t.reference "); \
662 assemble_name (FILE, NAME); \
663 fprintf (FILE, "\n"); \
665 } while (0)
667 #define ASM_DECLARE_CLASS_REFERENCE(FILE,NAME) \
668 do { \
669 if (FILE) { \
670 fprintf (FILE, "\t"); \
671 assemble_name (FILE, NAME); \
672 fprintf (FILE, "=0\n"); \
673 assemble_global (NAME); \
675 } while (0)
677 #undef ASM_GLOBALIZE_LABEL
678 #define ASM_GLOBALIZE_LABEL(FILE,NAME) \
679 do { const char *const _x = (NAME); if (!!strncmp (_x, "_OBJC_", 6)) { \
680 (fputs (".globl ", FILE), assemble_name (FILE, _x), fputs ("\n", FILE)); \
681 }} while (0)
683 #undef ASM_GENERATE_INTERNAL_LABEL
684 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
685 sprintf (LABEL, "*%s%d", PREFIX, NUM)
687 /* This is how to output an internal numbered label where PREFIX is
688 the class of label and NUM is the number within the class. */
690 #undef ASM_OUTPUT_INTERNAL_LABEL
691 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
692 fprintf (FILE, "%s%d:\n", PREFIX, NUM)
694 /* Since we have a separate readonly data section, define this so that
695 jump tables end up in text rather than data. */
697 #ifndef JUMP_TABLES_IN_TEXT_SECTION
698 #define JUMP_TABLES_IN_TEXT_SECTION 1
699 #endif
701 /* Symbolic names for various things we might know about a symbol. */
703 enum machopic_addr_class {
704 MACHOPIC_UNDEFINED,
705 MACHOPIC_DEFINED_DATA,
706 MACHOPIC_UNDEFINED_DATA,
707 MACHOPIC_DEFINED_FUNCTION,
708 MACHOPIC_UNDEFINED_FUNCTION
711 /* Macros defining the various PIC cases. */
713 #define MACHOPIC_INDIRECT (flag_pic)
714 #define MACHOPIC_JUST_INDIRECT (flag_pic == 1)
715 #define MACHOPIC_PURE (flag_pic == 2)
717 #define ENCODE_SECTION_INFO(DECL) \
718 darwin_encode_section_info (DECL)
720 /* Be conservative and always redo the encoding. */
722 #define REDO_SECTION_INFO_P(DECL) (1)
724 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
725 ((VAR) = ((SYMBOL_NAME[0] == '!') ? (SYMBOL_NAME) + 4 : (SYMBOL_NAME)))
727 #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH) \
728 do { \
729 const char *const stub_ = (STUB); \
730 char *buffer_ = (BUF); \
731 strcpy (buffer_, stub_); \
732 if (stub_[0] == '"') \
734 strcpy (buffer_ + (STUB_LENGTH) - 1, "_binder\""); \
736 else \
738 strcpy (buffer_ + (STUB_LENGTH), "_binder"); \
740 } while (0)
742 #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
743 do { \
744 const char *const symbol_ = (SYMBOL); \
745 char *buffer_ = (BUF); \
746 if (name_needs_quotes (symbol_) && symbol_[0] != '"') \
748 sprintf (buffer_, "\"%s\"", symbol_); \
750 else \
752 strcpy (buffer_, symbol_); \
754 } while (0)
756 /* Given a symbol name string, create the lazy pointer version
757 of the symbol name. */
759 #define GEN_LAZY_PTR_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
760 do { \
761 const char *symbol_ = (SYMBOL); \
762 char *buffer_ = (BUF); \
763 STRIP_NAME_ENCODING (symbol_, symbol_); \
764 if (symbol_[0] == '"') \
766 strcpy (buffer_, "\"L"); \
767 strcpy (buffer_ + 2, symbol_ + 1); \
768 strcpy (buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\""); \
770 else if (name_needs_quotes (symbol_)) \
772 strcpy (buffer_, "\"L"); \
773 strcpy (buffer_ + 2, symbol_); \
774 strcpy (buffer_ + (SYMBOL_LENGTH) + 2, "$lazy_ptr\""); \
776 else \
778 strcpy (buffer_, "L"); \
779 strcpy (buffer_ + 1, symbol_); \
780 strcpy (buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr"); \
782 } while (0)
784 #define EXCEPTION_SECTION() darwin_exception_section ()
786 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
787 (((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)
789 #define REGISTER_TARGET_PRAGMAS(PFILE) \
790 do { \
791 cpp_register_pragma (PFILE, 0, "mark", darwin_pragma_ignore); \
792 cpp_register_pragma (PFILE, 0, "options", darwin_pragma_options); \
793 cpp_register_pragma (PFILE, 0, "segment", darwin_pragma_ignore); \
794 cpp_register_pragma (PFILE, 0, "unused", darwin_pragma_unused); \
795 } while (0)