home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / GNUSRC.Z / nextstep.h < prev    next >
C/C++ Source or Header  |  1996-08-14  |  28KB  |  808 lines

  1. /* nextstep.h -- operating system specific defines to be used when
  2.    targeting GCC for NeXTSTEP.
  3.    Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* Use new NeXT include file search path.
  22.    In a cross compiler with NeXT as target, don't expect
  23.    the host to use Next's directory scheme.  */
  24.  
  25. #if NeXT || !defined(CROSS_COMPILE)
  26. #undef    INCLUDE_DEFAULTS
  27. #if 0
  28. #define INCLUDE_DEFAULTS                \
  29.   {                            \
  30.     { "/NextDeveloper/Headers/g++", 1, 1},        \
  31.     { "/NextDeveloper/Headers", 0},            \
  32.     { "/NextDeveloper/Headers/ansi", 0},        \
  33.     { "/NextDeveloper/Headers/bsd", 0},            \
  34.     { "/LocalDeveloper/Headers", 0, 1},            \
  35.     { "/LocalDeveloper/Headers/ansi", 0},        \
  36.     { "/LocalDeveloper/Headers/bsd", 0},        \
  37. /*  { "/NextDeveloper/2.0CompatibleHeaders", 0}, */    \
  38.     { STANDARD_INCLUDE_DIR, 0},                \
  39.     { "/usr/include/bsd", 0},                \
  40.     { "FakeSystemHeaders", 0},                \
  41.     { 0, 0}                        \
  42.   }
  43. #endif /* 0 */
  44. #define INCLUDE_DEFAULTS                        \
  45.   {                                    \
  46.     { "/NextLibrary/Frameworks/System.framework/PrivateHeaders", 0},     \
  47.     { "/NextLibrary/Frameworks/System.framework/Headers", 0},         \
  48.     { "/NextLibrary/Frameworks/System.framework/Headers/ansi", 0},     \
  49.     { "/NextLibrary/Frameworks/System.framework/Headers/bsd", 0},     \
  50.     { "/NextDeveloper/Headers/g++", 1, 1},                \
  51.     { "/NextDeveloper/Headers", 0},                    \
  52.     { "/NextDeveloper/Headers/ansi", 0},                \
  53.     { "/NextDeveloper/Headers/bsd", 0},                    \
  54.     { "/LocalDeveloper/Headers", 0, 1},                    \
  55.     { STANDARD_INCLUDE_DIR, 0},                        \
  56.     { 0, 0}                                \
  57.   }
  58. #define REL3COMPAT_INCLUDE_DEFAULTS            \
  59.   {                            \
  60.     { "/LocalDeveloper/3.xCompatibleHeaders", 0},     \
  61.     { "/LocalDeveloper/3.xCompatibleHeaders/ansi", 0},     \
  62.     { "/LocalDeveloper/3.xCompatibleHeaders/bsd", 0},     \
  63.     { "/NextDeveloper/3.xCompatibleHeaders", 0},     \
  64.     { "/NextDeveloper/3.xCompatibleHeaders/ansi", 0},     \
  65.     { "/NextDeveloper/3.xCompatibleHeaders/bsd", 0},     \
  66.     { "/NextDeveloper/Headers/g++", 1, 1},        \
  67.     { "/LocalDeveloper/Headers", 0},             \
  68.     { "/NextDeveloper/Headers", 0},             \
  69.     { 0, 0}                        \
  70.   }
  71. #endif /* !CROSS_COMPILE */
  72.  
  73. /* Report errors to make application. */
  74.  
  75. #define REPORT_EVENT(TYPE, NAME, FILE, LINE, MSG, ARG1, ARG2, ARG3)    \
  76.   make_support (TYPE, NAME, FILE, LINE, MSG, ARG1, ARG2, ARG3)
  77. #define V_REPORT_EVENT(TYPE, NAME, FILE, LINE, MSG, AP)            \
  78.   v_make_support (TYPE, NAME, FILE, LINE, MSG, AP)
  79.   
  80. #undef    EXTRA_FORMAT_FUNCTIONS
  81. #define EXTRA_FORMAT_FUNCTIONS \
  82.       "NXPrintf",    FALSE,    2,    FALSE,    \
  83.       "NXScanf",    TRUE,    2,    FALSE,    \
  84.       "NXVPrintf",    FALSE,    2,    TRUE,    \
  85.       "NXVScanf",    TRUE,    2,    TRUE,    \
  86.       "DPSPrintf",    FALSE,    2,    FALSE,    \
  87.       "bsd_sprintf",    FALSE,    2,    FALSE,    \
  88.       "bsd_vsprintf",    FALSE,    2,    TRUE,
  89.  
  90. /* Make the compiler look here for standard stuff */
  91.  
  92. #ifdef STANDARD_EXEC_PREFIX
  93. #undef STANDARD_EXEC_PREFIX
  94. #endif
  95. #define STANDARD_EXEC_PREFIX "/lib/"
  96.  
  97. /* Make -fnext-runtime the default.  */
  98.  
  99. #define NEXT_OBJC_RUNTIME
  100.  
  101. /* Support -arch xx flags */
  102.  
  103. #define NEXT_FAT_OUTPUT
  104.  
  105. /* support the precompiled header cpp */
  106.  
  107. #define NEXT_CPP_PRECOMP
  108.  
  109. /* Don't make the compiler think it knows which headerfiles are
  110.    c++ and which are not.   */
  111. /* #define NO_IMPLICIT_EXTERN_C */
  112.  
  113. /* change semantics of things around the compiler... */
  114.  
  115. #ifndef NEXT_SEMANTICS
  116. #define NEXT_SEMANTICS
  117. #endif
  118.  
  119. /* make the library functions in libgcc have only one underbar
  120.    in front of them.  */
  121. #define NEXT_LIBGCC_NAMES
  122.  
  123. /* We have atexit.  */
  124.  
  125. #define HAVE_ATEXIT
  126.  
  127. /* Enable recent gcc to compile under the old gcc in Next release 1.0.  */
  128.  
  129. #define __inline inline
  130.  
  131. /* wchar_t is unsigned short */
  132.  
  133. #undef    WCHAR_TYPE
  134. #define WCHAR_TYPE "short unsigned int"
  135. #undef    WCHAR_TYPE_SIZE
  136. #define WCHAR_TYPE_SIZE (BITS_PER_WORD / 2)
  137.  
  138. /* Don't default to pcc-struct-return, because gcc is the only compiler, and
  139.    we want to retain compatibility with older gcc versions.  */
  140.  
  141. #undef    DEFAULT_PCC_STRUCT_RETURN
  142. #define DEFAULT_PCC_STRUCT_RETURN 0
  143.  
  144. /* These compiler options take n arguments.  */
  145.  
  146. #undef    WORD_SWITCH_TAKES_ARG
  147. #define WORD_SWITCH_TAKES_ARG(STR)         \
  148.   (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) ? 1 :    \
  149.    !strcmp (STR, "segalign") ? 1 :        \
  150.    !strcmp (STR, "seg1addr") ? 1 :        \
  151.    !strcmp (STR, "undefined") ? 1 :        \
  152.    !strcmp (STR, "dylib_file") ? 1 :        \
  153.    !strcmp (STR, "segaddr") ? 2 :        \
  154.    !strcmp (STR, "sectobjectsymbols") ? 2 :    \
  155.    !strcmp (STR, "segprot") ? 3 :        \
  156.    !strcmp (STR, "sectcreate") ? 3 :        \
  157.    !strcmp (STR, "sectalign") ? 3 :        \
  158.    !strcmp (STR, "segcreate") ? 3 :        \
  159.    !strcmp (STR, "sectorder") ? 3 :        \
  160.    !strcmp (STR, "siff-mask") ? 1 :        \
  161.    !strcmp (STR, "siff-filter") ? 1 :        \
  162.    !strcmp (STR, "siff-warning") ? 1 :        \
  163.    !strcmp (STR, "arch") ? 1 :            \
  164.    !strcmp (STR, "NEXTSTEP-deployment-target") ? 1 : \
  165.    !strcmp (STR, "pagezero_size") ? 1 :        \
  166.    !strcmp (STR, "dylinker_install_name") ? 1 :    \
  167.    !strcmp (STR, "framework") ? 1 :        \
  168.    !strcmp (STR, "install_name") ? 1 :        \
  169.    !strcmp (STR, "arch_only") ? 1 :        \
  170.    !strcmp (STR, "compatibility_version") ? 1 :    \
  171.    !strcmp (STR, "current_version") ? 1 :    \
  172.    0)
  173.  
  174. #undef    WORD_SWITCH
  175. #define WORD_SWITCH(STR)            \
  176.   (WORD_SWITCH_TAKES_ARG (STR)            \
  177.    || !strcmp (STR, "bsd")            \
  178.    || !strcmp (STR, "object")            \
  179.    || !strcmp (STR, "ObjC")            \
  180.    || !strcmp (STR, "dylinker")            \
  181.    || !strcmp (STR, "dynamic")            \
  182.    || !strcmp (STR, "static")            \
  183.    || !strcmp (STR, "rel3compat")        \
  184.    || !strcmp (STR, "threeThreeMethodEncoding") \
  185.    || !strcmp (STR, "bundle")            \
  186.    || !strcmp (STR, "dynamiclib")        \
  187.    || !strcmp (STR, "output_for_dyld")        \
  188.    || !strcmp (STR, "keep_private_externs")    \
  189.    || !strcmp (STR, "all_load"))
  190.  
  191. /* Machine dependent ccp options.  */
  192.  
  193. #ifndef NX_RELEASE
  194. #define NX_RELEASE "400"
  195. #endif
  196.  
  197. #undef    CPP_SPEC
  198. #define CPP_SPEC "%{!traditional: -D__STDC__}            \
  199.                   %{posixstrict:-D_POSIX_SOURCE}         \
  200.                   %{!posixstrict:%{bsd:-D__STRICT_BSD__} \
  201.                   %{posix:-D_POSIX_SOURCE}               \
  202.                   %{!ansi:-D_NEXT_SOURCE}}               \
  203.               %{mdisable-fpregs:-D__NO_FP__}     \
  204.           %{F*}    %{ansi} %{fno-asm}             \
  205.           %{rel3compat:}              \
  206.           -DNX_COMPILER_RELEASE_3_0=300          \
  207.           -DNX_COMPILER_RELEASE_3_1=310          \
  208.           -DNX_COMPILER_RELEASE_3_2=320          \
  209.           -DNX_COMPILER_RELEASE_3_3=330          \
  210.           -DNX_CURRENT_COMPILER_RELEASE=" NX_RELEASE " \
  211.           -DNS_TARGET_MINOR=0    \
  212.           -DNS_TARGET_MAJOR=4   \
  213.           -DNS_TARGET=40    \
  214.           -D__GNUC_MINOR__=5    \
  215.           %{traditional:-D__GNU_CPP__}%{traditional-cpp:-D__GNU_CPP__}\
  216.           %{!traditional:%{!traditional-cpp:-D__NEXT_CPP__}} \
  217.                   %{dynamic:-D__DYNAMIC__}%{!dynamic:-D__STATIC__} \
  218.                   %{MD:-MD %M} %{MMD:-MMD %M}"
  219.  
  220. /* Machine dependent ld options.  */
  221.  
  222. #undef    LINK_SPEC
  223. #define LINK_SPEC "%{Z} %{M} %{F*} \
  224. %{execute*} %{preload*} %{fvmlib*} \
  225. %{segalign*} %{seg1addr*} %{segaddr*} %{segprot*} \
  226. %{pagezero_size*} %{undefined*} %{dylib_file*} \
  227. %{seglinkedit*} %{noseglinkedit*} %{read_only_relocs} \
  228. %{sectcreate*} %{sectalign*} %{sectobjectsymbols}\
  229. %{segcreate*} %{Mach*} %{whyload} %{w} \
  230. %{sectorder*} %{whatsloaded} %{ObjC} %{all_load} %{object} \
  231. %{dylinker} %{dylinker_install_name*} %{output_for_dyld} \
  232. %{keep_private_externs} %{prebind} %{noprebind}"
  233.  
  234. /* Machine dependent libraries.  */
  235.  
  236. #undef    LIB_SPEC
  237. #if 0
  238. #define LIB_SPEC "%{!bundle:%{!posix*:%{!pg:-lsys_s}%{pg:-lsys_p}}%{posix*:-lposix}}"
  239. #endif
  240. #define LIB_SPEC \
  241.      "%{!static:%{!pg:-framework System}%{pg:-framework System,_profile}} \
  242.       %{static:%{!pg:-lsys_s}%{pg:-lsys_p}}"
  243.  
  244. /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
  245.  
  246. #undef    STARTFILE_SPEC
  247. #define STARTFILE_SPEC  \
  248. "%{!dynamiclib:%{bundle:%{dynamic:-lbundle1.o}} \
  249.    %{!bundle:%{pg:%{!dynamic:-lgcrt0.o} \
  250.           %{dynamic:%{object:-lgcrt0.o} \
  251.                 %{!object:%{preload:-lgcrt0.o} \
  252.                       %{!preload:-lgcrt1.o}}}} \
  253.         %{!pg:%{!dynamic:-lcrt0.o} \
  254.           %{dynamic:%{object:-lcrt0.o} \
  255.                 %{!object:%{preload:-lcrt0.o} \
  256.                       %{!preload:-lcrt1.o}}}}}}"
  257.  
  258. /* Why not? */
  259.  
  260. #undef    DOLLARS_IN_IDENTIFIERS
  261. #define DOLLARS_IN_IDENTIFIERS 2
  262.  
  263. /* Allow #sscs (but don't do anything). */
  264.  
  265. #define SCCS_DIRECTIVE
  266.  
  267. /* We use Dbx symbol format.  */
  268.  
  269. #undef    SDB_DEBUGGING_INFO
  270. #undef    XCOFF_DEBUGGING_INFO
  271. #define DBX_DEBUGGING_INFO
  272.  
  273. /* This saves a fair amount of space. */
  274.  
  275. #undef    DBX_CONTIN_LENGTH
  276. #define DBX_CONTIN_LENGTH 0
  277.  
  278. /* These screw up NeXT's gdb at the moment, so don't use them. */
  279.  
  280. #undef    DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
  281. #define DBX_OUTPUT_MAIN_SOURCE_DIRECTORY(FILE, FILENAME)
  282.  
  283. /* These come from bsd386.h, but are specific to sequent, so make sure
  284.    they don't bite us.  */
  285.  
  286. #undef    DBX_NO_XREFS
  287. #undef    DBX_CONTIN_LENGTH
  288.  
  289. /* gdb needs a null N_SO at the end of each file for scattered loading. */
  290.  
  291. #undef    DBX_OUTPUT_MAIN_SOURCE_FILE_END
  292. #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME)            \
  293.   fprintf (FILE,                            \
  294.        "\t.text\n\t.stabs \"%s\",%d,0,0,Letext\nLetext:\n",        \
  295.        "" , N_SO)
  296.  
  297. /* Don't use .gcc_compiled symbols to communicate with GDB;
  298.    They interfere with numerically sorted symbol lists. */
  299.  
  300. #undef    ASM_IDENTIFY_GCC
  301. #define ASM_IDENTIFY_GCC(asm_out_file)
  302. #undef    INIT_SECTION_ASM_OP
  303. #define INIT_SECTION_ASM_OP
  304. #undef    INVOKE__main
  305.  
  306. #define ASM_OUTPUT_ZEROFILL(FILE, NAME, SIZE, ALIGNMENT)      \
  307. do { fputs (".zerofill __DATA, __common, ", (FILE));        \
  308.         assemble_name ((FILE), (NAME));                \
  309.         fprintf ((FILE), ", %u, %u\n", (SIZE), (ALIGNMENT));     \
  310.       } while (0)
  311.  
  312. #undef    ASM_OUTPUT_CONSTRUCTOR
  313. #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)                       \
  314.   do { if (flag_pic) mod_init_section ();                       \
  315.        else constructor_section ();                             \
  316.        ASM_OUTPUT_ALIGN (FILE, 1);                              \
  317.        fprintf (FILE, "\t.long ");                              \
  318.        assemble_name (FILE, NAME);                              \
  319.        fprintf (FILE, "\n");                                    \
  320.        if (!flag_pic)                                        \
  321.      fprintf (FILE, ".reference .constructors_used\n");     \
  322.       } while (0)
  323.  
  324. #undef    ASM_OUTPUT_DESTRUCTOR
  325. #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                        \
  326.   do { if (flag_pic) abort ();                    \
  327.        destructor_section ();                                   \
  328.        ASM_OUTPUT_ALIGN (FILE, 1);                              \
  329.        fprintf (FILE, "\t.long ");                              \
  330.        assemble_name (FILE, NAME);                              \
  331.        fprintf (FILE, "\n");                                    \
  332.        fprintf (FILE, ".reference .destructors_used\n");        \
  333.       } while (0)
  334.  
  335. #define CALL_DESTRUCTOR_DYNAMICALLY(dfndecl) \
  336.   call_destructor_dynamically (dfndecl)
  337. #define DYNAMIC_DESTRUCTORS (flag_pic != 0)
  338.  
  339. /* Don't output a .file directive.  That is only used by the assembler for
  340.    error reporting.  */
  341. #undef    ASM_FILE_START
  342. #define ASM_FILE_START(FILE)
  343.  
  344. #undef    ASM_FILE_END
  345. #define ASM_FILE_END(FILE)                    \
  346.   do {                                \
  347.     extern char *language_string;                \
  348.     if (strcmp (language_string, "GNU C++") == 0)        \
  349.       {                                \
  350.     constructor_section ();                    \
  351.     destructor_section ();                    \
  352.     ASM_OUTPUT_ALIGN (FILE, 1);                \
  353.       }                                \
  354.   } while (0)
  355.  
  356. /* How to parse #pragma's */
  357.  
  358. #undef    HANDLE_PRAGMA
  359. #define HANDLE_PRAGMA(finput) handle_pragma (finput, &get_directive_line)
  360.  
  361. /* Give methods pretty symbol names on NeXT. */
  362.  
  363. #undef    OBJC_GEN_METHOD_LABEL
  364. #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \
  365.   do { if (CAT_NAME)                            \
  366.      sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+',        \
  367.           (CLASS_NAME), (CAT_NAME), (SEL_NAME));        \
  368.        else                                \
  369.      sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+',        \
  370.           (CLASS_NAME), (SEL_NAME));                \
  371.      } while (0)
  372.  
  373. /* Wrap new method names in quotes so the assembler doesn't gag.
  374.    Make Objective-C internal symbols local.  */
  375.  
  376. #undef    ASM_OUTPUT_LABELREF
  377. #define ASM_OUTPUT_LABELREF(FILE,NAME)    \
  378.   do { if (NAME[0] == '+' || NAME[0] == '-') fprintf (FILE, "\"%s\"", NAME); \
  379.        else if (!strncmp (NAME, "_OBJC_", 6)) fprintf (FILE, "L%s", NAME);   \
  380.        else if (!strncmp (NAME, ".objc_class_name_", 17))        \
  381.      fprintf (FILE, "%s", NAME);                    \
  382.        else fprintf (FILE, "_%s", NAME); } while (0)
  383.  
  384. #undef    ALIGN_ASM_OP
  385. #define ALIGN_ASM_OP        ".align"
  386.  
  387. #undef    ASM_OUTPUT_ALIGN
  388. #define ASM_OUTPUT_ALIGN(FILE,LOG)    \
  389.   if ((LOG) != 0)            \
  390.     fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG))
  391.  
  392. /* Ensure correct alignment of bss data.  */
  393.  
  394. #undef    ASM_OUTPUT_ALIGNED_LOCAL
  395. #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
  396. ( fputs (".lcomm ", (FILE)),                \
  397.   assemble_name ((FILE), (NAME)),            \
  398.   fprintf ((FILE), ",%u,%u\n", (SIZE), floor_log2 ((ALIGN) / BITS_PER_UNIT)))
  399.  
  400. /* Output #ident as a .ident.  */
  401.  
  402. #undef    ASM_OUTPUT_IDENT
  403. #define ASM_OUTPUT_IDENT(FILE, NAME)
  404.  
  405. /* The maximum alignment which the object file format can support.
  406.    For NeXT's Mach-O format, this is 2^15.  */
  407.  
  408. #undef    MAX_OFILE_ALIGNMENT
  409. #define MAX_OFILE_ALIGNMENT 0x8000
  410.  
  411. /* Create new Mach-O sections. */
  412.  
  413. #undef    SECTION_FUNCTION
  414. #define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, WAS_TEXT, OBJC)    \
  415. void                                    \
  416. FUNCTION ()                                \
  417. {                                    \
  418.   extern void text_section ();                         \
  419.   extern void objc_section_init ();                    \
  420.   extern int flag_no_mach_text_sections;                \
  421.                                       \
  422.   if (WAS_TEXT && flag_no_mach_text_sections)                   \
  423.     text_section ();                            \
  424.   else if (in_section != SECTION)                    \
  425.     {                                    \
  426.       if (OBJC)                                \
  427.     objc_section_init ();                        \
  428.       fprintf (asm_out_file, "%s\n", DIRECTIVE);            \
  429.       in_section = SECTION;                        \
  430.     }                                    \
  431. }                                    \
  432.  
  433. #define ALIAS_SECTION(enum_value, alias_name)         \
  434. do { if (!strcmp (alias_name, name)) \
  435.         section_alias[enum_value] = alias ? get_identifier (alias) : 0;   \
  436.    } while (0)
  437.  
  438. #undef    EXTRA_SECTIONS
  439. #define EXTRA_SECTIONS                    \
  440.   in_const, in_const_data, in_cstring, in_literal4, in_literal8,    \
  441.   in_constructor, in_destructor, in_mod_init,        \
  442.   in_objc_class, in_objc_meta_class, in_objc_category,    \
  443.   in_objc_class_vars, in_objc_instance_vars,        \
  444.   in_objc_cls_meth, in_objc_inst_meth,            \
  445.   in_objc_cat_cls_meth, in_objc_cat_inst_meth,        \
  446.   in_objc_selector_refs,                \
  447.   in_objc_selector_fixup,                \
  448.   in_objc_symbols, in_objc_module_info,            \
  449.   in_objc_protocol, in_objc_string_object,        \
  450.   in_objc_constant_string_object,            \
  451.   in_objc_class_names, in_objc_meth_var_names,        \
  452.   in_objc_meth_var_types, in_objc_cls_refs,         \
  453.   in_machopic_nl_symbol_ptr,                \
  454.   in_machopic_lazy_symbol_ptr,                \
  455.   in_machopic_symbol_stub,                \
  456.   in_machopic_picsymbol_stub
  457.  
  458. #undef    EXTRA_SECTION_FUNCTIONS
  459. #define EXTRA_SECTION_FUNCTIONS            \
  460. SECTION_FUNCTION (const_section,        \
  461.                   in_const,            \
  462.                   ".const", 1, 0)        \
  463. SECTION_FUNCTION (const_data_section,        \
  464.                   in_const_data,        \
  465.                   ".const_data", 1, 0)        \
  466. SECTION_FUNCTION (cstring_section,        \
  467.           in_cstring,            \
  468.           ".cstring", 1, 0)        \
  469. SECTION_FUNCTION (literal4_section,        \
  470.           in_literal4,            \
  471.           ".literal4", 1, 0)        \
  472. SECTION_FUNCTION (literal8_section,        \
  473.           in_literal8,            \
  474.           ".literal8", 1, 0)        \
  475. SECTION_FUNCTION (constructor_section,        \
  476.           in_constructor,        \
  477.           ".constructor", 0, 0)        \
  478. SECTION_FUNCTION (mod_init_section,        \
  479.           in_mod_init,            \
  480.           ".mod_init_func", 0, 0)    \
  481. SECTION_FUNCTION (destructor_section,        \
  482.           in_destructor,        \
  483.           ".destructor", 0, 0)        \
  484. SECTION_FUNCTION (objc_class_section,        \
  485.           in_objc_class,        \
  486.           ".objc_class", 0, 1)        \
  487. SECTION_FUNCTION (objc_meta_class_section,    \
  488.           in_objc_meta_class,        \
  489.           ".objc_meta_class", 0, 1)    \
  490. SECTION_FUNCTION (objc_category_section,    \
  491.           in_objc_category,        \
  492.         ".objc_category", 0, 1)        \
  493. SECTION_FUNCTION (objc_class_vars_section,    \
  494.           in_objc_class_vars,        \
  495.           ".objc_class_vars", 0, 1)    \
  496. SECTION_FUNCTION (objc_instance_vars_section,    \
  497.           in_objc_instance_vars,    \
  498.           ".objc_instance_vars", 0, 1)    \
  499. SECTION_FUNCTION (objc_cls_meth_section,    \
  500.           in_objc_cls_meth,        \
  501.           ".objc_cls_meth", 0, 1)    \
  502. SECTION_FUNCTION (objc_inst_meth_section,    \
  503.           in_objc_inst_meth,        \
  504.           ".objc_inst_meth", 0, 1)    \
  505. SECTION_FUNCTION (objc_cat_cls_meth_section,    \
  506.           in_objc_cat_cls_meth,        \
  507.           ".objc_cat_cls_meth", 0, 1)    \
  508. SECTION_FUNCTION (objc_cat_inst_meth_section,    \
  509.           in_objc_cat_inst_meth,    \
  510.           ".objc_cat_inst_meth", 0, 1)    \
  511. SECTION_FUNCTION (objc_selector_refs_section,    \
  512.           in_objc_selector_refs,    \
  513.           ".objc_message_refs", 0, 1)    \
  514. SECTION_FUNCTION (objc_selector_fixup_section,    \
  515.           in_objc_selector_fixup,    \
  516.           ".section __OBJC, __sel_fixup", 0, 1)    \
  517. SECTION_FUNCTION (objc_symbols_section,        \
  518.           in_objc_symbols,        \
  519.           ".objc_symbols", 0, 1)    \
  520. SECTION_FUNCTION (objc_module_info_section,    \
  521.           in_objc_module_info,        \
  522.           ".objc_module_info", 0, 1)    \
  523. SECTION_FUNCTION (objc_protocol_section,    \
  524.           in_objc_protocol,        \
  525.           ".objc_protocol", 0, 1)    \
  526. SECTION_FUNCTION (objc_string_object_section,    \
  527.           in_objc_string_object,    \
  528.           ".objc_string_object", 0, 1)    \
  529. SECTION_FUNCTION (objc_constant_string_object_section,    \
  530.           in_objc_constant_string_object,    \
  531.           ".section __OBJC, __cstring_object", 0, 1)    \
  532. SECTION_FUNCTION (objc_class_names_section,    \
  533.         in_objc_class_names,        \
  534.         ".objc_class_names", 0, 1)    \
  535. SECTION_FUNCTION (objc_meth_var_names_section,    \
  536.         in_objc_meth_var_names,        \
  537.         ".objc_meth_var_names", 0, 1)    \
  538. SECTION_FUNCTION (objc_meth_var_types_section,    \
  539.         in_objc_meth_var_types,        \
  540.         ".objc_meth_var_types", 0, 1)    \
  541. SECTION_FUNCTION (objc_cls_refs_section,    \
  542.         in_objc_cls_refs,        \
  543.         ".objc_cls_refs", 0, 1)        \
  544.                         \
  545. SECTION_FUNCTION (machopic_lazy_symbol_ptr_section,    \
  546.         in_machopic_lazy_symbol_ptr,        \
  547.         ".lazy_symbol_pointer", 0, 0)          \
  548. SECTION_FUNCTION (machopic_nl_symbol_ptr_section,    \
  549.         in_machopic_nl_symbol_ptr,        \
  550.         ".non_lazy_symbol_pointer", 0, 0)          \
  551. SECTION_FUNCTION (machopic_symbol_stub_section,        \
  552.         in_machopic_symbol_stub,        \
  553.         ".symbol_stub", 0, 0)              \
  554. SECTION_FUNCTION (machopic_picsymbol_stub_section,    \
  555.         in_machopic_picsymbol_stub,        \
  556.         ".picsymbol_stub", 0, 0)              \
  557.                             \
  558. void                        \
  559. objc_section_init ()                \
  560. {                        \
  561.   static int been_here = 0;            \
  562.                         \
  563.   if (been_here == 0)                \
  564.     {                        \
  565.       been_here = 1;                \
  566.           /* written, cold -> hot */        \
  567.       objc_cat_cls_meth_section ();        \
  568.       objc_cat_inst_meth_section ();        \
  569.       objc_string_object_section ();        \
  570.       objc_constant_string_object_section ();    \
  571.       objc_selector_refs_section ();        \
  572.       objc_selector_fixup_section ();        \
  573.       objc_cls_refs_section ();            \
  574.       objc_class_section ();            \
  575.       objc_meta_class_section ();        \
  576.           /* shared, hot -> cold */            \
  577.       objc_cls_meth_section ();            \
  578.       objc_inst_meth_section ();        \
  579.       objc_protocol_section ();            \
  580.       objc_class_names_section ();        \
  581.       objc_meth_var_types_section ();        \
  582.       objc_meth_var_names_section ();        \
  583.       objc_category_section ();            \
  584.       objc_class_vars_section ();        \
  585.       objc_instance_vars_section ();        \
  586.       objc_module_info_section ();        \
  587.       objc_symbols_section ();            \
  588.     }                        \
  589. }                         \
  590. static tree section_alias[(int)num_sections];        \
  591. void try_section_alias ()             \
  592. {                        \
  593.     if (section_alias[in_section])        \
  594.        fprintf (asm_out_file, "%s\n",        \
  595.               IDENTIFIER_POINTER (section_alias[in_section]));    \
  596. }                              \
  597. void alias_section (name, alias)            \
  598.   char *name, *alias;                    \
  599. {                            \
  600.     ALIAS_SECTION(in_data, "data");            \
  601.     ALIAS_SECTION(in_text, "text");            \
  602.     ALIAS_SECTION(in_const, "const");            \
  603.     ALIAS_SECTION(in_const_data, "const_data");        \
  604.     ALIAS_SECTION(in_cstring, "cstring");        \
  605.     ALIAS_SECTION(in_literal4, "literal4");        \
  606.     ALIAS_SECTION(in_literal8, "literal8");        \
  607. }
  608.  
  609. #undef    READONLY_DATA_SECTION
  610. #define READONLY_DATA_SECTION const_section
  611.  
  612. #undef    SELECT_SECTION
  613. #define SELECT_SECTION(exp,reloc)                \
  614.   do                                \
  615.     {                                \
  616.       if (TREE_CODE (exp) == STRING_CST)            \
  617.     {                            \
  618.       if (flag_writable_strings)                \
  619.         data_section ();                    \
  620.       else if (TREE_STRING_LENGTH (exp) !=            \
  621.            strlen (TREE_STRING_POINTER (exp)) + 1)    \
  622.         readonly_data_section ();                \
  623.       else                            \
  624.         cstring_section ();                    \
  625.     }                            \
  626.       else if (TREE_CODE (exp) == INTEGER_CST            \
  627.            || TREE_CODE (exp) == REAL_CST)            \
  628.         {                            \
  629.       tree size = TYPE_SIZE (TREE_TYPE (exp));        \
  630.                                   \
  631.       if (TREE_CODE (size) == INTEGER_CST &&        \
  632.           TREE_INT_CST_LOW (size) == 4 &&            \
  633.           TREE_INT_CST_HIGH (size) == 0)            \
  634.         literal4_section ();                \
  635.       else if (TREE_CODE (size) == INTEGER_CST &&        \
  636.           TREE_INT_CST_LOW (size) == 8 &&            \
  637.           TREE_INT_CST_HIGH (size) == 0)            \
  638.         literal8_section ();                \
  639.       else                            \
  640.         readonly_data_section ();                \
  641.     }                            \
  642.       else if (TREE_CODE (exp) == CONSTRUCTOR                \
  643.            && TREE_TYPE (exp)                    \
  644.            && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE        \
  645.            && TYPE_NAME (TREE_TYPE (exp)))                \
  646.     {                                \
  647.       tree name = TYPE_NAME (TREE_TYPE (exp));            \
  648.       if (TREE_CODE (name) == TYPE_DECL)                \
  649.         name = DECL_NAME (name);                    \
  650.       if (!strcmp (IDENTIFIER_POINTER (name), "NSConstantString"))    \
  651.         objc_constant_string_object_section ();            \
  652.       else if (!strcmp (IDENTIFIER_POINTER (name), "NXConstantString")) \
  653.         objc_string_object_section ();                \
  654.       else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))        \
  655.         && !TREE_SIDE_EFFECTS (exp))                \
  656.                   { if (flag_pic && reloc ) const_data_section ();      \
  657.                     else readonly_data_section (); }                    \
  658.       else                                \
  659.         data_section ();                        \
  660.       }                                    \
  661.       else if (TREE_CODE (exp) == VAR_DECL &&                \
  662.            DECL_NAME (exp) &&                    \
  663.            TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE &&    \
  664.            IDENTIFIER_POINTER (DECL_NAME (exp)) &&            \
  665.            !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \
  666.     {                                \
  667.       const char *name = IDENTIFIER_POINTER (DECL_NAME (exp));    \
  668.                                       \
  669.       if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20))        \
  670.         objc_cls_meth_section ();                    \
  671.       else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23))    \
  672.         objc_inst_meth_section ();                    \
  673.       else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \
  674.         objc_cat_cls_meth_section ();                \
  675.       else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \
  676.         objc_cat_inst_meth_section ();                \
  677.       else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22))    \
  678.         objc_class_vars_section ();                    \
  679.       else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25))    \
  680.         objc_instance_vars_section ();                \
  681.       else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22))    \
  682.         objc_cat_cls_meth_section ();                \
  683.       else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17))        \
  684.         objc_class_names_section ();                \
  685.       else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20))        \
  686.         objc_meth_var_names_section ();                \
  687.       else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20))        \
  688.         objc_meth_var_types_section ();                \
  689.       else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22))    \
  690.         objc_cls_refs_section ();                    \
  691.       else if (!strncmp (name, "_OBJC_CLASS_", 12))            \
  692.         objc_class_section ();                    \
  693.       else if (!strncmp (name, "_OBJC_METACLASS_", 16))        \
  694.         objc_meta_class_section ();                    \
  695.       else if (!strncmp (name, "_OBJC_CATEGORY_", 15))        \
  696.         objc_category_section ();                    \
  697.       else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25))    \
  698.         objc_selector_refs_section ();                \
  699.       else if (!strncmp (name, "_OBJC_SELECTOR_FIXUP", 20))        \
  700.         objc_selector_fixup_section ();                \
  701.       else if (!strncmp (name, "_OBJC_SYMBOLS", 13))        \
  702.         objc_symbols_section ();                    \
  703.       else if (!strncmp (name, "_OBJC_MODULES", 13))        \
  704.         objc_module_info_section ();                \
  705.       else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) \
  706.         objc_cat_inst_meth_section ();                              \
  707.       else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) \
  708.         objc_cat_cls_meth_section ();                               \
  709.       else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20))         \
  710.         objc_cat_cls_meth_section ();                               \
  711.       else if (!strncmp (name, "_OBJC_PROTOCOL_", 15))              \
  712.         objc_protocol_section ();                                   \
  713.       else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))        \
  714.         && !TREE_SIDE_EFFECTS (exp))                 \
  715.              { if (flag_pic && reloc ) const_data_section ();             \
  716.                else readonly_data_section (); }                           \
  717.       else                                \
  718.         data_section ();                        \
  719.     }                                \
  720.       else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))    \
  721.            && !TREE_SIDE_EFFECTS (exp))                \
  722.                  { if (flag_pic && reloc ) const_data_section ();             \
  723.                    else readonly_data_section (); }                           \
  724.       else                                \
  725.         data_section ();                        \
  726.       try_section_alias ();    \
  727.     }                                    \
  728.   while (0)
  729.  
  730. #undef    SELECT_RTX_SECTION
  731. #define SELECT_RTX_SECTION(mode, rtx)                    \
  732.   do                                    \
  733.     {                                    \
  734.       if (GET_MODE_SIZE(mode) == 8)                    \
  735.     literal8_section();                        \
  736.       else if (GET_MODE_SIZE(mode) == 4)                \
  737.     literal4_section();                        \
  738.       else                                \
  739.     const_section ();                        \
  740.     }                                    \
  741.   while (0)
  742.  
  743.  
  744. #define LINK_COMMAND_SPEC \
  745. "%{!fsyntax-only: \
  746.    %{!c:%{!M:%{!MM:%{!E:%{!precomp:%{!S: \
  747.       %{dynamiclib:/bin/libtool -arch_only %T %J} \
  748.      %{!dynamiclib:%{.C:/bin/ld++}%{.M:/bin/ld++}%{.cc:/bin/ld++} \
  749.           %{!.C:%{!.M:%{!.cc:%{ObjC++:/bin/ld++}%{!ObjC++:/bin/ld}}}} \
  750.           -arch %T %{@:-arch_multiple}} \
  751.             %l %X \
  752.             %{force_cpusubtype_ALL}\
  753.             %{@:-o %f%g-%T.out}%{!@:%{o}} \
  754.                         %{NEXTSTEP-deployment-target} \
  755.             %{dynamic} %{static} %{bundle} \
  756.             %{A} %{d} %{e*} \
  757.             %{m} %{N} %{n} \
  758.             %{p} \
  759.             %{r} %{s} %{S} %{T*} %{t} %{u*} %{X} %{x} %{z} %{y*} \
  760.             %{!A:%{!nostartfiles:%{!nostdlib:%S}}} %{static:}\
  761.             %{L*} %D %o \
  762.             %{!nostdlib: %L %{!A:%E}} \
  763.      %{!dynamiclib:\n/bin/objcunique %{prebind} %{noprebind} \
  764.            %{@:%f%g-%T.out} %{!@:%{o*:%*}}}}}}}}}}"
  765.  
  766.  
  767. #define DECLARE_UNRESOLVED_REFERENCE(NAME)                \
  768.     do { extern FILE* asm_out_file;                     \
  769.      if (flag_pic) fprintf (asm_out_file, "\t.lazy_reference ");    \
  770.      else fprintf (asm_out_file, "\t.reference ");            \
  771.      assemble_name (asm_out_file, NAME);                \
  772.      fprintf (asm_out_file, "\n");                    \
  773.        } while (0)
  774.  
  775.  
  776. #define DECLARE_CLASS_REFERENCE(NAME) \
  777.     do { extern FILE* asm_out_file; fprintf (asm_out_file, "\t");    \
  778.          assemble_name (asm_out_file, NAME);                 \
  779.      fprintf (asm_out_file, "=0\n");                \
  780.      assemble_global (NAME);                    \
  781.        } while (0)
  782.  
  783. #define GO_IF_CPLUSPLUS_INCLUDE_NAME(NAME,LABEL)        \
  784.  do { char *_p = (NAME);                    \
  785.       _next: switch (*_p) { case 0: break;            \
  786.       case 'c': case 'C': case 'G': case 'g':            \
  787.       if (_p[1] == '+' && _p[2] == '+') goto LABEL; break;    \
  788.       default: _p += 1; goto _next; }} while (0)
  789.  
  790. #undef ASM_GLOBALIZE_LABEL
  791. #define ASM_GLOBALIZE_LABEL(FILE,NAME)    \
  792.  do { const char* _x = (NAME); if (!!strncmp (_x, "_OBJC_", 6)) { \
  793.   (fputs (".globl ", FILE), assemble_name (FILE, _x), fputs ("\n", FILE)); \
  794.  }} while (0)
  795.  
  796. #define ASM_PRIVATE_EXTERNIZE_LABEL(FILE, NAME) \
  797.  do { const char* _x = (NAME); if (!!strncmp (_x, "_OBJC_", 6)) { \
  798.   fputs (".private_extern ", FILE); assemble_name (FILE, _x); \
  799.   fputs ("\n", FILE); }} while (0)
  800.  
  801. #ifdef NEXT_LIBGCC_NAMES
  802. #include "next/nextstep.def"
  803. #endif
  804.  
  805. #ifndef JUMP_TABLES_IN_TEXT_SECTION
  806. #define JUMP_TABLES_IN_TEXT_SECTION 1
  807. #endif
  808.