PR c++/3637
[official-gcc.git] / gcc / config / darwin.h
blobcfa2bd5745f037d03edf16e4f28d4f16026bae69
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 (lang_hooks.name, "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 const 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 const 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 extern void FUNCTION PARAMS ((void)); \
314 void \
315 FUNCTION () \
317 if (in_section != SECTION) \
319 if (OBJC) \
320 objc_section_init (); \
321 data_section (); \
322 if (asm_out_file) \
323 fprintf (asm_out_file, "%s\n", DIRECTIVE); \
324 in_section = SECTION; \
328 #define ALIAS_SECTION(enum_value, alias_name) \
329 do { if (!strcmp (alias_name, name)) \
330 section_alias[enum_value] = (alias ? get_identifier (alias) : 0); \
331 } while (0)
333 /* Darwin uses many types of special sections. */
335 #undef EXTRA_SECTIONS
336 #define EXTRA_SECTIONS \
337 in_const, in_const_data, in_cstring, in_literal4, in_literal8, \
338 in_constructor, in_destructor, in_mod_init, in_mod_term, \
339 in_objc_class, in_objc_meta_class, in_objc_category, \
340 in_objc_class_vars, in_objc_instance_vars, \
341 in_objc_cls_meth, in_objc_inst_meth, \
342 in_objc_cat_cls_meth, in_objc_cat_inst_meth, \
343 in_objc_selector_refs, \
344 in_objc_selector_fixup, \
345 in_objc_symbols, in_objc_module_info, \
346 in_objc_protocol, in_objc_string_object, \
347 in_objc_constant_string_object, \
348 in_objc_class_names, in_objc_meth_var_names, \
349 in_objc_meth_var_types, in_objc_cls_refs, \
350 in_machopic_nl_symbol_ptr, \
351 in_machopic_lazy_symbol_ptr, \
352 in_machopic_symbol_stub, \
353 in_machopic_picsymbol_stub, \
354 in_darwin_exception, in_darwin_eh_frame, \
355 num_sections
357 #undef EXTRA_SECTION_FUNCTIONS
358 #define EXTRA_SECTION_FUNCTIONS \
359 static void objc_section_init PARAMS ((void)); \
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) \
463 SECTION_FUNCTION (darwin_eh_frame_section, \
464 in_darwin_eh_frame, \
465 ".section __TEXT,__eh_frame", 0) \
467 static void \
468 objc_section_init () \
470 static int been_here = 0; \
472 if (been_here == 0) \
474 been_here = 1; \
475 /* written, cold -> hot */ \
476 objc_cat_cls_meth_section (); \
477 objc_cat_inst_meth_section (); \
478 objc_string_object_section (); \
479 objc_constant_string_object_section (); \
480 objc_selector_refs_section (); \
481 objc_selector_fixup_section (); \
482 objc_cls_refs_section (); \
483 objc_class_section (); \
484 objc_meta_class_section (); \
485 /* shared, hot -> cold */ \
486 objc_cls_meth_section (); \
487 objc_inst_meth_section (); \
488 objc_protocol_section (); \
489 objc_class_names_section (); \
490 objc_meth_var_types_section (); \
491 objc_meth_var_names_section (); \
492 objc_category_section (); \
493 objc_class_vars_section (); \
494 objc_instance_vars_section (); \
495 objc_module_info_section (); \
496 objc_symbols_section (); \
499 static tree section_alias[(int) num_sections]; \
500 static void try_section_alias PARAMS ((void)); \
501 static void try_section_alias () \
503 if (section_alias[in_section] && asm_out_file) \
504 fprintf (asm_out_file, "%s\n", \
505 IDENTIFIER_POINTER (section_alias[in_section])); \
508 #if 0
509 static void alias_section PARAMS ((const char *, const char *)); \
510 static void alias_section (name, alias) \
511 const char *name, *alias; \
513 ALIAS_SECTION (in_data, "data"); \
514 ALIAS_SECTION (in_text, "text"); \
515 ALIAS_SECTION (in_const, "const"); \
516 ALIAS_SECTION (in_const_data, "const_data"); \
517 ALIAS_SECTION (in_cstring, "cstring"); \
518 ALIAS_SECTION (in_literal4, "literal4"); \
519 ALIAS_SECTION (in_literal8, "literal8"); \
521 #endif
523 #undef READONLY_DATA_SECTION
524 #define READONLY_DATA_SECTION const_section
526 #undef SELECT_SECTION
527 #define SELECT_SECTION(exp,reloc,align) \
528 do \
530 if (TREE_CODE (exp) == STRING_CST) \
532 if (flag_writable_strings) \
533 data_section (); \
534 else if (TREE_STRING_LENGTH (exp) != \
535 strlen (TREE_STRING_POINTER (exp)) + 1) \
536 readonly_data_section (); \
537 else \
538 cstring_section (); \
540 else if (TREE_CODE (exp) == INTEGER_CST \
541 || TREE_CODE (exp) == REAL_CST) \
543 tree size = TYPE_SIZE (TREE_TYPE (exp)); \
545 if (TREE_CODE (size) == INTEGER_CST && \
546 TREE_INT_CST_LOW (size) == 4 && \
547 TREE_INT_CST_HIGH (size) == 0) \
548 literal4_section (); \
549 else if (TREE_CODE (size) == INTEGER_CST && \
550 TREE_INT_CST_LOW (size) == 8 && \
551 TREE_INT_CST_HIGH (size) == 0) \
552 literal8_section (); \
553 else \
554 readonly_data_section (); \
556 else if (TREE_CODE (exp) == CONSTRUCTOR \
557 && TREE_TYPE (exp) \
558 && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE \
559 && TYPE_NAME (TREE_TYPE (exp))) \
561 tree name = TYPE_NAME (TREE_TYPE (exp)); \
562 if (TREE_CODE (name) == TYPE_DECL) \
563 name = DECL_NAME (name); \
564 if (!strcmp (IDENTIFIER_POINTER (name), "NSConstantString")) \
565 objc_constant_string_object_section (); \
566 else if (!strcmp (IDENTIFIER_POINTER (name), "NXConstantString")) \
567 objc_string_object_section (); \
568 else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
570 if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc) \
571 const_data_section (); \
572 else \
573 readonly_data_section (); \
575 else \
576 data_section (); \
578 else if (TREE_CODE (exp) == VAR_DECL && \
579 DECL_NAME (exp) && \
580 TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE && \
581 IDENTIFIER_POINTER (DECL_NAME (exp)) && \
582 !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \
584 const char *name = IDENTIFIER_POINTER (DECL_NAME (exp)); \
586 if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20)) \
587 objc_cls_meth_section (); \
588 else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23)) \
589 objc_inst_meth_section (); \
590 else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \
591 objc_cat_cls_meth_section (); \
592 else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \
593 objc_cat_inst_meth_section (); \
594 else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22)) \
595 objc_class_vars_section (); \
596 else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25)) \
597 objc_instance_vars_section (); \
598 else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22)) \
599 objc_cat_cls_meth_section (); \
600 else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17)) \
601 objc_class_names_section (); \
602 else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20)) \
603 objc_meth_var_names_section (); \
604 else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20)) \
605 objc_meth_var_types_section (); \
606 else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22)) \
607 objc_cls_refs_section (); \
608 else if (!strncmp (name, "_OBJC_CLASS_", 12)) \
609 objc_class_section (); \
610 else if (!strncmp (name, "_OBJC_METACLASS_", 16)) \
611 objc_meta_class_section (); \
612 else if (!strncmp (name, "_OBJC_CATEGORY_", 15)) \
613 objc_category_section (); \
614 else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25)) \
615 objc_selector_refs_section (); \
616 else if (!strncmp (name, "_OBJC_SELECTOR_FIXUP", 20)) \
617 objc_selector_fixup_section (); \
618 else if (!strncmp (name, "_OBJC_SYMBOLS", 13)) \
619 objc_symbols_section (); \
620 else if (!strncmp (name, "_OBJC_MODULES", 13)) \
621 objc_module_info_section (); \
622 else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) \
623 objc_cat_inst_meth_section (); \
624 else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) \
625 objc_cat_cls_meth_section (); \
626 else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20)) \
627 objc_cat_cls_meth_section (); \
628 else if (!strncmp (name, "_OBJC_PROTOCOL_", 15)) \
629 objc_protocol_section (); \
630 else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
631 && !TREE_SIDE_EFFECTS (exp)) \
632 { if (flag_pic && reloc ) const_data_section (); \
633 else readonly_data_section (); } \
634 else \
635 data_section (); \
637 else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
639 if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc) \
640 const_data_section (); \
641 else \
642 readonly_data_section (); \
644 else \
645 data_section (); \
646 try_section_alias (); \
648 while (0)
650 /* This can be called with address expressions as "rtx".
651 They must go in "const". */
652 #undef SELECT_RTX_SECTION
653 #define SELECT_RTX_SECTION(mode, rtx, align) \
654 do \
656 if (GET_MODE_SIZE (mode) == 8) \
657 literal8_section (); \
658 else if (GET_MODE_SIZE (mode) == 4 \
659 && (GET_CODE (rtx) == CONST_INT \
660 || GET_CODE (rtx) == CONST_DOUBLE)) \
661 literal4_section (); \
662 else \
663 const_section (); \
665 while (0)
667 #define ASM_DECLARE_UNRESOLVED_REFERENCE(FILE,NAME) \
668 do { \
669 if (FILE) { \
670 if (flag_pic) \
671 fprintf (FILE, "\t.lazy_reference "); \
672 else \
673 fprintf (FILE, "\t.reference "); \
674 assemble_name (FILE, NAME); \
675 fprintf (FILE, "\n"); \
677 } while (0)
679 #define ASM_DECLARE_CLASS_REFERENCE(FILE,NAME) \
680 do { \
681 if (FILE) { \
682 fprintf (FILE, "\t"); \
683 assemble_name (FILE, NAME); \
684 fprintf (FILE, "=0\n"); \
685 assemble_global (NAME); \
687 } while (0)
689 #undef ASM_GLOBALIZE_LABEL
690 #define ASM_GLOBALIZE_LABEL(FILE,NAME) \
691 do { const char *const _x = (NAME); if (!!strncmp (_x, "_OBJC_", 6)) { \
692 (fputs (".globl ", FILE), assemble_name (FILE, _x), fputs ("\n", FILE)); \
693 }} while (0)
695 #undef ASM_GENERATE_INTERNAL_LABEL
696 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
697 sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM))
699 /* This is how to output an internal numbered label where PREFIX is
700 the class of label and NUM is the number within the class. */
702 #undef ASM_OUTPUT_INTERNAL_LABEL
703 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
704 fprintf (FILE, "%s%d:\n", PREFIX, NUM)
706 /* Since we have a separate readonly data section, define this so that
707 jump tables end up in text rather than data. */
709 #ifndef JUMP_TABLES_IN_TEXT_SECTION
710 #define JUMP_TABLES_IN_TEXT_SECTION 1
711 #endif
713 /* Symbolic names for various things we might know about a symbol. */
715 enum machopic_addr_class {
716 MACHOPIC_UNDEFINED,
717 MACHOPIC_DEFINED_DATA,
718 MACHOPIC_UNDEFINED_DATA,
719 MACHOPIC_DEFINED_FUNCTION,
720 MACHOPIC_UNDEFINED_FUNCTION
723 /* Macros defining the various PIC cases. */
725 #define MACHOPIC_INDIRECT (flag_pic)
726 #define MACHOPIC_JUST_INDIRECT (flag_pic == 1)
727 #define MACHOPIC_PURE (flag_pic == 2)
729 #define ENCODE_SECTION_INFO(DECL) \
730 darwin_encode_section_info (DECL)
732 /* Be conservative and always redo the encoding. */
734 #define REDO_SECTION_INFO_P(DECL) (1)
736 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
737 ((VAR) = ((SYMBOL_NAME[0] == '!') ? (SYMBOL_NAME) + 4 : (SYMBOL_NAME)))
739 #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH) \
740 do { \
741 const char *const stub_ = (STUB); \
742 char *buffer_ = (BUF); \
743 strcpy (buffer_, stub_); \
744 if (stub_[0] == '"') \
746 strcpy (buffer_ + (STUB_LENGTH) - 1, "_binder\""); \
748 else \
750 strcpy (buffer_ + (STUB_LENGTH), "_binder"); \
752 } while (0)
754 #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
755 do { \
756 const char *const symbol_ = (SYMBOL); \
757 char *buffer_ = (BUF); \
758 if (name_needs_quotes (symbol_) && symbol_[0] != '"') \
760 sprintf (buffer_, "\"%s\"", symbol_); \
762 else \
764 strcpy (buffer_, symbol_); \
766 } while (0)
768 /* Given a symbol name string, create the lazy pointer version
769 of the symbol name. */
771 #define GEN_LAZY_PTR_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
772 do { \
773 const char *symbol_ = (SYMBOL); \
774 char *buffer_ = (BUF); \
775 STRIP_NAME_ENCODING (symbol_, symbol_); \
776 if (symbol_[0] == '"') \
778 strcpy (buffer_, "\"L"); \
779 strcpy (buffer_ + 2, symbol_ + 1); \
780 strcpy (buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\""); \
782 else if (name_needs_quotes (symbol_)) \
784 strcpy (buffer_, "\"L"); \
785 strcpy (buffer_ + 2, symbol_); \
786 strcpy (buffer_ + (SYMBOL_LENGTH) + 2, "$lazy_ptr\""); \
788 else \
790 strcpy (buffer_, "L"); \
791 strcpy (buffer_ + 1, symbol_); \
792 strcpy (buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr"); \
794 } while (0)
796 #define TARGET_ASM_EXCEPTION_SECTION darwin_exception_section
798 #define TARGET_ASM_EH_FRAME_SECTION darwin_eh_frame_section
800 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
801 (((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)
803 #define REGISTER_TARGET_PRAGMAS(PFILE) \
804 do { \
805 cpp_register_pragma (PFILE, 0, "mark", darwin_pragma_ignore); \
806 cpp_register_pragma (PFILE, 0, "options", darwin_pragma_options); \
807 cpp_register_pragma (PFILE, 0, "segment", darwin_pragma_ignore); \
808 cpp_register_pragma (PFILE, 0, "unused", darwin_pragma_unused); \
809 } while (0)