]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/gcc/config/darwin.h
This commit was generated by cvs2svn to compensate for changes in r98121,
[FreeBSD/FreeBSD.git] / contrib / gcc / config / darwin.h
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.
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 /* 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.  */
37
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.)  */
41
42 #define MATH_LIBRARY ""
43
44 /* We have atexit.  */
45
46 #define HAVE_ATEXIT
47
48 /* Define an empty body for the function do_global_dtors() in libgcc2.c.  */
49
50 #define DO_GLOBAL_DTORS_BODY
51
52 /* The string value for __SIZE_TYPE__.  */
53
54 #ifndef SIZE_TYPE
55 #define SIZE_TYPE "long unsigned int"
56 #endif
57
58 /* Type used for ptrdiff_t, as a string used in a declaration.  */
59
60 #undef  PTRDIFF_TYPE
61 #define PTRDIFF_TYPE "int"
62
63 /* wchar_t is int.  */
64
65 #undef  WCHAR_TYPE
66 #define WCHAR_TYPE "int"
67 #undef  WCHAR_TYPE_SIZE
68 #define WCHAR_TYPE_SIZE 32
69
70 /* Default to using the NeXT-style runtime, since that's what is
71    pre-installed on Darwin systems.  */
72
73 #define NEXT_OBJC_RUNTIME
74
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.  */
77
78 #undef  DEFAULT_PCC_STRUCT_RETURN
79 #define DEFAULT_PCC_STRUCT_RETURN 0
80
81 /* Don't warn about MacOS-style 'APPL' four-char-constants.  */
82
83 #undef WARN_FOUR_CHAR_CONSTANTS
84 #define WARN_FOUR_CHAR_CONSTANTS 0
85
86 /* Machine dependent cpp options.  */
87
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.  */
91
92 #ifndef APPLE_CC
93 #define APPLE_CC 999
94 #endif
95
96 #define STRINGIFY_THIS(x) # x
97 #define REALLY_STRINGIFY(x) STRINGIFY_THIS(x)
98
99 #undef  CPP_SPEC
100 #define CPP_SPEC "-D__APPLE_CC__=" REALLY_STRINGIFY(APPLE_CC) " \
101                   %{static:-D__STATIC__}%{!static:-D__DYNAMIC__}"
102
103 /* Machine dependent libraries.  */
104
105 #undef  LIB_SPEC
106 #define LIB_SPEC "%{!static:-lSystem}"
107
108 /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
109
110 #undef  STARTFILE_SPEC
111 #define STARTFILE_SPEC  \
112   "%{pg:%{static:-lgcrt0.o}%{!static:-lgcrt1.o}} \
113     %{!pg:%{static:-lcrt0.o}%{!static:-lcrt1.o}}"
114
115 #undef  DOLLARS_IN_IDENTIFIERS
116 #define DOLLARS_IN_IDENTIFIERS 2
117
118 /* Allow #sccs (but don't do anything). */
119
120 #define SCCS_DIRECTIVE
121
122 /* We use Dbx symbol format.  */
123
124 #define DBX_DEBUGGING_INFO
125
126 /* Also enable Dwarf 2 as an option.  */
127
128 #define DWARF2_DEBUGGING_INFO
129
130 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
131
132 /* When generating stabs debugging, use N_BINCL entries.  */
133
134 #define DBX_USE_BINCL
135
136 /* There is no limit to the length of stabs strings.  */
137
138 #define DBX_CONTIN_LENGTH 0
139
140 /* gdb needs a null N_SO at the end of each file for scattered loading. */
141
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)
148
149 /* Our profiling scheme doesn't LP labels and counter words.  */
150
151 #define NO_PROFILE_COUNTERS
152
153 #undef  INIT_SECTION_ASM_OP
154 #define INIT_SECTION_ASM_OP
155
156 #undef  INVOKE__main
157
158 #define TARGET_ASM_CONSTRUCTOR  machopic_asm_out_constructor
159 #define TARGET_ASM_DESTRUCTOR   machopic_asm_out_destructor
160
161
162 /* Don't output a .file directive.  That is only used by the assembler for
163    error reporting.  */
164
165 #undef  ASM_FILE_START
166 #define ASM_FILE_START(FILE)
167
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)               \
173       {                                                         \
174         constructor_section ();                                 \
175         destructor_section ();                                  \
176         ASM_OUTPUT_ALIGN (FILE, 1);                             \
177       }                                                         \
178   } while (0)
179
180 /* Give ObjcC methods pretty symbol names. */
181
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)
191
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.  */
197
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);  \
212     ASM_OUTPUT_LABEL (FILE, xname);                                     \
213   } while (0)
214
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);                                       \
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)
233
234 /* Wrap new method names in quotes so the assembler doesn't gag.
235    Make Objective-C internal symbols local.  */
236
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] == '*')                            \
242          {                                                              \
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); \
251          } \
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)
261
262 #undef  ALIGN_ASM_OP
263 #define ALIGN_ASM_OP            ".align"
264
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))
269
270 /* Ensure correct alignment of bss data.  */
271
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), floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
278     if ((DECL) && ((TREE_STATIC (DECL)                                             \
279          && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
280         || DECL_INITIAL (DECL)))                                         \
281       ENCODE_SECTION_INFO (DECL);  \
282     if ((DECL) && ((TREE_STATIC (DECL)                                             \
283          && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
284         || DECL_INITIAL (DECL)))                                         \
285       machopic_define_name (NAME);                                     \
286   } while (0)
287
288 /* Output nothing for #ident.  */
289
290 #undef  ASM_OUTPUT_IDENT
291 #define ASM_OUTPUT_IDENT(FILE, NAME)
292
293 /* The maximum alignment which the object file format can support.
294    For Mach-O, this is 2^15.  */
295
296 #undef  MAX_OFILE_ALIGNMENT
297 #define MAX_OFILE_ALIGNMENT 0x8000
298
299 /* Create new Mach-O sections. */
300
301 #undef  SECTION_FUNCTION
302 #define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, OBJC)            \
303 extern void FUNCTION PARAMS ((void));                                   \
304 void                                                                    \
305 FUNCTION ()                                                             \
306 {                                                                       \
307   if (in_section != SECTION)                                            \
308     {                                                                   \
309       if (OBJC)                                                         \
310         objc_section_init ();                                           \
311       data_section ();                                                  \
312       if (asm_out_file)                                                 \
313         fprintf (asm_out_file, "%s\n", DIRECTIVE);                      \
314       in_section = SECTION;                                             \
315     }                                                                   \
316 }                                                                       \
317
318 #define ALIAS_SECTION(enum_value, alias_name)                           \
319 do { if (!strcmp (alias_name, name))                                    \
320        section_alias[enum_value] = (alias ? get_identifier (alias) : 0);  \
321    } while (0)
322
323 /* Darwin uses many types of special sections.  */
324
325 #undef  EXTRA_SECTIONS
326 #define EXTRA_SECTIONS                                  \
327   in_const, in_const_data, in_cstring, in_literal4, in_literal8,        \
328   in_constructor, in_destructor, in_mod_init, in_mod_term,              \
329   in_objc_class, in_objc_meta_class, in_objc_category,  \
330   in_objc_class_vars, in_objc_instance_vars,            \
331   in_objc_cls_meth, in_objc_inst_meth,                  \
332   in_objc_cat_cls_meth, in_objc_cat_inst_meth,          \
333   in_objc_selector_refs,                                \
334   in_objc_selector_fixup,                               \
335   in_objc_symbols, in_objc_module_info,                 \
336   in_objc_protocol, in_objc_string_object,              \
337   in_objc_constant_string_object,                       \
338   in_objc_class_names, in_objc_meth_var_names,          \
339   in_objc_meth_var_types, in_objc_cls_refs,             \
340   in_machopic_nl_symbol_ptr,                            \
341   in_machopic_lazy_symbol_ptr,                          \
342   in_machopic_symbol_stub,                              \
343   in_machopic_picsymbol_stub,                           \
344   in_darwin_exception, in_darwin_eh_frame,              \
345   num_sections
346
347 #undef  EXTRA_SECTION_FUNCTIONS
348 #define EXTRA_SECTION_FUNCTIONS                 \
349 static void objc_section_init PARAMS ((void));  \
350 SECTION_FUNCTION (const_section,                \
351                   in_const,                     \
352                   ".const", 0)                  \
353 SECTION_FUNCTION (const_data_section,           \
354                   in_const_data,                \
355                   ".const_data", 0)             \
356 SECTION_FUNCTION (cstring_section,              \
357                   in_cstring,                   \
358                   ".cstring", 0)                \
359 SECTION_FUNCTION (literal4_section,             \
360                   in_literal4,                  \
361                   ".literal4", 0)               \
362 SECTION_FUNCTION (literal8_section,             \
363                   in_literal8,                  \
364                   ".literal8", 0)               \
365 SECTION_FUNCTION (constructor_section,          \
366                   in_constructor,               \
367                   ".constructor", 0)            \
368 SECTION_FUNCTION (mod_init_section,             \
369                   in_mod_init,                  \
370                   ".mod_init_func", 0)  \
371 SECTION_FUNCTION (mod_term_section, \
372                   in_mod_term,                  \
373                   ".mod_term_func", 0)  \
374 SECTION_FUNCTION (destructor_section,           \
375                   in_destructor,                \
376                   ".destructor", 0)             \
377 SECTION_FUNCTION (objc_class_section,           \
378                   in_objc_class,                \
379                   ".objc_class", 1)             \
380 SECTION_FUNCTION (objc_meta_class_section,      \
381                   in_objc_meta_class,           \
382                   ".objc_meta_class", 1)        \
383 SECTION_FUNCTION (objc_category_section,        \
384                   in_objc_category,             \
385                 ".objc_category", 1)            \
386 SECTION_FUNCTION (objc_class_vars_section,      \
387                   in_objc_class_vars,           \
388                   ".objc_class_vars", 1)        \
389 SECTION_FUNCTION (objc_instance_vars_section,   \
390                   in_objc_instance_vars,        \
391                   ".objc_instance_vars", 1)     \
392 SECTION_FUNCTION (objc_cls_meth_section,        \
393                   in_objc_cls_meth,             \
394                   ".objc_cls_meth", 1)  \
395 SECTION_FUNCTION (objc_inst_meth_section,       \
396                   in_objc_inst_meth,            \
397                   ".objc_inst_meth", 1) \
398 SECTION_FUNCTION (objc_cat_cls_meth_section,    \
399                   in_objc_cat_cls_meth,         \
400                   ".objc_cat_cls_meth", 1)      \
401 SECTION_FUNCTION (objc_cat_inst_meth_section,   \
402                   in_objc_cat_inst_meth,        \
403                   ".objc_cat_inst_meth", 1)     \
404 SECTION_FUNCTION (objc_selector_refs_section,   \
405                   in_objc_selector_refs,        \
406                   ".objc_message_refs", 1)      \
407 SECTION_FUNCTION (objc_selector_fixup_section,  \
408                   in_objc_selector_fixup,       \
409                   ".section __OBJC, __sel_fixup", 1)    \
410 SECTION_FUNCTION (objc_symbols_section,         \
411                   in_objc_symbols,              \
412                   ".objc_symbols", 1)   \
413 SECTION_FUNCTION (objc_module_info_section,     \
414                   in_objc_module_info,          \
415                   ".objc_module_info", 1)       \
416 SECTION_FUNCTION (objc_protocol_section,        \
417                   in_objc_protocol,             \
418                   ".objc_protocol", 1)  \
419 SECTION_FUNCTION (objc_string_object_section,   \
420                   in_objc_string_object,        \
421                   ".objc_string_object", 1)     \
422 SECTION_FUNCTION (objc_constant_string_object_section,  \
423                   in_objc_constant_string_object,       \
424                   ".section __OBJC, __cstring_object", 1)       \
425 SECTION_FUNCTION (objc_class_names_section,     \
426                 in_objc_class_names,            \
427                 ".objc_class_names", 1) \
428 SECTION_FUNCTION (objc_meth_var_names_section,  \
429                 in_objc_meth_var_names,         \
430                 ".objc_meth_var_names", 1)      \
431 SECTION_FUNCTION (objc_meth_var_types_section,  \
432                 in_objc_meth_var_types,         \
433                 ".objc_meth_var_types", 1)      \
434 SECTION_FUNCTION (objc_cls_refs_section,        \
435                 in_objc_cls_refs,               \
436                 ".objc_cls_refs", 1)            \
437                                                 \
438 SECTION_FUNCTION (machopic_lazy_symbol_ptr_section,     \
439                 in_machopic_lazy_symbol_ptr,            \
440                 ".lazy_symbol_pointer", 0)              \
441 SECTION_FUNCTION (machopic_nl_symbol_ptr_section,       \
442                 in_machopic_nl_symbol_ptr,              \
443                 ".non_lazy_symbol_pointer", 0)          \
444 SECTION_FUNCTION (machopic_symbol_stub_section,         \
445                 in_machopic_symbol_stub,                \
446                 ".symbol_stub", 0)                      \
447 SECTION_FUNCTION (machopic_picsymbol_stub_section,      \
448                 in_machopic_picsymbol_stub,             \
449                 ".picsymbol_stub", 0)                   \
450 SECTION_FUNCTION (darwin_exception_section,             \
451                 in_darwin_exception,                    \
452                 ".section __TEXT,__gcc_except_tab", 0)  \
453 SECTION_FUNCTION (darwin_eh_frame_section,              \
454                 in_darwin_eh_frame,                     \
455                 ".section __TEXT,__eh_frame", 0)        \
456                                                         \
457 static void                                     \
458 objc_section_init ()                            \
459 {                                               \
460   static int been_here = 0;                     \
461                                                 \
462   if (been_here == 0)                           \
463     {                                           \
464       been_here = 1;                            \
465           /* written, cold -> hot */            \
466       objc_cat_cls_meth_section ();             \
467       objc_cat_inst_meth_section ();            \
468       objc_string_object_section ();            \
469       objc_constant_string_object_section ();   \
470       objc_selector_refs_section ();            \
471       objc_selector_fixup_section ();           \
472       objc_cls_refs_section ();                 \
473       objc_class_section ();                    \
474       objc_meta_class_section ();               \
475           /* shared, hot -> cold */             \
476       objc_cls_meth_section ();                 \
477       objc_inst_meth_section ();                \
478       objc_protocol_section ();                 \
479       objc_class_names_section ();              \
480       objc_meth_var_types_section ();           \
481       objc_meth_var_names_section ();           \
482       objc_category_section ();                 \
483       objc_class_vars_section ();               \
484       objc_instance_vars_section ();            \
485       objc_module_info_section ();              \
486       objc_symbols_section ();                  \
487     }                                           \
488 }                                               \
489 static tree section_alias[(int) num_sections];  \
490 static void try_section_alias PARAMS ((void));  \
491 static void try_section_alias ()                \
492 {                                               \
493     if (section_alias[in_section] && asm_out_file) \
494       fprintf (asm_out_file, "%s\n",            \
495                IDENTIFIER_POINTER (section_alias[in_section])); \
496 }                                               \
497
498 #if 0
499 static void alias_section PARAMS ((const char *, const char *)); \
500 static void alias_section (name, alias)                 \
501      const char *name, *alias;                          \
502 {                                                       \
503     ALIAS_SECTION (in_data, "data");                    \
504     ALIAS_SECTION (in_text, "text");                    \
505     ALIAS_SECTION (in_const, "const");                  \
506     ALIAS_SECTION (in_const_data, "const_data");        \
507     ALIAS_SECTION (in_cstring, "cstring");              \
508     ALIAS_SECTION (in_literal4, "literal4");            \
509     ALIAS_SECTION (in_literal8, "literal8");            \
510 }
511 #endif
512
513 #undef  READONLY_DATA_SECTION
514 #define READONLY_DATA_SECTION const_section
515
516 #undef  SELECT_SECTION
517 #define SELECT_SECTION(exp,reloc,align)                         \
518   do                                                            \
519     {                                                           \
520       if (TREE_CODE (exp) == STRING_CST)                        \
521         {                                                       \
522           if (flag_writable_strings)                            \
523             data_section ();                                    \
524           else if (TREE_STRING_LENGTH (exp) !=                  \
525                    strlen (TREE_STRING_POINTER (exp)) + 1)      \
526             readonly_data_section ();                           \
527           else                                                  \
528             cstring_section ();                                 \
529         }                                                       \
530       else if (TREE_CODE (exp) == INTEGER_CST                   \
531                || TREE_CODE (exp) == REAL_CST)                  \
532         {                                                       \
533           tree size = TYPE_SIZE (TREE_TYPE (exp));              \
534                                                                 \
535           if (TREE_CODE (size) == INTEGER_CST &&                \
536               TREE_INT_CST_LOW (size) == 4 &&                   \
537               TREE_INT_CST_HIGH (size) == 0)                    \
538             literal4_section ();                                \
539           else if (TREE_CODE (size) == INTEGER_CST &&           \
540               TREE_INT_CST_LOW (size) == 8 &&                   \
541               TREE_INT_CST_HIGH (size) == 0)                    \
542             literal8_section ();                                \
543           else                                                  \
544             readonly_data_section ();                           \
545         }                                                       \
546       else if (TREE_CODE (exp) == CONSTRUCTOR                           \
547                && TREE_TYPE (exp)                                       \
548                && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE            \
549                && TYPE_NAME (TREE_TYPE (exp)))                          \
550         {                                                               \
551           tree name = TYPE_NAME (TREE_TYPE (exp));                      \
552           if (TREE_CODE (name) == TYPE_DECL)                            \
553             name = DECL_NAME (name);                                    \
554           if (!strcmp (IDENTIFIER_POINTER (name), "NSConstantString"))  \
555             objc_constant_string_object_section ();                     \
556           else if (!strcmp (IDENTIFIER_POINTER (name), "NXConstantString")) \
557             objc_string_object_section ();                              \
558           else if (TREE_READONLY (exp) || TREE_CONSTANT (exp))          \
559             {                                                           \
560               if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc)         \
561                 const_data_section ();                                  \
562               else                                                      \
563                 readonly_data_section ();                               \
564             }                                                           \
565           else                                                          \
566             data_section ();                                            \
567       }                                                                 \
568       else if (TREE_CODE (exp) == VAR_DECL &&                           \
569                DECL_NAME (exp) &&                                       \
570                TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE &&        \
571                IDENTIFIER_POINTER (DECL_NAME (exp)) &&                  \
572                !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \
573         {                                                               \
574           const char *name = IDENTIFIER_POINTER (DECL_NAME (exp));      \
575                                                                         \
576           if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20))              \
577             objc_cls_meth_section ();                                   \
578           else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23))      \
579             objc_inst_meth_section ();                                  \
580           else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \
581             objc_cat_cls_meth_section ();                               \
582           else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \
583             objc_cat_inst_meth_section ();                              \
584           else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22))       \
585             objc_class_vars_section ();                                 \
586           else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25))    \
587             objc_instance_vars_section ();                              \
588           else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22))       \
589             objc_cat_cls_meth_section ();                               \
590           else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17))            \
591             objc_class_names_section ();                                \
592           else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20))         \
593             objc_meth_var_names_section ();                             \
594           else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20))         \
595             objc_meth_var_types_section ();                             \
596           else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22))       \
597             objc_cls_refs_section ();                                   \
598           else if (!strncmp (name, "_OBJC_CLASS_", 12))                 \
599             objc_class_section ();                                      \
600           else if (!strncmp (name, "_OBJC_METACLASS_", 16))             \
601             objc_meta_class_section ();                                 \
602           else if (!strncmp (name, "_OBJC_CATEGORY_", 15))              \
603             objc_category_section ();                                   \
604           else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25))    \
605             objc_selector_refs_section ();                              \
606           else if (!strncmp (name, "_OBJC_SELECTOR_FIXUP", 20))         \
607             objc_selector_fixup_section ();                             \
608           else if (!strncmp (name, "_OBJC_SYMBOLS", 13))                \
609             objc_symbols_section ();                                    \
610           else if (!strncmp (name, "_OBJC_MODULES", 13))                \
611             objc_module_info_section ();                                \
612           else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) \
613             objc_cat_inst_meth_section ();                              \
614           else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) \
615             objc_cat_cls_meth_section ();                               \
616           else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20))         \
617             objc_cat_cls_meth_section ();                               \
618           else if (!strncmp (name, "_OBJC_PROTOCOL_", 15))              \
619             objc_protocol_section ();                                   \
620           else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))         \
621                 && !TREE_SIDE_EFFECTS (exp))                            \
622              { if (flag_pic && reloc ) const_data_section ();             \
623                else readonly_data_section (); }                         \
624           else                                                          \
625             data_section ();                                            \
626         }                                                               \
627       else if (TREE_READONLY (exp) || TREE_CONSTANT (exp))              \
628         {                                                               \
629           if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc)             \
630             const_data_section ();                                      \
631           else                                                          \
632             readonly_data_section ();                                   \
633         }                                                               \
634       else                                                              \
635         data_section ();                                                \
636       try_section_alias ();                                             \
637     }                                                                   \
638   while (0)
639
640 /* This can be called with address expressions as "rtx".
641    They must go in "const". */
642 #undef  SELECT_RTX_SECTION
643 #define SELECT_RTX_SECTION(mode, rtx, align)                            \
644   do                                                                    \
645     {                                                                   \
646       if (GET_MODE_SIZE (mode) == 8)                                    \
647         literal8_section ();                                            \
648       else if (GET_MODE_SIZE (mode) == 4                                \
649                && (GET_CODE (rtx) == CONST_INT                          \
650                    || GET_CODE (rtx) == CONST_DOUBLE))                  \
651         literal4_section ();                                            \
652       else                                                              \
653         const_section ();                                               \
654     }                                                                   \
655   while (0)
656
657 #define ASM_DECLARE_UNRESOLVED_REFERENCE(FILE,NAME)                     \
658     do {                                                                \
659          if (FILE) {                                                    \
660            if (flag_pic)                                                \
661              fprintf (FILE, "\t.lazy_reference ");                      \
662            else                                                         \
663              fprintf (FILE, "\t.reference ");                           \
664            assemble_name (FILE, NAME);                                  \
665            fprintf (FILE, "\n");                                        \
666          }                                                              \
667        } while (0)
668
669 #define ASM_DECLARE_CLASS_REFERENCE(FILE,NAME)                          \
670     do {                                                                \
671          if (FILE) {                                                    \
672            fprintf (FILE, "\t");                                        \
673            assemble_name (FILE, NAME);                                  \
674            fprintf (FILE, "=0\n");                                      \
675            assemble_global (NAME);                                      \
676          }                                                              \
677        } while (0)
678
679 #undef ASM_GLOBALIZE_LABEL
680 #define ASM_GLOBALIZE_LABEL(FILE,NAME)  \
681  do { const char *const _x = (NAME); if (!!strncmp (_x, "_OBJC_", 6)) { \
682   (fputs (".globl ", FILE), assemble_name (FILE, _x), fputs ("\n", FILE)); \
683  }} while (0)
684
685 #undef ASM_GENERATE_INTERNAL_LABEL
686 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
687   sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM))
688
689 /* This is how to output an internal numbered label where PREFIX is
690    the class of label and NUM is the number within the class.  */
691
692 #undef ASM_OUTPUT_INTERNAL_LABEL
693 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)      \
694   fprintf (FILE, "%s%d:\n", PREFIX, NUM)
695
696 /* Since we have a separate readonly data section, define this so that
697    jump tables end up in text rather than data.  */
698
699 #ifndef JUMP_TABLES_IN_TEXT_SECTION
700 #define JUMP_TABLES_IN_TEXT_SECTION 1
701 #endif
702
703 /* Symbolic names for various things we might know about a symbol.  */
704
705 enum machopic_addr_class {
706   MACHOPIC_UNDEFINED,
707   MACHOPIC_DEFINED_DATA,
708   MACHOPIC_UNDEFINED_DATA,
709   MACHOPIC_DEFINED_FUNCTION,
710   MACHOPIC_UNDEFINED_FUNCTION
711 };
712
713 /* Macros defining the various PIC cases.  */
714
715 #define MACHOPIC_INDIRECT      (flag_pic)
716 #define MACHOPIC_JUST_INDIRECT (flag_pic == 1)
717 #define MACHOPIC_PURE          (flag_pic == 2)
718
719 #define ENCODE_SECTION_INFO(DECL)  \
720   darwin_encode_section_info (DECL)
721
722 /* Be conservative and always redo the encoding.  */
723
724 #define REDO_SECTION_INFO_P(DECL) (1)
725
726 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME)  \
727   ((VAR) = ((SYMBOL_NAME[0] == '!') ? (SYMBOL_NAME) + 4 : (SYMBOL_NAME)))
728
729 #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH)          \
730   do {                                                          \
731     const char *const stub_ = (STUB);                           \
732     char *buffer_ = (BUF);                                      \
733     strcpy (buffer_, stub_);                                    \
734     if (stub_[0] == '"')                                        \
735       {                                                         \
736         strcpy (buffer_ + (STUB_LENGTH) - 1, "_binder\"");      \
737       }                                                         \
738     else                                                        \
739       {                                                         \
740         strcpy (buffer_ + (STUB_LENGTH), "_binder");            \
741       }                                                         \
742   } while (0)
743
744 #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH)    \
745   do {                                                          \
746     const char *const symbol_ = (SYMBOL);                       \
747     char *buffer_ = (BUF);                                      \
748     if (name_needs_quotes (symbol_) && symbol_[0] != '"')       \
749       {                                                         \
750           sprintf (buffer_, "\"%s\"", symbol_);                 \
751       }                                                         \
752     else                                                        \
753       {                                                         \
754         strcpy (buffer_, symbol_);                              \
755       }                                                         \
756   } while (0)
757
758 /* Given a symbol name string, create the lazy pointer version
759    of the symbol name.  */
760
761 #define GEN_LAZY_PTR_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH)  \
762   do {                                                          \
763     const char *symbol_ = (SYMBOL);                             \
764     char *buffer_ = (BUF);                                      \
765     STRIP_NAME_ENCODING (symbol_, symbol_);  \
766     if (symbol_[0] == '"')                                      \
767       {                                                         \
768         strcpy (buffer_, "\"L");                                        \
769         strcpy (buffer_ + 2, symbol_ + 1);                      \
770         strcpy (buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\"");      \
771       }                                                         \
772     else if (name_needs_quotes (symbol_))                       \
773       {                                                         \
774         strcpy (buffer_, "\"L");                                \
775         strcpy (buffer_ + 2, symbol_);                          \
776         strcpy (buffer_ + (SYMBOL_LENGTH) + 2, "$lazy_ptr\"");  \
777       }                                                         \
778     else                                                        \
779       {                                                         \
780         strcpy (buffer_, "L");                                  \
781         strcpy (buffer_ + 1, symbol_);                          \
782         strcpy (buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr");    \
783       }                                                         \
784   } while (0)
785
786 #define TARGET_ASM_EXCEPTION_SECTION darwin_exception_section
787
788 #define TARGET_ASM_EH_FRAME_SECTION darwin_eh_frame_section
789   
790 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)  \
791   (((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)
792
793 #define REGISTER_TARGET_PRAGMAS(PFILE)                          \
794   do {                                                          \
795     cpp_register_pragma (PFILE, 0, "mark", darwin_pragma_ignore);  \
796     cpp_register_pragma (PFILE, 0, "options", darwin_pragma_options);  \
797     cpp_register_pragma (PFILE, 0, "segment", darwin_pragma_ignore);  \
798     cpp_register_pragma (PFILE, 0, "unused", darwin_pragma_unused);  \
799   } while (0)