2002-05-03 David S. Miller <davem@redhat.com>
[official-gcc.git] / gcc / config / darwin.h
blobc5a078b025e50a655296a23f837d63f6da97a6c9
1 /* Target definitions for Darwin (Mac OS X) systems.
2 Copyright (C) 1989, 1990, 1991, 1992, 1993, 2000, 2001, 2002
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 #undef INIT_SECTION_ASM_OP
154 #define INIT_SECTION_ASM_OP
156 #undef INVOKE__main
158 #define TARGET_ASM_CONSTRUCTOR machopic_asm_out_constructor
159 #define TARGET_ASM_DESTRUCTOR machopic_asm_out_destructor
162 /* Don't output a .file directive. That is only used by the assembler for
163 error reporting. */
165 #undef ASM_FILE_START
166 #define ASM_FILE_START(FILE)
168 #undef ASM_FILE_END
169 #define ASM_FILE_END(FILE) \
170 do { \
171 machopic_finish (asm_out_file); \
172 if (strcmp (lang_hooks.name, "GNU C++") == 0) \
174 constructor_section (); \
175 destructor_section (); \
176 ASM_OUTPUT_ALIGN (FILE, 1); \
178 } while (0)
180 /* Give ObjcC methods pretty symbol names. */
182 #undef OBJC_GEN_METHOD_LABEL
183 #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \
184 do { if (CAT_NAME) \
185 sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+', \
186 (CLASS_NAME), (CAT_NAME), (SEL_NAME)); \
187 else \
188 sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+', \
189 (CLASS_NAME), (SEL_NAME)); \
190 } while (0)
192 /* The RTTI data (e.g., __ti4name) is common and public (and static),
193 but it does need to be referenced via indirect PIC data pointers.
194 The machopic_define_name calls are telling the machopic subsystem
195 that the name *is* defined in this module, so it doesn't need to
196 make them indirect. */
198 #undef ASM_DECLARE_OBJECT_NAME
199 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
200 do { \
201 const char *xname = NAME; \
202 if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
203 xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
204 if ((TREE_STATIC (DECL) \
205 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
206 || DECL_INITIAL (DECL)) \
207 machopic_define_name (xname); \
208 if ((TREE_STATIC (DECL) \
209 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
210 || DECL_INITIAL (DECL)) \
211 ENCODE_SECTION_INFO (DECL, false); \
212 ASM_OUTPUT_LABEL (FILE, xname); \
213 } while (0)
215 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
216 do { \
217 const char *xname = NAME; \
218 if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
219 xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
220 if ((TREE_STATIC (DECL) \
221 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
222 || DECL_INITIAL (DECL)) \
223 machopic_define_name (xname); \
224 if ((TREE_STATIC (DECL) \
225 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
226 || DECL_INITIAL (DECL)) \
227 ENCODE_SECTION_INFO (DECL, false); \
228 ASM_OUTPUT_LABEL (FILE, xname); \
229 /* Avoid generating stubs for functions we've just defined by \
230 outputting any required stub name label now. */ \
231 machopic_output_possible_stub_label (FILE, xname); \
232 } while (0)
234 /* Wrap new method names in quotes so the assembler doesn't gag.
235 Make Objective-C internal symbols local. */
237 #undef ASM_OUTPUT_LABELREF
238 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
239 do { \
240 STRIP_NAME_ENCODING (NAME, NAME); \
241 if (NAME[0] == '&' || NAME[0] == '*') \
243 int len = strlen (NAME); \
244 if (len > 6 && !strcmp ("$stub", NAME + len - 5)) \
245 machopic_validate_stub_or_non_lazy_ptr (NAME, 1); \
246 else if (len > 7 && !strcmp ("$stub\"", NAME + len - 6)) \
247 machopic_validate_stub_or_non_lazy_ptr (NAME, 1); \
248 else if (len > 14 && !strcmp ("$non_lazy_ptr", NAME + len - 13)) \
249 machopic_validate_stub_or_non_lazy_ptr (NAME, 0); \
250 fputs (&NAME[1], FILE); \
252 else if (NAME[0] == '+' || NAME[0] == '-') \
253 fprintf (FILE, "\"%s\"", NAME); \
254 else if (!strncmp (NAME, "_OBJC_", 6)) \
255 fprintf (FILE, "L%s", NAME); \
256 else if (!strncmp (NAME, ".objc_class_name_", 17)) \
257 fprintf (FILE, "%s", NAME); \
258 else \
259 fprintf (FILE, "_%s", NAME); \
260 } while (0)
262 #undef ALIGN_ASM_OP
263 #define ALIGN_ASM_OP ".align"
265 #undef ASM_OUTPUT_ALIGN
266 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
267 if ((LOG) != 0) \
268 fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG))
270 /* Ensure correct alignment of bss data. */
272 #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
273 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
274 do { \
275 fputs (".lcomm ", (FILE)); \
276 assemble_name ((FILE), (NAME)); \
277 fprintf ((FILE), ",%u,%u\n", (SIZE), \
278 floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
279 if ((DECL) && ((TREE_STATIC (DECL) \
280 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
281 || DECL_INITIAL (DECL))) \
282 ENCODE_SECTION_INFO (DECL, false); \
283 if ((DECL) && ((TREE_STATIC (DECL) \
284 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
285 || DECL_INITIAL (DECL))) \
286 machopic_define_name (NAME); \
287 } while (0)
289 /* Output nothing for #ident. */
291 #undef ASM_OUTPUT_IDENT
292 #define ASM_OUTPUT_IDENT(FILE, NAME)
294 /* The maximum alignment which the object file format can support.
295 For Mach-O, this is 2^15. */
297 #undef MAX_OFILE_ALIGNMENT
298 #define MAX_OFILE_ALIGNMENT 0x8000
300 /* Create new Mach-O sections. */
302 #undef SECTION_FUNCTION
303 #define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, OBJC) \
304 extern void FUNCTION PARAMS ((void)); \
305 void \
306 FUNCTION () \
308 if (in_section != SECTION) \
310 if (OBJC) \
311 objc_section_init (); \
312 data_section (); \
313 if (asm_out_file) \
314 fprintf (asm_out_file, "%s\n", DIRECTIVE); \
315 in_section = SECTION; \
319 #define ALIAS_SECTION(enum_value, alias_name) \
320 do { if (!strcmp (alias_name, name)) \
321 section_alias[enum_value] = (alias ? get_identifier (alias) : 0); \
322 } while (0)
324 /* Darwin uses many types of special sections. */
326 #undef EXTRA_SECTIONS
327 #define EXTRA_SECTIONS \
328 in_const, in_const_data, in_cstring, in_literal4, in_literal8, \
329 in_constructor, in_destructor, in_mod_init, in_mod_term, \
330 in_objc_class, in_objc_meta_class, in_objc_category, \
331 in_objc_class_vars, in_objc_instance_vars, \
332 in_objc_cls_meth, in_objc_inst_meth, \
333 in_objc_cat_cls_meth, in_objc_cat_inst_meth, \
334 in_objc_selector_refs, \
335 in_objc_selector_fixup, \
336 in_objc_symbols, in_objc_module_info, \
337 in_objc_protocol, in_objc_string_object, \
338 in_objc_constant_string_object, \
339 in_objc_class_names, in_objc_meth_var_names, \
340 in_objc_meth_var_types, in_objc_cls_refs, \
341 in_machopic_nl_symbol_ptr, \
342 in_machopic_lazy_symbol_ptr, \
343 in_machopic_symbol_stub, \
344 in_machopic_picsymbol_stub, \
345 in_darwin_exception, in_darwin_eh_frame, \
346 num_sections
348 #undef EXTRA_SECTION_FUNCTIONS
349 #define EXTRA_SECTION_FUNCTIONS \
350 static void objc_section_init PARAMS ((void)); \
351 SECTION_FUNCTION (const_section, \
352 in_const, \
353 ".const", 0) \
354 SECTION_FUNCTION (const_data_section, \
355 in_const_data, \
356 ".const_data", 0) \
357 SECTION_FUNCTION (cstring_section, \
358 in_cstring, \
359 ".cstring", 0) \
360 SECTION_FUNCTION (literal4_section, \
361 in_literal4, \
362 ".literal4", 0) \
363 SECTION_FUNCTION (literal8_section, \
364 in_literal8, \
365 ".literal8", 0) \
366 SECTION_FUNCTION (constructor_section, \
367 in_constructor, \
368 ".constructor", 0) \
369 SECTION_FUNCTION (mod_init_section, \
370 in_mod_init, \
371 ".mod_init_func", 0) \
372 SECTION_FUNCTION (mod_term_section, \
373 in_mod_term, \
374 ".mod_term_func", 0) \
375 SECTION_FUNCTION (destructor_section, \
376 in_destructor, \
377 ".destructor", 0) \
378 SECTION_FUNCTION (objc_class_section, \
379 in_objc_class, \
380 ".objc_class", 1) \
381 SECTION_FUNCTION (objc_meta_class_section, \
382 in_objc_meta_class, \
383 ".objc_meta_class", 1) \
384 SECTION_FUNCTION (objc_category_section, \
385 in_objc_category, \
386 ".objc_category", 1) \
387 SECTION_FUNCTION (objc_class_vars_section, \
388 in_objc_class_vars, \
389 ".objc_class_vars", 1) \
390 SECTION_FUNCTION (objc_instance_vars_section, \
391 in_objc_instance_vars, \
392 ".objc_instance_vars", 1) \
393 SECTION_FUNCTION (objc_cls_meth_section, \
394 in_objc_cls_meth, \
395 ".objc_cls_meth", 1) \
396 SECTION_FUNCTION (objc_inst_meth_section, \
397 in_objc_inst_meth, \
398 ".objc_inst_meth", 1) \
399 SECTION_FUNCTION (objc_cat_cls_meth_section, \
400 in_objc_cat_cls_meth, \
401 ".objc_cat_cls_meth", 1) \
402 SECTION_FUNCTION (objc_cat_inst_meth_section, \
403 in_objc_cat_inst_meth, \
404 ".objc_cat_inst_meth", 1) \
405 SECTION_FUNCTION (objc_selector_refs_section, \
406 in_objc_selector_refs, \
407 ".objc_message_refs", 1) \
408 SECTION_FUNCTION (objc_selector_fixup_section, \
409 in_objc_selector_fixup, \
410 ".section __OBJC, __sel_fixup", 1) \
411 SECTION_FUNCTION (objc_symbols_section, \
412 in_objc_symbols, \
413 ".objc_symbols", 1) \
414 SECTION_FUNCTION (objc_module_info_section, \
415 in_objc_module_info, \
416 ".objc_module_info", 1) \
417 SECTION_FUNCTION (objc_protocol_section, \
418 in_objc_protocol, \
419 ".objc_protocol", 1) \
420 SECTION_FUNCTION (objc_string_object_section, \
421 in_objc_string_object, \
422 ".objc_string_object", 1) \
423 SECTION_FUNCTION (objc_constant_string_object_section, \
424 in_objc_constant_string_object, \
425 ".section __OBJC, __cstring_object", 1) \
426 SECTION_FUNCTION (objc_class_names_section, \
427 in_objc_class_names, \
428 ".objc_class_names", 1) \
429 SECTION_FUNCTION (objc_meth_var_names_section, \
430 in_objc_meth_var_names, \
431 ".objc_meth_var_names", 1) \
432 SECTION_FUNCTION (objc_meth_var_types_section, \
433 in_objc_meth_var_types, \
434 ".objc_meth_var_types", 1) \
435 SECTION_FUNCTION (objc_cls_refs_section, \
436 in_objc_cls_refs, \
437 ".objc_cls_refs", 1) \
439 SECTION_FUNCTION (machopic_lazy_symbol_ptr_section, \
440 in_machopic_lazy_symbol_ptr, \
441 ".lazy_symbol_pointer", 0) \
442 SECTION_FUNCTION (machopic_nl_symbol_ptr_section, \
443 in_machopic_nl_symbol_ptr, \
444 ".non_lazy_symbol_pointer", 0) \
445 SECTION_FUNCTION (machopic_symbol_stub_section, \
446 in_machopic_symbol_stub, \
447 ".symbol_stub", 0) \
448 SECTION_FUNCTION (machopic_picsymbol_stub_section, \
449 in_machopic_picsymbol_stub, \
450 ".picsymbol_stub", 0) \
451 SECTION_FUNCTION (darwin_exception_section, \
452 in_darwin_exception, \
453 ".section __TEXT,__gcc_except_tab", 0) \
454 SECTION_FUNCTION (darwin_eh_frame_section, \
455 in_darwin_eh_frame, \
456 ".section __TEXT,__eh_frame", 0) \
458 static void \
459 objc_section_init () \
461 static int been_here = 0; \
463 if (been_here == 0) \
465 been_here = 1; \
466 /* written, cold -> hot */ \
467 objc_cat_cls_meth_section (); \
468 objc_cat_inst_meth_section (); \
469 objc_string_object_section (); \
470 objc_constant_string_object_section (); \
471 objc_selector_refs_section (); \
472 objc_selector_fixup_section (); \
473 objc_cls_refs_section (); \
474 objc_class_section (); \
475 objc_meta_class_section (); \
476 /* shared, hot -> cold */ \
477 objc_cls_meth_section (); \
478 objc_inst_meth_section (); \
479 objc_protocol_section (); \
480 objc_class_names_section (); \
481 objc_meth_var_types_section (); \
482 objc_meth_var_names_section (); \
483 objc_category_section (); \
484 objc_class_vars_section (); \
485 objc_instance_vars_section (); \
486 objc_module_info_section (); \
487 objc_symbols_section (); \
490 static tree section_alias[(int) num_sections]; \
491 static void try_section_alias PARAMS ((void)); \
492 static void try_section_alias () \
494 if (section_alias[in_section] && asm_out_file) \
495 fprintf (asm_out_file, "%s\n", \
496 IDENTIFIER_POINTER (section_alias[in_section])); \
499 #if 0
500 static void alias_section PARAMS ((const char *, const char *)); \
501 static void alias_section (name, alias) \
502 const char *name, *alias; \
504 ALIAS_SECTION (in_data, "data"); \
505 ALIAS_SECTION (in_text, "text"); \
506 ALIAS_SECTION (in_const, "const"); \
507 ALIAS_SECTION (in_const_data, "const_data"); \
508 ALIAS_SECTION (in_cstring, "cstring"); \
509 ALIAS_SECTION (in_literal4, "literal4"); \
510 ALIAS_SECTION (in_literal8, "literal8"); \
512 #endif
514 #undef READONLY_DATA_SECTION
515 #define READONLY_DATA_SECTION const_section
517 #undef SELECT_SECTION
518 #define SELECT_SECTION(exp,reloc,align) \
519 do \
521 if (TREE_CODE (exp) == STRING_CST) \
523 if (flag_writable_strings) \
524 data_section (); \
525 else if (TREE_STRING_LENGTH (exp) != \
526 strlen (TREE_STRING_POINTER (exp)) + 1) \
527 readonly_data_section (); \
528 else \
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 (); \
544 else \
545 readonly_data_section (); \
547 else if (TREE_CODE (exp) == CONSTRUCTOR \
548 && TREE_TYPE (exp) \
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 (); \
563 else \
564 readonly_data_section (); \
566 else \
567 data_section (); \
569 else if (TREE_CODE (exp) == VAR_DECL && \
570 DECL_NAME (exp) && \
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 (); } \
625 else \
626 data_section (); \
628 else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
630 if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc) \
631 const_data_section (); \
632 else \
633 readonly_data_section (); \
635 else \
636 data_section (); \
637 try_section_alias (); \
639 while (0)
641 /* This can be called with address expressions as "rtx".
642 They must go in "const". */
643 #undef SELECT_RTX_SECTION
644 #define SELECT_RTX_SECTION(mode, rtx, align) \
645 do \
647 if (GET_MODE_SIZE (mode) == 8) \
648 literal8_section (); \
649 else if (GET_MODE_SIZE (mode) == 4 \
650 && (GET_CODE (rtx) == CONST_INT \
651 || GET_CODE (rtx) == CONST_DOUBLE)) \
652 literal4_section (); \
653 else \
654 const_section (); \
656 while (0)
658 #define ASM_DECLARE_UNRESOLVED_REFERENCE(FILE,NAME) \
659 do { \
660 if (FILE) { \
661 if (flag_pic) \
662 fprintf (FILE, "\t.lazy_reference "); \
663 else \
664 fprintf (FILE, "\t.reference "); \
665 assemble_name (FILE, NAME); \
666 fprintf (FILE, "\n"); \
668 } while (0)
670 #define ASM_DECLARE_CLASS_REFERENCE(FILE,NAME) \
671 do { \
672 if (FILE) { \
673 fprintf (FILE, "\t"); \
674 assemble_name (FILE, NAME); \
675 fprintf (FILE, "=0\n"); \
676 assemble_global (NAME); \
678 } while (0)
680 #undef ASM_GLOBALIZE_LABEL
681 #define ASM_GLOBALIZE_LABEL(FILE,NAME) \
682 do { const char *const _x = (NAME); if (!!strncmp (_x, "_OBJC_", 6)) { \
683 (fputs (".globl ", FILE), assemble_name (FILE, _x), fputs ("\n", FILE)); \
684 }} while (0)
686 #undef ASM_GENERATE_INTERNAL_LABEL
687 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
688 sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM))
690 /* This is how to output an internal numbered label where PREFIX is
691 the class of label and NUM is the number within the class. */
693 #undef ASM_OUTPUT_INTERNAL_LABEL
694 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
695 fprintf (FILE, "%s%d:\n", PREFIX, NUM)
697 /* Since we have a separate readonly data section, define this so that
698 jump tables end up in text rather than data. */
700 #ifndef JUMP_TABLES_IN_TEXT_SECTION
701 #define JUMP_TABLES_IN_TEXT_SECTION 1
702 #endif
704 /* Symbolic names for various things we might know about a symbol. */
706 enum machopic_addr_class {
707 MACHOPIC_UNDEFINED,
708 MACHOPIC_DEFINED_DATA,
709 MACHOPIC_UNDEFINED_DATA,
710 MACHOPIC_DEFINED_FUNCTION,
711 MACHOPIC_UNDEFINED_FUNCTION
714 /* Macros defining the various PIC cases. */
716 #define MACHOPIC_INDIRECT (flag_pic)
717 #define MACHOPIC_JUST_INDIRECT (flag_pic == 1)
718 #define MACHOPIC_PURE (flag_pic == 2)
720 #define ENCODE_SECTION_INFO(DECL, FIRST) \
721 darwin_encode_section_info (DECL, FIRST)
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) \
727 do { \
728 const char *const stub_ = (STUB); \
729 char *buffer_ = (BUF); \
730 strcpy (buffer_, stub_); \
731 if (stub_[0] == '"') \
733 strcpy (buffer_ + (STUB_LENGTH) - 1, "_binder\""); \
735 else \
737 strcpy (buffer_ + (STUB_LENGTH), "_binder"); \
739 } while (0)
741 #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
742 do { \
743 const char *const symbol_ = (SYMBOL); \
744 char *buffer_ = (BUF); \
745 if (name_needs_quotes (symbol_) && symbol_[0] != '"') \
747 sprintf (buffer_, "\"%s\"", symbol_); \
749 else \
751 strcpy (buffer_, symbol_); \
753 } while (0)
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) \
759 do { \
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\""); \
775 else \
777 strcpy (buffer_, "L"); \
778 strcpy (buffer_ + 1, symbol_); \
779 strcpy (buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr"); \
781 } while (0)
783 #define TARGET_ASM_EXCEPTION_SECTION darwin_exception_section
785 #define TARGET_ASM_EH_FRAME_SECTION darwin_eh_frame_section
787 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
788 (((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)
790 #define REGISTER_TARGET_PRAGMAS(PFILE) \
791 do { \
792 cpp_register_pragma (PFILE, 0, "mark", darwin_pragma_ignore); \
793 cpp_register_pragma (PFILE, 0, "options", darwin_pragma_options); \
794 cpp_register_pragma (PFILE, 0, "segment", darwin_pragma_ignore); \
795 cpp_register_pragma (PFILE, 0, "unused", darwin_pragma_unused); \
796 } while (0)