OSDN Git Service

* netbsd.h (COLLECT_SHARED_INIT_FUNC)
[pf3gnuchains/gcc-fork.git] / gcc / config / netbsd.h
1 /* NETBSD_NATIVE is defined when gcc is integrated into the NetBSD
2    source tree so it can be configured appropriately without using
3    the GNU configure/build mechanism. */
4
5 #ifdef NETBSD_NATIVE
6
7 /* Look for the include files in the system-defined places.  */
8
9 #undef GPLUSPLUS_INCLUDE_DIR
10 #define GPLUSPLUS_INCLUDE_DIR "/usr/include/g++"
11
12 #undef GCC_INCLUDE_DIR
13 #define GCC_INCLUDE_DIR "/usr/include"
14
15 #undef INCLUDE_DEFAULTS
16 #define INCLUDE_DEFAULTS                        \
17   {                                             \
18     { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },     \
19     { GCC_INCLUDE_DIR, "GCC", 0, 0 },           \
20     { 0, 0, 0, 0 }                              \
21   }
22
23 /* Under NetBSD, the normal location of the compiler back ends is the
24    /usr/libexec directory.  */
25
26 #undef STANDARD_EXEC_PREFIX
27 #define STANDARD_EXEC_PREFIX            "/usr/libexec/"
28
29 /* Under NetBSD, the normal location of the various *crt*.o files is the
30    /usr/lib directory.  */
31
32 #undef STANDARD_STARTFILE_PREFIX
33 #define STANDARD_STARTFILE_PREFIX       "/usr/lib/"
34
35 #endif
36
37
38 /* Provide a CPP_SPEC appropriate for NetBSD.  Current we just deal with
39    the GCC option `-posix'.  */
40
41 #undef CPP_SPEC
42 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
43
44 /* Provide an ASM_SPEC appropriate for NetBSD.  Currently we only deal
45    with the options for generating PIC code.  */
46
47 #undef ASM_SPEC
48 #define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k -K}"
49
50 /* Provide a LIB_SPEC appropriate for NetBSD.  Just select the appropriate
51    libc, depending on whether we're doing profiling.  */
52
53 #undef LIB_SPEC
54 #define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
55
56 /* Provide a LINK_SPEC appropriate for NetBSD.  Here we provide support
57    for the special GCC options -shared, -static, -assert, and -nostdlib.  */
58
59 #undef LINK_SPEC
60 #define LINK_SPEC \
61   "%{!shared:%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{R*} %{static:-Bstatic}} %{shared} %{assert*}"
62
63 /* When building shared libraries, the initialization and finalization 
64    functions for the library are .init and .fini respectively.  */
65
66 #define COLLECT_SHARED_INIT_FUNC(STREAM,FUNC)                           \
67   do {                                                                  \
68     fprintf ((STREAM), "void __init() __asm__ (\".init\");");           \
69     fprintf ((STREAM), "void __init() {\n\t%s();\n}\n", (FUNC));        \
70   } while (0)
71
72 #define COLLECT_SHARED_FINI_FUNC(STREAM,FUNC)                           \
73   do {                                                                  \
74     fprintf ((STREAM), "void __fini() __asm__ (\".fini\");");           \
75     fprintf ((STREAM), "void __fini() {\n\t%s();\n}\n", (FUNC));        \
76   } while (0)
77
78 /* This defines which switch letters take arguments. */
79 #undef SWITCH_TAKES_ARG
80 #define SWITCH_TAKES_ARG(CHAR) \
81   (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
82    || (CHAR) == 'R')
83
84 /* Implicit library calls should use memcpy, not bcopy, etc.  */
85
86 #undef TARGET_MEM_FUNCTIONS
87 #define TARGET_MEM_FUNCTIONS 1
88
89 /* Handle #pragma weak and #pragma pack.  */
90
91 #define HANDLE_SYSV_PRAGMA
92 \f
93 /*
94  * Some imports from svr4.h in support of shared libraries.
95  * Currently, we need the DECLARE_OBJECT_SIZE stuff.
96  */
97
98 /* Define the strings used for the .type, .size, and .set directives.
99    These strings generally do not vary from one system running netbsd
100    to another, but if a given system needs to use different pseudo-op
101    names for these, they may be overridden in the file which includes
102    this one.  */
103
104 #undef TYPE_ASM_OP
105 #undef SIZE_ASM_OP
106 #undef SET_ASM_OP
107 #define TYPE_ASM_OP     "\t.type\t"
108 #define SIZE_ASM_OP     "\t.size\t"
109 #define SET_ASM_OP      "\t.set\t"
110
111 /* This is how we tell the assembler that a symbol is weak.  */
112
113 #undef ASM_WEAKEN_LABEL
114 #define ASM_WEAKEN_LABEL(FILE,NAME) \
115   do { fputs ("\t.globl\t", FILE); assemble_name (FILE, NAME); \
116        fputc ('\n', FILE); \
117        fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
118        fputc ('\n', FILE); } while (0)
119
120 /* The following macro defines the format used to output the second
121    operand of the .type assembler directive.  Different svr4 assemblers
122    expect various different forms for this operand.  The one given here
123    is just a default.  You may need to override it in your machine-
124    specific tm.h file (depending upon the particulars of your assembler).  */
125
126 #undef TYPE_OPERAND_FMT
127 #define TYPE_OPERAND_FMT        "@%s"
128
129 /* Write the extra assembler code needed to declare a function's result.
130    Most svr4 assemblers don't require any special declaration of the
131    result value, but there are exceptions.  */
132
133 #ifndef ASM_DECLARE_RESULT
134 #define ASM_DECLARE_RESULT(FILE, RESULT)
135 #endif
136
137 /* These macros generate the special .type and .size directives which
138    are used to set the corresponding fields of the linker symbol table
139    entries in an ELF object file under SVR4.  These macros also output
140    the starting labels for the relevant functions/objects.  */
141
142 /* Write the extra assembler code needed to declare a function properly.
143    Some svr4 assemblers need to also have something extra said about the
144    function's return value.  We allow for that here.  */
145
146 #undef ASM_DECLARE_FUNCTION_NAME
147 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
148   do {                                                                  \
149     fprintf (FILE, "%s", TYPE_ASM_OP);                                  \
150     assemble_name (FILE, NAME);                                         \
151     putc (',', FILE);                                                   \
152     fprintf (FILE, TYPE_OPERAND_FMT, "function");                       \
153     putc ('\n', FILE);                                                  \
154     ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));                      \
155     ASM_OUTPUT_LABEL(FILE, NAME);                                       \
156   } while (0)
157
158 /* Write the extra assembler code needed to declare an object properly.  */
159
160 #undef ASM_DECLARE_OBJECT_NAME
161 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                       \
162   do {                                                                  \
163     fprintf (FILE, "%s", TYPE_ASM_OP);                                  \
164     assemble_name (FILE, NAME);                                         \
165     putc (',', FILE);                                                   \
166     fprintf (FILE, TYPE_OPERAND_FMT, "object");                         \
167     putc ('\n', FILE);                                                  \
168     size_directive_output = 0;                                          \
169     if (!flag_inhibit_size_directive && DECL_SIZE (DECL))               \
170       {                                                                 \
171         size_directive_output = 1;                                      \
172         fprintf (FILE, "%s", SIZE_ASM_OP);                              \
173         assemble_name (FILE, NAME);                                     \
174         fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL))); \
175       }                                                                 \
176     ASM_OUTPUT_LABEL(FILE, NAME);                                       \
177   } while (0)
178
179 /* Output the size directive for a decl in rest_of_decl_compilation
180    in the case where we did not do so before the initializer.
181    Once we find the error_mark_node, we know that the value of
182    size_directive_output was set
183    by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
184
185 #undef ASM_FINISH_DECLARE_OBJECT
186 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)         \
187 do {                                                                     \
188      const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);             \
189      if (!flag_inhibit_size_directive && DECL_SIZE (DECL)                \
190          && ! AT_END && TOP_LEVEL                                        \
191          && DECL_INITIAL (DECL) == error_mark_node                       \
192          && !size_directive_output)                                      \
193        {                                                                 \
194          size_directive_output = 1;                                      \
195          fprintf (FILE, "%s", SIZE_ASM_OP);                              \
196          assemble_name (FILE, name);                                     \
197          fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL))); \
198        }                                                                 \
199    } while (0)
200
201 /* This is how to declare the size of a function.  */
202
203 #undef ASM_DECLARE_FUNCTION_SIZE
204 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)                    \
205   do {                                                                  \
206     if (!flag_inhibit_size_directive)                                   \
207       {                                                                 \
208         char label[256];                                                \
209         static int labelno;                                             \
210         labelno++;                                                      \
211         ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno);            \
212         ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno);               \
213         fprintf (FILE, "%s", SIZE_ASM_OP);                              \
214         assemble_name (FILE, (FNAME));                                  \
215         fprintf (FILE, ",");                                            \
216         assemble_name (FILE, label);                                    \
217         fprintf (FILE, "-");                                            \
218         assemble_name (FILE, (FNAME));                                  \
219         putc ('\n', FILE);                                              \
220       }                                                                 \
221   } while (0)