]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/darwin.h
Add Darwin (Mac OS X kernel) native support.
[thirdparty/gcc.git] / gcc / config / darwin.h
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.
5
6 This file is part of GNU CC.
7
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.
12
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.
17
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. */
22
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. */
29
30 /* Although NeXT ran on many different architectures, as of Jan 2001
31 the only supported Darwin targets are PowerPC and x86. */
32
33 /* Make the compiler look here for standard stuff. */
34
35 #undef STANDARD_EXEC_PREFIX
36 #define STANDARD_EXEC_PREFIX "/usr/libexec/"
37
38 /* Name of the command that invokes the compiler - used in g++.c. */
39
40 #undef GCC_NAME
41 #define GCC_NAME "cc"
42
43 /* Never try linking with -lm - used in g++.c. */
44
45 #define NO_MATH_LIBRARY
46
47 /* We have atexit. */
48
49 #define HAVE_ATEXIT
50
51 /* Define an empty body for the function do_global_dtors() in libgcc2.c. */
52
53 #define DO_GLOBAL_DTORS_BODY
54
55 /* The string value for __SIZE_TYPE__. */
56
57 #ifndef SIZE_TYPE
58 #define SIZE_TYPE "long unsigned int"
59 #endif
60
61 /* Type used for ptrdiff_t, as a string used in a declaration. */
62
63 #undef PTRDIFF_TYPE
64 #define PTRDIFF_TYPE "int"
65
66 /* wchar_t is int. */
67
68 #undef WCHAR_TYPE
69 #define WCHAR_TYPE "int"
70 #undef WCHAR_TYPE_SIZE
71 #define WCHAR_TYPE_SIZE 32
72
73 /* Don't default to pcc-struct-return, because gcc is the only compiler, and
74 we want to retain compatibility with older gcc versions. */
75
76 #undef DEFAULT_PCC_STRUCT_RETURN
77 #define DEFAULT_PCC_STRUCT_RETURN 0
78
79 /* Don't warn about MacOS-style 'APPL' four-char-constants. */
80
81 #undef WARN_FOUR_CHAR_CONSTANTS
82 #define WARN_FOUR_CHAR_CONSTANTS 0
83
84 /* Machine dependent cpp options. */
85
86 /* The sequence here allows us to get a more specific version number
87 glued into __APPLE_CC__. Normally this number would be updated as
88 part of submitting to a release engineering organization. */
89
90 #ifndef APPLE_CC
91 #define APPLE_CC 999
92 #endif
93
94 #define STRINGIFY_THIS(x) # x
95 #define REALLY_STRINGIFY(x) STRINGIFY_THIS(x)
96
97 #undef CPP_SPEC
98 #define CPP_SPEC "-D__APPLE_CC__=" REALLY_STRINGIFY(APPLE_CC) " \
99 %{static:-D__STATIC__}%{!static:-D__DYNAMIC__}"
100
101 /* Machine dependent libraries. */
102
103 #undef LIB_SPEC
104 #define LIB_SPEC \
105 "%{!static:%{!pg:-framework System}%{pg:-framework System,_profile}}"
106
107 #undef LIBGCC_SPEC
108 #define LIBGCC_SPEC "%{!shared:%{static:-lcc} \
109 %{!static:-lcc_dynamic}}"
110
111 /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
112
113 #undef STARTFILE_SPEC
114 #define STARTFILE_SPEC \
115 "%{pg:%{static:-lgcrt0.o}%{!static:-lgcrt1.o}} \
116 %{!pg:%{static:-lcrt0.o}%{!static:-lcrt1.o}}"
117
118 #undef DOLLARS_IN_IDENTIFIERS
119 #define DOLLARS_IN_IDENTIFIERS 2
120
121 /* Allow #sccs (but don't do anything). */
122
123 #define SCCS_DIRECTIVE
124
125 /* We use Dbx symbol format. */
126
127 #define DBX_DEBUGGING_INFO
128
129 /* When generating stabs debugging, use N_BINCL entries. */
130
131 #define DBX_USE_BINCL
132
133 /* There is no limit to the length of stabs strings. */
134
135 #define DBX_CONTIN_LENGTH 0
136
137 /* gdb needs a null N_SO at the end of each file for scattered loading. */
138
139 #undef DBX_OUTPUT_MAIN_SOURCE_FILE_END
140 #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \
141 do { text_section (); \
142 fprintf (FILE, \
143 "\t.stabs \"%s\",%d,0,0,Letext\nLetext:\n", "" , N_SO); \
144 } while (0)
145
146 /* Our profiling scheme doesn't LP labels and counter words. */
147
148 #define NO_PROFILE_COUNTERS
149
150 /* Don't use .gcc_compiled symbols to communicate with GDB;
151 They interfere with numerically sorted symbol lists. */
152
153 #undef ASM_IDENTIFY_GCC
154 #define ASM_IDENTIFY_GCC(asm_out_file)
155
156 #undef INIT_SECTION_ASM_OP
157 #define INIT_SECTION_ASM_OP
158
159 #undef INVOKE__main
160
161 #undef ASM_OUTPUT_CONSTRUCTOR
162 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
163 do { if (flag_pic) \
164 mod_init_section (); \
165 else \
166 constructor_section (); \
167 ASM_OUTPUT_ALIGN (FILE, 1); \
168 fprintf (FILE, "\t.long "); \
169 assemble_name (FILE, NAME); \
170 fprintf (FILE, "\n"); \
171 if (!flag_pic) \
172 fprintf (FILE, ".reference .constructors_used\n"); \
173 } while (0)
174
175 #undef ASM_OUTPUT_DESTRUCTOR
176 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
177 do { if (flag_pic) \
178 mod_term_section (); \
179 else \
180 destructor_section (); \
181 ASM_OUTPUT_ALIGN (FILE, 1); \
182 fprintf (FILE, "\t.long "); \
183 assemble_name (FILE, NAME); \
184 fprintf (FILE, "\n"); \
185 if (!flag_pic) \
186 fprintf (FILE, ".reference .destructors_used\n"); \
187 } while (0)
188
189
190 /* Don't output a .file directive. That is only used by the assembler for
191 error reporting. */
192
193 #undef ASM_FILE_START
194 #define ASM_FILE_START(FILE)
195
196 #undef ASM_FILE_END
197 #define ASM_FILE_END(FILE) \
198 do { \
199 extern const char *language_string; \
200 machopic_finish (asm_out_file); \
201 if (strcmp (language_string, "GNU C++") == 0) \
202 { \
203 constructor_section (); \
204 destructor_section (); \
205 ASM_OUTPUT_ALIGN (FILE, 1); \
206 } \
207 } while (0)
208
209 /* Give ObjcC methods pretty symbol names. */
210
211 #undef OBJC_GEN_METHOD_LABEL
212 #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \
213 do { if (CAT_NAME) \
214 sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+', \
215 (CLASS_NAME), (CAT_NAME), (SEL_NAME)); \
216 else \
217 sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+', \
218 (CLASS_NAME), (SEL_NAME)); \
219 } while (0)
220
221 /* The RTTI data (e.g., __ti4name) is common and public (and static),
222 but it does need to be referenced via indirect PIC data pointers.
223 The machopic_define_name calls are telling the machopic subsystem
224 that the name *is* defined in this module, so it doesn't need to
225 make them indirect. */
226
227 #undef ASM_DECLARE_OBJECT_NAME
228 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
229 do { \
230 char *xname = NAME; \
231 if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
232 xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
233 if ((TREE_STATIC (DECL) \
234 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
235 || DECL_INITIAL (DECL)) \
236 machopic_define_name (xname); \
237 ASM_OUTPUT_LABEL (FILE, xname); \
238 } while (0)
239
240 /* Wrap new method names in quotes so the assembler doesn't gag.
241 Make Objective-C internal symbols local. */
242
243 #undef ASM_OUTPUT_LABELREF
244 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
245 do { \
246 if (NAME[0] == '&') \
247 { \
248 int len = strlen (NAME); \
249 if (len > 6 && !strcmp ("$stub", NAME + len - 5)) \
250 machopic_validate_stub_or_non_lazy_ptr (NAME, 1); \
251 else if (len > 7 && !strcmp ("$stub\"", NAME + len - 6)) \
252 machopic_validate_stub_or_non_lazy_ptr (NAME, 1); \
253 else if (len > 14 && !strcmp ("$non_lazy_ptr", NAME + len - 13)) \
254 machopic_validate_stub_or_non_lazy_ptr (NAME, 0); \
255 fputs (&NAME[1], FILE); \
256 } \
257 else if (NAME[0] == '+' || NAME[0] == '-') \
258 fprintf (FILE, "\"%s\"", NAME); \
259 else if (!strncmp (NAME, "_OBJC_", 6)) \
260 fprintf (FILE, "L%s", NAME); \
261 else if (!strncmp (NAME, ".objc_class_name_", 17)) \
262 fprintf (FILE, "%s", NAME); \
263 else \
264 fprintf (FILE, "_%s", NAME); \
265 } while (0)
266
267 #undef ALIGN_ASM_OP
268 #define ALIGN_ASM_OP ".align"
269
270 #undef ASM_OUTPUT_ALIGN
271 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
272 if ((LOG) != 0) \
273 fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG))
274
275 /* Ensure correct alignment of bss data. */
276
277 #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
278 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
279 do { \
280 fputs (".lcomm ", (FILE)); \
281 assemble_name ((FILE), (NAME)); \
282 fprintf ((FILE), ",%u,%u\n", (SIZE), floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
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)
288
289 /* Output nothing for #ident. */
290
291 #undef ASM_OUTPUT_IDENT
292 #define ASM_OUTPUT_IDENT(FILE, NAME)
293
294 /* The maximum alignment which the object file format can support.
295 For Mach-O, this is 2^15. */
296
297 #undef MAX_OFILE_ALIGNMENT
298 #define MAX_OFILE_ALIGNMENT 0x8000
299
300 /* Create new Mach-O sections. */
301
302 #undef SECTION_FUNCTION
303 #define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, WAS_TEXT, OBJC) \
304 void \
305 FUNCTION () \
306 { \
307 extern void text_section (); \
308 extern void objc_section_init (); \
309 extern int flag_no_mach_text_sections; \
310 \
311 if (WAS_TEXT && flag_no_mach_text_sections) \
312 text_section (); \
313 else if (in_section != SECTION) \
314 { \
315 if (OBJC) \
316 objc_section_init (); \
317 data_section (); \
318 if (asm_out_file) \
319 fprintf (asm_out_file, "%s\n", DIRECTIVE); \
320 in_section = SECTION; \
321 } \
322 } \
323
324 #define ALIAS_SECTION(enum_value, alias_name) \
325 do { if (!strcmp (alias_name, name)) \
326 section_alias[enum_value] = (alias ? get_identifier (alias) : 0); \
327 } while (0)
328
329 /* Darwin uses many types of special sections. */
330
331 #undef EXTRA_SECTIONS
332 #define EXTRA_SECTIONS \
333 in_const, in_const_data, in_cstring, in_literal4, in_literal8, \
334 in_constructor, in_destructor, in_mod_init, in_mod_term, \
335 in_objc_class, in_objc_meta_class, in_objc_category, \
336 in_objc_class_vars, in_objc_instance_vars, \
337 in_objc_cls_meth, in_objc_inst_meth, \
338 in_objc_cat_cls_meth, in_objc_cat_inst_meth, \
339 in_objc_selector_refs, \
340 in_objc_selector_fixup, \
341 in_objc_symbols, in_objc_module_info, \
342 in_objc_protocol, in_objc_string_object, \
343 in_objc_constant_string_object, \
344 in_objc_class_names, in_objc_meth_var_names, \
345 in_objc_meth_var_types, in_objc_cls_refs, \
346 in_machopic_nl_symbol_ptr, \
347 in_machopic_lazy_symbol_ptr, \
348 in_machopic_symbol_stub, \
349 in_machopic_picsymbol_stub, \
350 num_sections
351
352 #undef EXTRA_SECTION_FUNCTIONS
353 #define EXTRA_SECTION_FUNCTIONS \
354 SECTION_FUNCTION (const_section, \
355 in_const, \
356 ".const", 1, 0) \
357 SECTION_FUNCTION (const_data_section, \
358 in_const_data, \
359 ".const_data", 1, 0) \
360 SECTION_FUNCTION (cstring_section, \
361 in_cstring, \
362 ".cstring", 1, 0) \
363 SECTION_FUNCTION (literal4_section, \
364 in_literal4, \
365 ".literal4", 1, 0) \
366 SECTION_FUNCTION (literal8_section, \
367 in_literal8, \
368 ".literal8", 1, 0) \
369 SECTION_FUNCTION (constructor_section, \
370 in_constructor, \
371 ".constructor", 0, 0) \
372 SECTION_FUNCTION (mod_init_section, \
373 in_mod_init, \
374 ".mod_init_func", 0, 0) \
375 SECTION_FUNCTION (mod_term_section, \
376 in_mod_term, \
377 ".mod_term_func", 0, 0) \
378 SECTION_FUNCTION (destructor_section, \
379 in_destructor, \
380 ".destructor", 0, 0) \
381 SECTION_FUNCTION (objc_class_section, \
382 in_objc_class, \
383 ".objc_class", 0, 1) \
384 SECTION_FUNCTION (objc_meta_class_section, \
385 in_objc_meta_class, \
386 ".objc_meta_class", 0, 1) \
387 SECTION_FUNCTION (objc_category_section, \
388 in_objc_category, \
389 ".objc_category", 0, 1) \
390 SECTION_FUNCTION (objc_class_vars_section, \
391 in_objc_class_vars, \
392 ".objc_class_vars", 0, 1) \
393 SECTION_FUNCTION (objc_instance_vars_section, \
394 in_objc_instance_vars, \
395 ".objc_instance_vars", 0, 1) \
396 SECTION_FUNCTION (objc_cls_meth_section, \
397 in_objc_cls_meth, \
398 ".objc_cls_meth", 0, 1) \
399 SECTION_FUNCTION (objc_inst_meth_section, \
400 in_objc_inst_meth, \
401 ".objc_inst_meth", 0, 1) \
402 SECTION_FUNCTION (objc_cat_cls_meth_section, \
403 in_objc_cat_cls_meth, \
404 ".objc_cat_cls_meth", 0, 1) \
405 SECTION_FUNCTION (objc_cat_inst_meth_section, \
406 in_objc_cat_inst_meth, \
407 ".objc_cat_inst_meth", 0, 1) \
408 SECTION_FUNCTION (objc_selector_refs_section, \
409 in_objc_selector_refs, \
410 ".objc_message_refs", 0, 1) \
411 SECTION_FUNCTION (objc_selector_fixup_section, \
412 in_objc_selector_fixup, \
413 ".section __OBJC, __sel_fixup", 0, 1) \
414 SECTION_FUNCTION (objc_symbols_section, \
415 in_objc_symbols, \
416 ".objc_symbols", 0, 1) \
417 SECTION_FUNCTION (objc_module_info_section, \
418 in_objc_module_info, \
419 ".objc_module_info", 0, 1) \
420 SECTION_FUNCTION (objc_protocol_section, \
421 in_objc_protocol, \
422 ".objc_protocol", 0, 1) \
423 SECTION_FUNCTION (objc_string_object_section, \
424 in_objc_string_object, \
425 ".objc_string_object", 0, 1) \
426 SECTION_FUNCTION (objc_constant_string_object_section, \
427 in_objc_constant_string_object, \
428 ".section __OBJC, __cstring_object", 0, 1) \
429 SECTION_FUNCTION (objc_class_names_section, \
430 in_objc_class_names, \
431 ".objc_class_names", 0, 1) \
432 SECTION_FUNCTION (objc_meth_var_names_section, \
433 in_objc_meth_var_names, \
434 ".objc_meth_var_names", 0, 1) \
435 SECTION_FUNCTION (objc_meth_var_types_section, \
436 in_objc_meth_var_types, \
437 ".objc_meth_var_types", 0, 1) \
438 SECTION_FUNCTION (objc_cls_refs_section, \
439 in_objc_cls_refs, \
440 ".objc_cls_refs", 0, 1) \
441 \
442 SECTION_FUNCTION (machopic_lazy_symbol_ptr_section, \
443 in_machopic_lazy_symbol_ptr, \
444 ".lazy_symbol_pointer", 0, 0) \
445 SECTION_FUNCTION (machopic_nl_symbol_ptr_section, \
446 in_machopic_nl_symbol_ptr, \
447 ".non_lazy_symbol_pointer", 0, 0) \
448 SECTION_FUNCTION (machopic_symbol_stub_section, \
449 in_machopic_symbol_stub, \
450 ".symbol_stub", 0, 0) \
451 SECTION_FUNCTION (machopic_picsymbol_stub_section, \
452 in_machopic_picsymbol_stub, \
453 ".picsymbol_stub", 0, 0) \
454 \
455 void \
456 objc_section_init () \
457 { \
458 static int been_here = 0; \
459 \
460 if (been_here == 0) \
461 { \
462 been_here = 1; \
463 /* written, cold -> hot */ \
464 objc_cat_cls_meth_section (); \
465 objc_cat_inst_meth_section (); \
466 objc_string_object_section (); \
467 objc_constant_string_object_section (); \
468 objc_selector_refs_section (); \
469 objc_selector_fixup_section (); \
470 objc_cls_refs_section (); \
471 objc_class_section (); \
472 objc_meta_class_section (); \
473 /* shared, hot -> cold */ \
474 objc_cls_meth_section (); \
475 objc_inst_meth_section (); \
476 objc_protocol_section (); \
477 objc_class_names_section (); \
478 objc_meth_var_types_section (); \
479 objc_meth_var_names_section (); \
480 objc_category_section (); \
481 objc_class_vars_section (); \
482 objc_instance_vars_section (); \
483 objc_module_info_section (); \
484 objc_symbols_section (); \
485 } \
486 } \
487 static tree section_alias[(int) num_sections]; \
488 void try_section_alias () \
489 { \
490 if (section_alias[in_section] && asm_out_file) \
491 fprintf (asm_out_file, "%s\n", \
492 IDENTIFIER_POINTER (section_alias[in_section])); \
493 } \
494 void alias_section (name, alias) \
495 char *name, *alias; \
496 { \
497 ALIAS_SECTION (in_data, "data"); \
498 ALIAS_SECTION (in_text, "text"); \
499 ALIAS_SECTION (in_const, "const"); \
500 ALIAS_SECTION (in_const_data, "const_data"); \
501 ALIAS_SECTION (in_cstring, "cstring"); \
502 ALIAS_SECTION (in_literal4, "literal4"); \
503 ALIAS_SECTION (in_literal8, "literal8"); \
504 }
505
506 #undef READONLY_DATA_SECTION
507 #define READONLY_DATA_SECTION const_section
508
509 #undef SELECT_SECTION
510 #define SELECT_SECTION(exp,reloc) \
511 do \
512 { \
513 if (TREE_CODE (exp) == STRING_CST) \
514 { \
515 if (flag_writable_strings) \
516 data_section (); \
517 else if (TREE_STRING_LENGTH (exp) != \
518 strlen (TREE_STRING_POINTER (exp)) + 1) \
519 readonly_data_section (); \
520 else \
521 cstring_section (); \
522 } \
523 else if (TREE_CODE (exp) == INTEGER_CST \
524 || TREE_CODE (exp) == REAL_CST) \
525 { \
526 tree size = TYPE_SIZE (TREE_TYPE (exp)); \
527 \
528 if (TREE_CODE (size) == INTEGER_CST && \
529 TREE_INT_CST_LOW (size) == 4 && \
530 TREE_INT_CST_HIGH (size) == 0) \
531 literal4_section (); \
532 else if (TREE_CODE (size) == INTEGER_CST && \
533 TREE_INT_CST_LOW (size) == 8 && \
534 TREE_INT_CST_HIGH (size) == 0) \
535 literal8_section (); \
536 else \
537 readonly_data_section (); \
538 } \
539 else if (TREE_CODE (exp) == CONSTRUCTOR \
540 && TREE_TYPE (exp) \
541 && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE \
542 && TYPE_NAME (TREE_TYPE (exp))) \
543 { \
544 tree name = TYPE_NAME (TREE_TYPE (exp)); \
545 if (TREE_CODE (name) == TYPE_DECL) \
546 name = DECL_NAME (name); \
547 if (!strcmp (IDENTIFIER_POINTER (name), "NSConstantString")) \
548 objc_constant_string_object_section (); \
549 else if (!strcmp (IDENTIFIER_POINTER (name), "NXConstantString")) \
550 objc_string_object_section (); \
551 else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
552 { \
553 if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc) \
554 const_data_section (); \
555 else \
556 readonly_data_section (); \
557 } \
558 else \
559 data_section (); \
560 } \
561 else if (TREE_CODE (exp) == VAR_DECL && \
562 DECL_NAME (exp) && \
563 TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE && \
564 IDENTIFIER_POINTER (DECL_NAME (exp)) && \
565 !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \
566 { \
567 const char *name = IDENTIFIER_POINTER (DECL_NAME (exp)); \
568 \
569 if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20)) \
570 objc_cls_meth_section (); \
571 else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23)) \
572 objc_inst_meth_section (); \
573 else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \
574 objc_cat_cls_meth_section (); \
575 else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \
576 objc_cat_inst_meth_section (); \
577 else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22)) \
578 objc_class_vars_section (); \
579 else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25)) \
580 objc_instance_vars_section (); \
581 else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22)) \
582 objc_cat_cls_meth_section (); \
583 else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17)) \
584 objc_class_names_section (); \
585 else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20)) \
586 objc_meth_var_names_section (); \
587 else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20)) \
588 objc_meth_var_types_section (); \
589 else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22)) \
590 objc_cls_refs_section (); \
591 else if (!strncmp (name, "_OBJC_CLASS_", 12)) \
592 objc_class_section (); \
593 else if (!strncmp (name, "_OBJC_METACLASS_", 16)) \
594 objc_meta_class_section (); \
595 else if (!strncmp (name, "_OBJC_CATEGORY_", 15)) \
596 objc_category_section (); \
597 else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25)) \
598 objc_selector_refs_section (); \
599 else if (!strncmp (name, "_OBJC_SELECTOR_FIXUP", 20)) \
600 objc_selector_fixup_section (); \
601 else if (!strncmp (name, "_OBJC_SYMBOLS", 13)) \
602 objc_symbols_section (); \
603 else if (!strncmp (name, "_OBJC_MODULES", 13)) \
604 objc_module_info_section (); \
605 else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) \
606 objc_cat_inst_meth_section (); \
607 else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) \
608 objc_cat_cls_meth_section (); \
609 else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20)) \
610 objc_cat_cls_meth_section (); \
611 else if (!strncmp (name, "_OBJC_PROTOCOL_", 15)) \
612 objc_protocol_section (); \
613 else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
614 && !TREE_SIDE_EFFECTS (exp)) \
615 { if (flag_pic && reloc ) const_data_section (); \
616 else readonly_data_section (); } \
617 else \
618 data_section (); \
619 } \
620 else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
621 { \
622 if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc) \
623 const_data_section (); \
624 else \
625 readonly_data_section (); \
626 } \
627 else \
628 data_section (); \
629 try_section_alias (); \
630 } \
631 while (0)
632
633 #undef SELECT_RTX_SECTION
634 #define SELECT_RTX_SECTION(mode, rtx) \
635 do \
636 { \
637 if (GET_MODE_SIZE (mode) == 8) \
638 literal8_section (); \
639 else if (GET_MODE_SIZE (mode) == 4) \
640 literal4_section (); \
641 else \
642 const_section (); \
643 } \
644 while (0)
645
646 #define DECLARE_UNRESOLVED_REFERENCE(NAME) \
647 do { extern FILE* asm_out_file; \
648 if (asm_out_file) { \
649 if (flag_pic) \
650 fprintf (asm_out_file, "\t.lazy_reference "); \
651 else \
652 fprintf (asm_out_file, "\t.reference "); \
653 assemble_name (asm_out_file, NAME); \
654 fprintf (asm_out_file, "\n"); \
655 } \
656 } while (0)
657
658 #define DECLARE_CLASS_REFERENCE(NAME) \
659 do { extern FILE* asm_out_file; \
660 if (asm_out_file) { \
661 fprintf (asm_out_file, "\t"); \
662 assemble_name (asm_out_file, NAME); \
663 fprintf (asm_out_file, "=0\n"); \
664 assemble_global (NAME); \
665 } \
666 } while (0)
667
668 #undef ASM_GLOBALIZE_LABEL
669 #define ASM_GLOBALIZE_LABEL(FILE,NAME) \
670 do { const char* _x = (NAME); if (!!strncmp (_x, "_OBJC_", 6)) { \
671 (fputs (".globl ", FILE), assemble_name (FILE, _x), fputs ("\n", FILE)); \
672 }} while (0)
673
674 #undef ASM_GENERATE_INTERNAL_LABEL
675 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
676 sprintf (LABEL, "*%s%d", PREFIX, NUM)
677
678 /* This is how to output an internal numbered label where PREFIX is
679 the class of label and NUM is the number within the class. */
680
681 #undef ASM_OUTPUT_INTERNAL_LABEL
682 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
683 fprintf (FILE, "%s%d:\n", PREFIX, NUM)
684
685 /* Since we have a separate readonly data section, define this so that
686 jump tables end up in text rather than data. */
687
688 #ifndef JUMP_TABLES_IN_TEXT_SECTION
689 #define JUMP_TABLES_IN_TEXT_SECTION 1
690 #endif
691
692 /* Symbolic names for various things we might know about a symbol. */
693
694 enum machopic_addr_class {
695 MACHOPIC_UNDEFINED,
696 MACHOPIC_DEFINED_DATA,
697 MACHOPIC_UNDEFINED_DATA,
698 MACHOPIC_DEFINED_FUNCTION,
699 MACHOPIC_UNDEFINED_FUNCTION
700 };
701
702 /* Macros defining the various PIC cases. */
703
704 #define MACHOPIC_INDIRECT (flag_pic)
705 #define MACHOPIC_JUST_INDIRECT (flag_pic == 1)
706 #define MACHOPIC_PURE (flag_pic == 2)
707
708 #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH) \
709 do { \
710 const char *stub_ = (STUB); \
711 char *buffer_ = (BUF); \
712 strcpy (buffer_, stub_); \
713 if (stub_[0] == '"') \
714 { \
715 strcpy (buffer_ + (STUB_LENGTH) - 1, "_binder\""); \
716 } \
717 else \
718 { \
719 strcpy (buffer_ + (STUB_LENGTH), "_binder"); \
720 } \
721 } while (0)
722
723 #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
724 do { \
725 const char *symbol_ = (SYMBOL); \
726 char *buffer_ = (BUF); \
727 if (name_needs_quotes (symbol_) && symbol_[0] != '"') \
728 { \
729 sprintf (buffer_, "\"%s\"", symbol_); \
730 } \
731 else \
732 { \
733 strcpy (buffer_, symbol_); \
734 } \
735 } while (0)
736
737 /* Given a symbol name string, create the lazy pointer version
738 of the symbol name. */
739
740 #define GEN_LAZY_PTR_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \
741 do { \
742 const char *symbol_ = (SYMBOL); \
743 char *buffer_ = (BUF); \
744 if (symbol_[0] == '"') \
745 { \
746 strcpy (buffer_, "\"L"); \
747 strcpy (buffer_ + 2, symbol_ + 1); \
748 strcpy (buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\""); \
749 } \
750 else if (name_needs_quotes (symbol_)) \
751 { \
752 strcpy (buffer_, "\"L"); \
753 strcpy (buffer_ + 2, symbol_); \
754 strcpy (buffer_ + (SYMBOL_LENGTH) + 2, "$lazy_ptr\""); \
755 } \
756 else \
757 { \
758 strcpy (buffer_, "L"); \
759 strcpy (buffer_ + 1, symbol_); \
760 strcpy (buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr"); \
761 } \
762 } while (0)
763