OSDN Git Service

339fb6b9b0b750f4996dbd31cb7a46492c74ee6a
[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, 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 #undef  CPP_SPEC
89 #define CPP_SPEC "%{static:-D__STATIC__}%{!static:-D__DYNAMIC__}"
90
91 /* Machine dependent libraries.  */
92
93 #undef  LIB_SPEC
94 #define LIB_SPEC "%{!static:-lSystem}"
95
96 /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
97
98 #undef  STARTFILE_SPEC
99 #define STARTFILE_SPEC  \
100   "%{pg:%{static:-lgcrt0.o}%{!static:-lgcrt1.o}} \
101     %{!pg:%{static:-lcrt0.o}%{!static:-lcrt1.o}}"
102
103 #undef  DOLLARS_IN_IDENTIFIERS
104 #define DOLLARS_IN_IDENTIFIERS 2
105
106 /* We use Dbx symbol format.  */
107
108 #define DBX_DEBUGGING_INFO
109
110 /* Also enable Dwarf 2 as an option.  */
111
112 #define DWARF2_DEBUGGING_INFO
113
114 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
115
116 /* When generating stabs debugging, use N_BINCL entries.  */
117
118 #define DBX_USE_BINCL
119
120 /* There is no limit to the length of stabs strings.  */
121
122 #define DBX_CONTIN_LENGTH 0
123
124 /* gdb needs a null N_SO at the end of each file for scattered loading. */
125
126 #undef  DBX_OUTPUT_MAIN_SOURCE_FILE_END
127 #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME)                 \
128 do { text_section ();                                                   \
129      fprintf (FILE,                                                     \
130               "\t.stabs \"%s\",%d,0,0,Letext\nLetext:\n", "" , N_SO);   \
131    } while (0)
132
133 /* Our profiling scheme doesn't LP labels and counter words.  */
134
135 #define NO_PROFILE_COUNTERS
136
137 #undef  INIT_SECTION_ASM_OP
138 #define INIT_SECTION_ASM_OP
139
140 #undef  INVOKE__main
141
142 #define TARGET_ASM_CONSTRUCTOR  machopic_asm_out_constructor
143 #define TARGET_ASM_DESTRUCTOR   machopic_asm_out_destructor
144
145
146 /* Don't output a .file directive.  That is only used by the assembler for
147    error reporting.  */
148
149 #undef  ASM_FILE_START
150 #define ASM_FILE_START(FILE)
151
152 #undef  ASM_FILE_END
153 #define ASM_FILE_END(FILE)                                      \
154   do {                                                          \
155     machopic_finish (asm_out_file);                             \
156     if (strcmp (lang_hooks.name, "GNU C++") == 0)               \
157       {                                                         \
158         constructor_section ();                                 \
159         destructor_section ();                                  \
160         ASM_OUTPUT_ALIGN (FILE, 1);                             \
161       }                                                         \
162   } while (0)
163
164 #undef ASM_OUTPUT_LABEL
165 #define ASM_OUTPUT_LABEL(FILE,NAME)     \
166   do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
167
168 #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
169   fprintf (FILE, "\t.space %d\n", SIZE)
170
171 /* Give ObjC methods pretty symbol names. */
172
173 #undef  OBJC_GEN_METHOD_LABEL
174 #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \
175   do { if (CAT_NAME)                                                    \
176          sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+',          \
177                   (CLASS_NAME), (CAT_NAME), (SEL_NAME));                \
178        else                                                             \
179          sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+',              \
180                   (CLASS_NAME), (SEL_NAME));                            \
181      } while (0)
182
183 /* The RTTI data (e.g., __ti4name) is common and public (and static),
184    but it does need to be referenced via indirect PIC data pointers.
185    The machopic_define_name calls are telling the machopic subsystem
186    that the name *is* defined in this module, so it doesn't need to
187    make them indirect.  */
188
189 #undef ASM_DECLARE_OBJECT_NAME
190 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                       \
191   do {                                                                  \
192     const char *xname = NAME;                                           \
193     if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF)             \
194       xname = IDENTIFIER_POINTER (DECL_NAME (DECL));                    \
195     if ((TREE_STATIC (DECL)                                             \
196          && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
197         || DECL_INITIAL (DECL))                                         \
198       machopic_define_name (xname);                                     \
199     if ((TREE_STATIC (DECL)                                             \
200          && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
201         || DECL_INITIAL (DECL))                                         \
202       (* targetm.encode_section_info) (DECL, false);                    \
203     ASM_OUTPUT_LABEL (FILE, xname);                                     \
204   } while (0)
205
206 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
207   do {                                                                  \
208     const char *xname = NAME;                                           \
209     if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF)             \
210       xname = IDENTIFIER_POINTER (DECL_NAME (DECL));                    \
211     if ((TREE_STATIC (DECL)                                             \
212          && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
213         || DECL_INITIAL (DECL))                                         \
214       machopic_define_name (xname);                                     \
215     if ((TREE_STATIC (DECL)                                             \
216          && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
217         || DECL_INITIAL (DECL))                                         \
218       (* targetm.encode_section_info) (DECL, false);                    \
219     ASM_OUTPUT_LABEL (FILE, xname);                                     \
220     /* Avoid generating stubs for functions we've just defined by       \
221        outputting any required stub name label now.  */                 \
222     machopic_output_possible_stub_label (FILE, xname);                  \
223   } while (0)
224
225 /* Wrap new method names in quotes so the assembler doesn't gag.
226    Make Objective-C internal symbols local.  */
227
228 #undef  ASM_OUTPUT_LABELREF
229 #define ASM_OUTPUT_LABELREF(FILE,NAME)                                       \
230   do {                                                                       \
231        const char *xname = darwin_strip_name_encoding (NAME);                \
232        if (xname[0] == '&' || xname[0] == '*')                               \
233          {                                                                   \
234            int len = strlen (xname);                                         \
235            if (len > 6 && !strcmp ("$stub", xname + len - 5))                \
236              machopic_validate_stub_or_non_lazy_ptr (xname, 1);              \
237            else if (len > 7 && !strcmp ("$stub\"", xname + len - 6))         \
238              machopic_validate_stub_or_non_lazy_ptr (xname, 1);              \
239            else if (len > 14 && !strcmp ("$non_lazy_ptr", xname + len - 13)) \
240              machopic_validate_stub_or_non_lazy_ptr (xname, 0);              \
241            fputs (&xname[1], FILE);                                          \
242          }                                                                   \
243        else if (xname[0] == '+' || xname[0] == '-')                          \
244          fprintf (FILE, "\"%s\"", xname);                                    \
245        else if (!strncmp (xname, "_OBJC_", 6))                               \
246          fprintf (FILE, "L%s", xname);                                       \
247        else if (!strncmp (xname, ".objc_class_name_", 17))                   \
248          fprintf (FILE, "%s", xname);                                        \
249        else                                                                  \
250          fprintf (FILE, "_%s", xname);                                       \
251   } while (0)
252
253 /* Output before executable code.  */
254 #undef TEXT_SECTION_ASM_OP
255 #define TEXT_SECTION_ASM_OP ".text"
256
257 /* Output before writable data.  */
258
259 #undef DATA_SECTION_ASM_OP
260 #define DATA_SECTION_ASM_OP ".data"
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),                                \
278              floor_log2 ((ALIGN) / BITS_PER_UNIT));                     \
279     if ((DECL) && ((TREE_STATIC (DECL)                                  \
280          && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
281         || DECL_INITIAL (DECL)))                                        \
282       (* targetm.encode_section_info) (DECL, false);                    \
283     if ((DECL) && ((TREE_STATIC (DECL)                                  \
284          && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
285         || DECL_INITIAL (DECL)))                                        \
286       machopic_define_name (NAME);                                      \
287   } while (0)
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, OBJC)            \
304 extern void FUNCTION PARAMS ((void));                                   \
305 void                                                                    \
306 FUNCTION ()                                                             \
307 {                                                                       \
308   if (in_section != SECTION)                                            \
309     {                                                                   \
310       if (OBJC)                                                         \
311         objc_section_init ();                                           \
312       data_section ();                                                  \
313       if (asm_out_file)                                                 \
314         fprintf (asm_out_file, "%s\n", DIRECTIVE);                      \
315       in_section = SECTION;                                             \
316     }                                                                   \
317 }                                                                       \
318
319 /* Darwin uses many types of special sections.  */
320
321 #undef  EXTRA_SECTIONS
322 #define EXTRA_SECTIONS                                  \
323   in_const, in_const_data, in_cstring, in_literal4, in_literal8,        \
324   in_constructor, in_destructor, in_mod_init, in_mod_term,              \
325   in_objc_class, in_objc_meta_class, in_objc_category,  \
326   in_objc_class_vars, in_objc_instance_vars,            \
327   in_objc_cls_meth, in_objc_inst_meth,                  \
328   in_objc_cat_cls_meth, in_objc_cat_inst_meth,          \
329   in_objc_selector_refs,                                \
330   in_objc_selector_fixup,                               \
331   in_objc_symbols, in_objc_module_info,                 \
332   in_objc_protocol, in_objc_string_object,              \
333   in_objc_constant_string_object,                       \
334   in_objc_class_names, in_objc_meth_var_names,          \
335   in_objc_meth_var_types, in_objc_cls_refs,             \
336   in_machopic_nl_symbol_ptr,                            \
337   in_machopic_lazy_symbol_ptr,                          \
338   in_machopic_symbol_stub,                              \
339   in_machopic_picsymbol_stub,                           \
340   in_darwin_exception, in_darwin_eh_frame,              \
341   num_sections
342
343 #undef  EXTRA_SECTION_FUNCTIONS
344 #define EXTRA_SECTION_FUNCTIONS                 \
345 static void objc_section_init PARAMS ((void));  \
346 SECTION_FUNCTION (const_section,                \
347                   in_const,                     \
348                   ".const", 0)                  \
349 SECTION_FUNCTION (const_data_section,           \
350                   in_const_data,                \
351                   ".const_data", 0)             \
352 SECTION_FUNCTION (cstring_section,              \
353                   in_cstring,                   \
354                   ".cstring", 0)                \
355 SECTION_FUNCTION (literal4_section,             \
356                   in_literal4,                  \
357                   ".literal4", 0)               \
358 SECTION_FUNCTION (literal8_section,             \
359                   in_literal8,                  \
360                   ".literal8", 0)               \
361 SECTION_FUNCTION (constructor_section,          \
362                   in_constructor,               \
363                   ".constructor", 0)            \
364 SECTION_FUNCTION (mod_init_section,             \
365                   in_mod_init,                  \
366                   ".mod_init_func", 0)  \
367 SECTION_FUNCTION (mod_term_section, \
368                   in_mod_term,                  \
369                   ".mod_term_func", 0)  \
370 SECTION_FUNCTION (destructor_section,           \
371                   in_destructor,                \
372                   ".destructor", 0)             \
373 SECTION_FUNCTION (objc_class_section,           \
374                   in_objc_class,                \
375                   ".objc_class", 1)             \
376 SECTION_FUNCTION (objc_meta_class_section,      \
377                   in_objc_meta_class,           \
378                   ".objc_meta_class", 1)        \
379 SECTION_FUNCTION (objc_category_section,        \
380                   in_objc_category,             \
381                 ".objc_category", 1)            \
382 SECTION_FUNCTION (objc_class_vars_section,      \
383                   in_objc_class_vars,           \
384                   ".objc_class_vars", 1)        \
385 SECTION_FUNCTION (objc_instance_vars_section,   \
386                   in_objc_instance_vars,        \
387                   ".objc_instance_vars", 1)     \
388 SECTION_FUNCTION (objc_cls_meth_section,        \
389                   in_objc_cls_meth,             \
390                   ".objc_cls_meth", 1)  \
391 SECTION_FUNCTION (objc_inst_meth_section,       \
392                   in_objc_inst_meth,            \
393                   ".objc_inst_meth", 1) \
394 SECTION_FUNCTION (objc_cat_cls_meth_section,    \
395                   in_objc_cat_cls_meth,         \
396                   ".objc_cat_cls_meth", 1)      \
397 SECTION_FUNCTION (objc_cat_inst_meth_section,   \
398                   in_objc_cat_inst_meth,        \
399                   ".objc_cat_inst_meth", 1)     \
400 SECTION_FUNCTION (objc_selector_refs_section,   \
401                   in_objc_selector_refs,        \
402                   ".objc_message_refs", 1)      \
403 SECTION_FUNCTION (objc_selector_fixup_section,  \
404                   in_objc_selector_fixup,       \
405                   ".section __OBJC, __sel_fixup", 1)    \
406 SECTION_FUNCTION (objc_symbols_section,         \
407                   in_objc_symbols,              \
408                   ".objc_symbols", 1)   \
409 SECTION_FUNCTION (objc_module_info_section,     \
410                   in_objc_module_info,          \
411                   ".objc_module_info", 1)       \
412 SECTION_FUNCTION (objc_protocol_section,        \
413                   in_objc_protocol,             \
414                   ".objc_protocol", 1)  \
415 SECTION_FUNCTION (objc_string_object_section,   \
416                   in_objc_string_object,        \
417                   ".objc_string_object", 1)     \
418 SECTION_FUNCTION (objc_constant_string_object_section,  \
419                   in_objc_constant_string_object,       \
420                   ".section __OBJC, __cstring_object", 1)       \
421 SECTION_FUNCTION (objc_class_names_section,     \
422                 in_objc_class_names,            \
423                 ".objc_class_names", 1) \
424 SECTION_FUNCTION (objc_meth_var_names_section,  \
425                 in_objc_meth_var_names,         \
426                 ".objc_meth_var_names", 1)      \
427 SECTION_FUNCTION (objc_meth_var_types_section,  \
428                 in_objc_meth_var_types,         \
429                 ".objc_meth_var_types", 1)      \
430 SECTION_FUNCTION (objc_cls_refs_section,        \
431                 in_objc_cls_refs,               \
432                 ".objc_cls_refs", 1)            \
433                                                 \
434 SECTION_FUNCTION (machopic_lazy_symbol_ptr_section,     \
435                 in_machopic_lazy_symbol_ptr,            \
436                 ".lazy_symbol_pointer", 0)              \
437 SECTION_FUNCTION (machopic_nl_symbol_ptr_section,       \
438                 in_machopic_nl_symbol_ptr,              \
439                 ".non_lazy_symbol_pointer", 0)          \
440 SECTION_FUNCTION (machopic_symbol_stub_section,         \
441                 in_machopic_symbol_stub,                \
442                 ".symbol_stub", 0)                      \
443 SECTION_FUNCTION (machopic_picsymbol_stub_section,      \
444                 in_machopic_picsymbol_stub,             \
445                 ".picsymbol_stub", 0)                   \
446 SECTION_FUNCTION (darwin_exception_section,             \
447                 in_darwin_exception,                    \
448                 ".section __TEXT,__gcc_except_tab", 0)  \
449 SECTION_FUNCTION (darwin_eh_frame_section,              \
450                 in_darwin_eh_frame,                     \
451                 ".section __TEXT,__eh_frame", 0)        \
452                                                         \
453 static void                                     \
454 objc_section_init ()                            \
455 {                                               \
456   static int been_here = 0;                     \
457                                                 \
458   if (been_here == 0)                           \
459     {                                           \
460       been_here = 1;                            \
461           /* written, cold -> hot */            \
462       objc_cat_cls_meth_section ();             \
463       objc_cat_inst_meth_section ();            \
464       objc_string_object_section ();            \
465       objc_constant_string_object_section ();   \
466       objc_selector_refs_section ();            \
467       objc_selector_fixup_section ();           \
468       objc_cls_refs_section ();                 \
469       objc_class_section ();                    \
470       objc_meta_class_section ();               \
471           /* shared, hot -> cold */             \
472       objc_cls_meth_section ();                 \
473       objc_inst_meth_section ();                \
474       objc_protocol_section ();                 \
475       objc_class_names_section ();              \
476       objc_meth_var_types_section ();           \
477       objc_meth_var_names_section ();           \
478       objc_category_section ();                 \
479       objc_class_vars_section ();               \
480       objc_instance_vars_section ();            \
481       objc_module_info_section ();              \
482       objc_symbols_section ();                  \
483     }                                           \
484 }
485
486 #define READONLY_DATA_SECTION const_section
487
488 #undef  TARGET_ASM_SELECT_SECTION
489 #define TARGET_ASM_SELECT_SECTION machopic_select_section
490 #undef  TARGET_ASM_SELECT_RTX_SECTION
491 #define TARGET_ASM_SELECT_RTX_SECTION machopic_select_rtx_section
492
493 #define ASM_DECLARE_UNRESOLVED_REFERENCE(FILE,NAME)                     \
494     do {                                                                \
495          if (FILE) {                                                    \
496            if (flag_pic)                                                \
497              fprintf (FILE, "\t.lazy_reference ");                      \
498            else                                                         \
499              fprintf (FILE, "\t.reference ");                           \
500            assemble_name (FILE, NAME);                                  \
501            fprintf (FILE, "\n");                                        \
502          }                                                              \
503        } while (0)
504
505 #define ASM_DECLARE_CLASS_REFERENCE(FILE,NAME)                          \
506     do {                                                                \
507          if (FILE) {                                                    \
508            fprintf (FILE, "\t");                                        \
509            assemble_name (FILE, NAME);                                  \
510            fprintf (FILE, "=0\n");                                      \
511            assemble_global (NAME);                                      \
512          }                                                              \
513        } while (0)
514
515 #undef ASM_GLOBALIZE_LABEL
516 #define ASM_GLOBALIZE_LABEL(FILE,NAME)  \
517  do { const char *const _x = (NAME); if (!!strncmp (_x, "_OBJC_", 6)) { \
518   (fputs (".globl ", FILE), assemble_name (FILE, _x), fputs ("\n", FILE)); \
519  }} while (0)
520
521 #undef ASM_GENERATE_INTERNAL_LABEL
522 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
523   sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM))
524
525 /* This is how to output an internal numbered label where PREFIX is
526    the class of label and NUM is the number within the class.  */
527
528 #undef ASM_OUTPUT_INTERNAL_LABEL
529 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)      \
530   fprintf (FILE, "%s%d:\n", PREFIX, NUM)
531
532 /* Since we have a separate readonly data section, define this so that
533    jump tables end up in text rather than data.  */
534
535 #ifndef JUMP_TABLES_IN_TEXT_SECTION
536 #define JUMP_TABLES_IN_TEXT_SECTION 1
537 #endif
538
539 /* Symbolic names for various things we might know about a symbol.  */
540
541 enum machopic_addr_class {
542   MACHOPIC_UNDEFINED,
543   MACHOPIC_DEFINED_DATA,
544   MACHOPIC_UNDEFINED_DATA,
545   MACHOPIC_DEFINED_FUNCTION,
546   MACHOPIC_UNDEFINED_FUNCTION
547 };
548
549 /* Macros defining the various PIC cases.  */
550
551 #define MACHOPIC_INDIRECT      (flag_pic)
552 #define MACHOPIC_JUST_INDIRECT (flag_pic == 1)
553 #define MACHOPIC_PURE          (flag_pic == 2)
554
555 #define TARGET_ENCODE_SECTION_INFO  darwin_encode_section_info
556 #define TARGET_STRIP_NAME_ENCODING  darwin_strip_name_encoding
557
558 #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH)          \
559   do {                                                          \
560     const char *const stub_ = (STUB);                           \
561     char *buffer_ = (BUF);                                      \
562     strcpy (buffer_, stub_);                                    \
563     if (stub_[0] == '"')                                        \
564       {                                                         \
565         strcpy (buffer_ + (STUB_LENGTH) - 1, "_binder\"");      \
566       }                                                         \
567     else                                                        \
568       {                                                         \
569         strcpy (buffer_ + (STUB_LENGTH), "_binder");            \
570       }                                                         \
571   } while (0)
572
573 #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH)    \
574   do {                                                          \
575     const char *const symbol_ = (SYMBOL);                       \
576     char *buffer_ = (BUF);                                      \
577     if (name_needs_quotes (symbol_) && symbol_[0] != '"')       \
578       {                                                         \
579           sprintf (buffer_, "\"%s\"", symbol_);                 \
580       }                                                         \
581     else                                                        \
582       {                                                         \
583         strcpy (buffer_, symbol_);                              \
584       }                                                         \
585   } while (0)
586
587 /* Given a symbol name string, create the lazy pointer version
588    of the symbol name.  */
589
590 #define GEN_LAZY_PTR_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH)  \
591   do {                                                          \
592     const char *symbol_ = darwin_strip_name_encoding (SYMBOL);  \
593     char *buffer_ = (BUF);                                      \
594     if (symbol_[0] == '"')                                      \
595       {                                                         \
596         strcpy (buffer_, "\"L");                                \
597         strcpy (buffer_ + 2, symbol_ + 1);                      \
598         strcpy (buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\"");      \
599       }                                                         \
600     else if (name_needs_quotes (symbol_))                       \
601       {                                                         \
602         strcpy (buffer_, "\"L");                                \
603         strcpy (buffer_ + 2, symbol_);                          \
604         strcpy (buffer_ + (SYMBOL_LENGTH) + 2, "$lazy_ptr\"");  \
605       }                                                         \
606     else                                                        \
607       {                                                         \
608         strcpy (buffer_, "L");                                  \
609         strcpy (buffer_ + 1, symbol_);                          \
610         strcpy (buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr");    \
611       }                                                         \
612   } while (0)
613
614 #define TARGET_ASM_EXCEPTION_SECTION darwin_exception_section
615
616 #define TARGET_ASM_EH_FRAME_SECTION darwin_eh_frame_section
617   
618 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)  \
619   (((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)
620
621 #define DARWIN_REGISTER_TARGET_PRAGMAS(PFILE)                           \
622   do {                                                                  \
623     cpp_register_pragma (PFILE, 0, "mark", darwin_pragma_ignore);       \
624     cpp_register_pragma (PFILE, 0, "options", darwin_pragma_options);   \
625     cpp_register_pragma (PFILE, 0, "segment", darwin_pragma_ignore);    \
626     cpp_register_pragma (PFILE, 0, "unused", darwin_pragma_unused);     \
627   } while (0)
628
629 #undef ASM_APP_ON
630 #define ASM_APP_ON ""
631 #undef ASM_APP_OFF
632 #define ASM_APP_OFF ""