OSDN Git Service

c3a0a91c613a67b5ba90729d18ec5960f8f5a96e
[pf3gnuchains/gcc-fork.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 /* 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 /* 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 /* Default to using the NeXT-style runtime, since that's what is
74    pre-installed on Darwin systems.  */
75
76 #define NEXT_OBJC_RUNTIME
77
78 /* Don't default to pcc-struct-return, because gcc is the only compiler, and
79    we want to retain compatibility with older gcc versions.  */
80
81 #undef  DEFAULT_PCC_STRUCT_RETURN
82 #define DEFAULT_PCC_STRUCT_RETURN 0
83
84 /* Don't warn about MacOS-style 'APPL' four-char-constants.  */
85
86 #undef WARN_FOUR_CHAR_CONSTANTS
87 #define WARN_FOUR_CHAR_CONSTANTS 0
88
89 /* Machine dependent cpp options.  */
90
91 /* The sequence here allows us to get a more specific version number
92    glued into __APPLE_CC__.  Normally this number would be updated as
93    part of submitting to a release engineering organization.  */
94
95 #ifndef APPLE_CC
96 #define APPLE_CC 999
97 #endif
98
99 #define STRINGIFY_THIS(x) # x
100 #define REALLY_STRINGIFY(x) STRINGIFY_THIS(x)
101
102 #undef  CPP_SPEC
103 #define CPP_SPEC "-D__APPLE_CC__=" REALLY_STRINGIFY(APPLE_CC) " \
104                   %{static:-D__STATIC__}%{!static:-D__DYNAMIC__}"
105
106 /* Machine dependent libraries.  */
107
108 #undef  LIB_SPEC
109 #define LIB_SPEC "%{!static:-lSystem}"
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     machopic_finish (asm_out_file);                             \
200     if (strcmp (language_string, "GNU C++") == 0)               \
201       {                                                         \
202         constructor_section ();                                 \
203         destructor_section ();                                  \
204         ASM_OUTPUT_ALIGN (FILE, 1);                             \
205       }                                                         \
206   } while (0)
207
208 /* Give ObjcC methods pretty symbol names. */
209
210 #undef  OBJC_GEN_METHOD_LABEL
211 #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \
212   do { if (CAT_NAME)                                                    \
213          sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+',          \
214                   (CLASS_NAME), (CAT_NAME), (SEL_NAME));                \
215        else                                                             \
216          sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+',              \
217                   (CLASS_NAME), (SEL_NAME));                            \
218      } while (0)
219
220 /* The RTTI data (e.g., __ti4name) is common and public (and static),
221    but it does need to be referenced via indirect PIC data pointers.
222    The machopic_define_name calls are telling the machopic subsystem
223    that the name *is* defined in this module, so it doesn't need to
224    make them indirect.  */
225
226 #undef ASM_DECLARE_OBJECT_NAME
227 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                       \
228   do {                                                                  \
229     char *xname = NAME;                                                 \
230     if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF)             \
231       xname = IDENTIFIER_POINTER (DECL_NAME (DECL));                    \
232     if ((TREE_STATIC (DECL)                                             \
233          && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
234         || DECL_INITIAL (DECL))                                         \
235       machopic_define_name (xname);                                     \
236     if ((TREE_STATIC (DECL)                                             \
237          && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
238         || DECL_INITIAL (DECL))                                         \
239       ENCODE_SECTION_INFO (DECL);  \
240     ASM_OUTPUT_LABEL (FILE, xname);                                     \
241   } while (0)
242
243 /* Wrap new method names in quotes so the assembler doesn't gag.
244    Make Objective-C internal symbols local.  */
245
246 #undef  ASM_OUTPUT_LABELREF
247 #define ASM_OUTPUT_LABELREF(FILE,NAME)  \
248   do {                                                                  \
249        STRIP_NAME_ENCODING (NAME, NAME);  \
250        if (NAME[0] == '&')                                              \
251          {                                                              \
252            int len = strlen (NAME);                                     \
253            if (len > 6 && !strcmp ("$stub", NAME + len - 5))            \
254              machopic_validate_stub_or_non_lazy_ptr (NAME, 1);          \
255            else if (len > 7 && !strcmp ("$stub\"", NAME + len - 6))     \
256              machopic_validate_stub_or_non_lazy_ptr (NAME, 1);          \
257            else if (len > 14 && !strcmp ("$non_lazy_ptr", NAME + len - 13)) \
258              machopic_validate_stub_or_non_lazy_ptr (NAME, 0);          \
259            fputs (&NAME[1], FILE); \
260          } \
261        else if (NAME[0] == '+' || NAME[0] == '-')   \
262          fprintf (FILE, "\"%s\"", NAME); \
263        else if (!strncmp (NAME, "_OBJC_", 6))  \
264          fprintf (FILE, "L%s", NAME);   \
265        else if (!strncmp (NAME, ".objc_class_name_", 17))               \
266          fprintf (FILE, "%s", NAME);                                    \
267        else                                                             \
268          fprintf (FILE, "_%s", NAME);                                   \
269   } while (0)
270
271 #undef  ALIGN_ASM_OP
272 #define ALIGN_ASM_OP            ".align"
273
274 #undef  ASM_OUTPUT_ALIGN
275 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
276   if ((LOG) != 0)                       \
277     fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG))
278
279 /* Ensure correct alignment of bss data.  */
280
281 #undef  ASM_OUTPUT_ALIGNED_DECL_LOCAL
282 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
283   do {  \
284     fputs (".lcomm ", (FILE));                          \
285     assemble_name ((FILE), (NAME));                     \
286     fprintf ((FILE), ",%u,%u\n", (SIZE), floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
287     if ((DECL) && ((TREE_STATIC (DECL)                                             \
288          && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
289         || DECL_INITIAL (DECL)))                                         \
290       ENCODE_SECTION_INFO (DECL);  \
291     if ((DECL) && ((TREE_STATIC (DECL)                                             \
292          && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
293         || DECL_INITIAL (DECL)))                                         \
294       machopic_define_name (NAME);                                     \
295   } while (0)
296
297 /* Output nothing for #ident.  */
298
299 #undef  ASM_OUTPUT_IDENT
300 #define ASM_OUTPUT_IDENT(FILE, NAME)
301
302 /* The maximum alignment which the object file format can support.
303    For Mach-O, this is 2^15.  */
304
305 #undef  MAX_OFILE_ALIGNMENT
306 #define MAX_OFILE_ALIGNMENT 0x8000
307
308 /* Create new Mach-O sections. */
309
310 #undef  SECTION_FUNCTION
311 #define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, WAS_TEXT, OBJC)  \
312 void                                                                    \
313 FUNCTION ()                                                             \
314 {                                                                       \
315   extern void text_section ();                                          \
316   extern void objc_section_init ();                                     \
317   extern int flag_no_mach_text_sections;                                \
318                                                                         \
319   if (WAS_TEXT && flag_no_mach_text_sections)                           \
320     text_section ();                                                    \
321   else if (in_section != SECTION)                                       \
322     {                                                                   \
323       if (OBJC)                                                         \
324         objc_section_init ();                                           \
325       data_section ();                                                  \
326       if (asm_out_file)                                                 \
327         fprintf (asm_out_file, "%s\n", DIRECTIVE);                      \
328       in_section = SECTION;                                             \
329     }                                                                   \
330 }                                                                       \
331
332 #define ALIAS_SECTION(enum_value, alias_name)                           \
333 do { if (!strcmp (alias_name, name))                                    \
334        section_alias[enum_value] = (alias ? get_identifier (alias) : 0);  \
335    } while (0)
336
337 /* Darwin uses many types of special sections.  */
338
339 #undef  EXTRA_SECTIONS
340 #define EXTRA_SECTIONS                                  \
341   in_const, in_const_data, in_cstring, in_literal4, in_literal8,        \
342   in_constructor, in_destructor, in_mod_init, in_mod_term,              \
343   in_objc_class, in_objc_meta_class, in_objc_category,  \
344   in_objc_class_vars, in_objc_instance_vars,            \
345   in_objc_cls_meth, in_objc_inst_meth,                  \
346   in_objc_cat_cls_meth, in_objc_cat_inst_meth,          \
347   in_objc_selector_refs,                                \
348   in_objc_selector_fixup,                               \
349   in_objc_symbols, in_objc_module_info,                 \
350   in_objc_protocol, in_objc_string_object,              \
351   in_objc_constant_string_object,                       \
352   in_objc_class_names, in_objc_meth_var_names,          \
353   in_objc_meth_var_types, in_objc_cls_refs,             \
354   in_machopic_nl_symbol_ptr,                            \
355   in_machopic_lazy_symbol_ptr,                          \
356   in_machopic_symbol_stub,                              \
357   in_machopic_picsymbol_stub,                           \
358   num_sections
359
360 #undef  EXTRA_SECTION_FUNCTIONS
361 #define EXTRA_SECTION_FUNCTIONS                 \
362 SECTION_FUNCTION (const_section,                \
363                   in_const,                     \
364                   ".const", 1, 0)               \
365 SECTION_FUNCTION (const_data_section,           \
366                   in_const_data,                \
367                   ".const_data", 1, 0)          \
368 SECTION_FUNCTION (cstring_section,              \
369                   in_cstring,                   \
370                   ".cstring", 1, 0)             \
371 SECTION_FUNCTION (literal4_section,             \
372                   in_literal4,                  \
373                   ".literal4", 1, 0)            \
374 SECTION_FUNCTION (literal8_section,             \
375                   in_literal8,                  \
376                   ".literal8", 1, 0)            \
377 SECTION_FUNCTION (constructor_section,          \
378                   in_constructor,               \
379                   ".constructor", 0, 0)         \
380 SECTION_FUNCTION (mod_init_section,             \
381                   in_mod_init,                  \
382                   ".mod_init_func", 0, 0)       \
383 SECTION_FUNCTION (mod_term_section, \
384                   in_mod_term,                  \
385                   ".mod_term_func", 0, 0)       \
386 SECTION_FUNCTION (destructor_section,           \
387                   in_destructor,                \
388                   ".destructor", 0, 0)          \
389 SECTION_FUNCTION (objc_class_section,           \
390                   in_objc_class,                \
391                   ".objc_class", 0, 1)          \
392 SECTION_FUNCTION (objc_meta_class_section,      \
393                   in_objc_meta_class,           \
394                   ".objc_meta_class", 0, 1)     \
395 SECTION_FUNCTION (objc_category_section,        \
396                   in_objc_category,             \
397                 ".objc_category", 0, 1)         \
398 SECTION_FUNCTION (objc_class_vars_section,      \
399                   in_objc_class_vars,           \
400                   ".objc_class_vars", 0, 1)     \
401 SECTION_FUNCTION (objc_instance_vars_section,   \
402                   in_objc_instance_vars,        \
403                   ".objc_instance_vars", 0, 1)  \
404 SECTION_FUNCTION (objc_cls_meth_section,        \
405                   in_objc_cls_meth,             \
406                   ".objc_cls_meth", 0, 1)       \
407 SECTION_FUNCTION (objc_inst_meth_section,       \
408                   in_objc_inst_meth,            \
409                   ".objc_inst_meth", 0, 1)      \
410 SECTION_FUNCTION (objc_cat_cls_meth_section,    \
411                   in_objc_cat_cls_meth,         \
412                   ".objc_cat_cls_meth", 0, 1)   \
413 SECTION_FUNCTION (objc_cat_inst_meth_section,   \
414                   in_objc_cat_inst_meth,        \
415                   ".objc_cat_inst_meth", 0, 1)  \
416 SECTION_FUNCTION (objc_selector_refs_section,   \
417                   in_objc_selector_refs,        \
418                   ".objc_message_refs", 0, 1)   \
419 SECTION_FUNCTION (objc_selector_fixup_section,  \
420                   in_objc_selector_fixup,       \
421                   ".section __OBJC, __sel_fixup", 0, 1) \
422 SECTION_FUNCTION (objc_symbols_section,         \
423                   in_objc_symbols,              \
424                   ".objc_symbols", 0, 1)        \
425 SECTION_FUNCTION (objc_module_info_section,     \
426                   in_objc_module_info,          \
427                   ".objc_module_info", 0, 1)    \
428 SECTION_FUNCTION (objc_protocol_section,        \
429                   in_objc_protocol,             \
430                   ".objc_protocol", 0, 1)       \
431 SECTION_FUNCTION (objc_string_object_section,   \
432                   in_objc_string_object,        \
433                   ".objc_string_object", 0, 1)  \
434 SECTION_FUNCTION (objc_constant_string_object_section,  \
435                   in_objc_constant_string_object,       \
436                   ".section __OBJC, __cstring_object", 0, 1)    \
437 SECTION_FUNCTION (objc_class_names_section,     \
438                 in_objc_class_names,            \
439                 ".objc_class_names", 0, 1)      \
440 SECTION_FUNCTION (objc_meth_var_names_section,  \
441                 in_objc_meth_var_names,         \
442                 ".objc_meth_var_names", 0, 1)   \
443 SECTION_FUNCTION (objc_meth_var_types_section,  \
444                 in_objc_meth_var_types,         \
445                 ".objc_meth_var_types", 0, 1)   \
446 SECTION_FUNCTION (objc_cls_refs_section,        \
447                 in_objc_cls_refs,               \
448                 ".objc_cls_refs", 0, 1)         \
449                                                 \
450 SECTION_FUNCTION (machopic_lazy_symbol_ptr_section,     \
451                 in_machopic_lazy_symbol_ptr,            \
452                 ".lazy_symbol_pointer", 0, 0)           \
453 SECTION_FUNCTION (machopic_nl_symbol_ptr_section,       \
454                 in_machopic_nl_symbol_ptr,              \
455                 ".non_lazy_symbol_pointer", 0, 0)       \
456 SECTION_FUNCTION (machopic_symbol_stub_section,         \
457                 in_machopic_symbol_stub,                \
458                 ".symbol_stub", 0, 0)                   \
459 SECTION_FUNCTION (machopic_picsymbol_stub_section,      \
460                 in_machopic_picsymbol_stub,             \
461                 ".picsymbol_stub", 0, 0)                \
462                                                         \
463 void                                            \
464 objc_section_init ()                            \
465 {                                               \
466   static int been_here = 0;                     \
467                                                 \
468   if (been_here == 0)                           \
469     {                                           \
470       been_here = 1;                            \
471           /* written, cold -> hot */            \
472       objc_cat_cls_meth_section ();             \
473       objc_cat_inst_meth_section ();            \
474       objc_string_object_section ();            \
475       objc_constant_string_object_section ();   \
476       objc_selector_refs_section ();            \
477       objc_selector_fixup_section ();           \
478       objc_cls_refs_section ();                 \
479       objc_class_section ();                    \
480       objc_meta_class_section ();               \
481           /* shared, hot -> cold */             \
482       objc_cls_meth_section ();                 \
483       objc_inst_meth_section ();                \
484       objc_protocol_section ();                 \
485       objc_class_names_section ();              \
486       objc_meth_var_types_section ();           \
487       objc_meth_var_names_section ();           \
488       objc_category_section ();                 \
489       objc_class_vars_section ();               \
490       objc_instance_vars_section ();            \
491       objc_module_info_section ();              \
492       objc_symbols_section ();                  \
493     }                                           \
494 }                                               \
495 static tree section_alias[(int) num_sections];  \
496 void try_section_alias ()                       \
497 {                                               \
498     if (section_alias[in_section] && asm_out_file) \
499       fprintf (asm_out_file, "%s\n",            \
500                IDENTIFIER_POINTER (section_alias[in_section])); \
501 }                                               \
502 void alias_section (name, alias)                        \
503      char *name, *alias;                                \
504 {                                                       \
505     ALIAS_SECTION (in_data, "data");                    \
506     ALIAS_SECTION (in_text, "text");                    \
507     ALIAS_SECTION (in_const, "const");                  \
508     ALIAS_SECTION (in_const_data, "const_data");        \
509     ALIAS_SECTION (in_cstring, "cstring");              \
510     ALIAS_SECTION (in_literal4, "literal4");            \
511     ALIAS_SECTION (in_literal8, "literal8");            \
512 }
513
514 #undef  READONLY_DATA_SECTION
515 #define READONLY_DATA_SECTION const_section
516
517 #undef  SELECT_SECTION
518 #define SELECT_SECTION(exp,reloc)                               \
519   do                                                            \
520     {                                                           \
521       if (TREE_CODE (exp) == STRING_CST)                        \
522         {                                                       \
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 ();                                 \
530         }                                                       \
531       else if (TREE_CODE (exp) == INTEGER_CST                   \
532                || TREE_CODE (exp) == REAL_CST)                  \
533         {                                                       \
534           tree size = TYPE_SIZE (TREE_TYPE (exp));              \
535                                                                 \
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 ();                           \
546         }                                                       \
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)))                          \
551         {                                                               \
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))          \
560             {                                                           \
561               if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc)         \
562                 const_data_section ();                                  \
563               else                                                      \
564                 readonly_data_section ();                               \
565             }                                                           \
566           else                                                          \
567             data_section ();                                            \
568       }                                                                 \
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)) \
574         {                                                               \
575           const char *name = IDENTIFIER_POINTER (DECL_NAME (exp));      \
576                                                                         \
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 ();                                            \
627         }                                                               \
628       else if (TREE_READONLY (exp) || TREE_CONSTANT (exp))              \
629         {                                                               \
630           if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc)             \
631             const_data_section ();                                      \
632           else                                                          \
633             readonly_data_section ();                                   \
634         }                                                               \
635       else                                                              \
636         data_section ();                                                \
637       try_section_alias ();                                             \
638     }                                                                   \
639   while (0)
640
641 #undef  SELECT_RTX_SECTION
642 #define SELECT_RTX_SECTION(mode, rtx)                                   \
643   do                                                                    \
644     {                                                                   \
645       if (GET_MODE_SIZE (mode) == 8)                                    \
646         literal8_section ();                                            \
647       else if (GET_MODE_SIZE (mode) == 4)                               \
648         literal4_section ();                                            \
649       else                                                              \
650         const_section ();                                               \
651     }                                                                   \
652   while (0)
653
654 #define ASM_DECLARE_UNRESOLVED_REFERENCE(FILE,NAME)                     \
655     do {                                                                \
656          if (FILE) {                                                    \
657            if (flag_pic)                                                \
658              fprintf (FILE, "\t.lazy_reference ");                      \
659            else                                                         \
660              fprintf (FILE, "\t.reference ");                           \
661            assemble_name (FILE, NAME);                                  \
662            fprintf (FILE, "\n");                                        \
663          }                                                              \
664        } while (0)
665
666 #define ASM_DECLARE_CLASS_REFERENCE(FILE,NAME)                          \
667     do {                                                                \
668          if (FILE) {                                                    \
669            fprintf (FILE, "\t");                                        \
670            assemble_name (FILE, NAME);                                  \
671            fprintf (FILE, "=0\n");                                      \
672            assemble_global (NAME);                                      \
673          }                                                              \
674        } while (0)
675
676 #undef ASM_GLOBALIZE_LABEL
677 #define ASM_GLOBALIZE_LABEL(FILE,NAME)  \
678  do { const char* _x = (NAME); if (!!strncmp (_x, "_OBJC_", 6)) { \
679   (fputs (".globl ", FILE), assemble_name (FILE, _x), fputs ("\n", FILE)); \
680  }} while (0)
681
682 #undef ASM_GENERATE_INTERNAL_LABEL
683 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
684   sprintf (LABEL, "*%s%d", PREFIX, NUM)
685
686 /* This is how to output an internal numbered label where PREFIX is
687    the class of label and NUM is the number within the class.  */
688
689 #undef ASM_OUTPUT_INTERNAL_LABEL
690 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)      \
691   fprintf (FILE, "%s%d:\n", PREFIX, NUM)
692
693 /* Since we have a separate readonly data section, define this so that
694    jump tables end up in text rather than data.  */
695
696 #ifndef JUMP_TABLES_IN_TEXT_SECTION
697 #define JUMP_TABLES_IN_TEXT_SECTION 1
698 #endif
699
700 /* Symbolic names for various things we might know about a symbol.  */
701
702 enum machopic_addr_class {
703   MACHOPIC_UNDEFINED,
704   MACHOPIC_DEFINED_DATA,
705   MACHOPIC_UNDEFINED_DATA,
706   MACHOPIC_DEFINED_FUNCTION,
707   MACHOPIC_UNDEFINED_FUNCTION
708 };
709
710 /* Macros defining the various PIC cases.  */
711
712 #define MACHOPIC_INDIRECT      (flag_pic)
713 #define MACHOPIC_JUST_INDIRECT (flag_pic == 1)
714 #define MACHOPIC_PURE          (flag_pic == 2)
715
716 #define ENCODE_SECTION_INFO(DECL)  \
717   darwin_encode_section_info (DECL)
718
719 /* Be conservative and always redo the encoding.  */
720
721 #define REDO_SECTION_INFO_P(DECL) (1)
722
723 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME)  \
724   ((VAR) = ((SYMBOL_NAME[0] == '!') ? (SYMBOL_NAME) + 4 : (SYMBOL_NAME)))
725
726 #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH)          \
727   do {                                                          \
728     const char *stub_ = (STUB);                                 \
729     char *buffer_ = (BUF);                                      \
730     strcpy (buffer_, stub_);                                    \
731     if (stub_[0] == '"')                                        \
732       {                                                         \
733         strcpy (buffer_ + (STUB_LENGTH) - 1, "_binder\"");      \
734       }                                                         \
735     else                                                        \
736       {                                                         \
737         strcpy (buffer_ + (STUB_LENGTH), "_binder");            \
738       }                                                         \
739   } while (0)
740
741 #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH)    \
742   do {                                                          \
743     const char *symbol_ = (SYMBOL);                             \
744     char *buffer_ = (BUF);                                      \
745     if (name_needs_quotes (symbol_) && symbol_[0] != '"')       \
746       {                                                         \
747           sprintf (buffer_, "\"%s\"", symbol_);                 \
748       }                                                         \
749     else                                                        \
750       {                                                         \
751         strcpy (buffer_, symbol_);                              \
752       }                                                         \
753   } while (0)
754
755 /* Given a symbol name string, create the lazy pointer version
756    of the symbol name.  */
757
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] == '"')                                      \
764       {                                                         \
765         strcpy (buffer_, "\"L");                                        \
766         strcpy (buffer_ + 2, symbol_ + 1);                      \
767         strcpy (buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\"");      \
768       }                                                         \
769     else if (name_needs_quotes (symbol_))                       \
770       {                                                         \
771         strcpy (buffer_, "\"L");                                \
772         strcpy (buffer_ + 2, symbol_);                          \
773         strcpy (buffer_ + (SYMBOL_LENGTH) + 2, "$lazy_ptr\"");  \
774       }                                                         \
775     else                                                        \
776       {                                                         \
777         strcpy (buffer_, "L");                                  \
778         strcpy (buffer_ + 1, symbol_);                          \
779         strcpy (buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr");    \
780       }                                                         \
781   } while (0)
782