OSDN Git Service

bc648caa4d8fe1ed63219bf2e52bb0339e67e6c4
[pf3gnuchains/gcc-fork.git] / gcc / config / svr3.h
1 /* svr3.h  --  operating system specific defines to be used when
2    targeting GCC for some generic System V Release 3 system.
3    Copyright (C) 1991 Free Software Foundation, Inc.
4
5    Written by Ron Guilmette (rfg@ncd.com).
6
7 This file is part of GNU CC.
8
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING.  If not, write to
21 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22
23    To use this file, make up a file with a name like:
24
25         ?????svr3.h
26
27    where ????? is replaced by the name of the basic hardware that you
28    are targeting for.  Then, in the file ?????svr3.h, put something
29    like:
30
31         #include "?????.h"
32         #include "svr3.h"
33
34    followed by any really system-specific defines (or overrides of
35    defines) which you find that you need.  For example, CPP_PREDEFINES
36    is defined here with only the defined -Dunix and -DSVR3.  You should
37    probably override that in your target-specific ?????svr3.h file
38    with a set of defines that includes these, but also contains an
39    appropriate define for the type of hardware that you are targeting.
40 */
41
42 /* Define a symbol so that libgcc* can know what sort of operating
43    environment and assembler syntax we are targeting for.  */
44 #define SVR3_target
45
46 /* Cpp, assembler, linker, library, and startfile spec's.  */
47
48 /* You should redefine CPP_PREDEFINES in any file which includes this one.
49    The definition should be appropriate for the type of target system
50    involved, and it should include any -A (assertion) options which are
51    appropriate for the given target system.  */
52
53 #undef CPP_PREDEFINES
54
55 /* Output at beginning of assembler file.  */
56 /* The .file command should always begin the output.  */
57
58 #undef ASM_FILE_START
59 #define ASM_FILE_START(FILE)                                    \
60   do { output_file_directive ((FILE), main_input_filename);     \
61        if (optimize) ASM_FILE_START_1 (FILE);                   \
62      } while (0)
63
64 /* By default, do nothing: a few machines support .optim, but not most.  */
65 #undef ASM_FILE_START_1
66 #define ASM_FILE_START_1(FILE)
67
68 /* This says how to output an assembler line
69    to define a global common symbol.  */
70 /* We don't use ROUNDED because the standard compiler doesn't,
71    and the linker gives error messages if a common symbol
72    has more than one length value.  */
73
74 #undef ASM_OUTPUT_COMMON
75 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
76 ( fputs (".comm ", (FILE)),                     \
77   assemble_name ((FILE), (NAME)),               \
78   fprintf ((FILE), ",%u\n", (SIZE)))
79
80 /* This says how to output an assembler line
81    to define a local common symbol.  */
82
83 /* Note that using bss_section here caused errors
84    in building shared libraries on system V.3.  */
85 #undef ASM_OUTPUT_LOCAL
86 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)     \
87   do {                                                  \
88     int align = exact_log2 (ROUNDED);                   \
89     if (align > 2) align = 2;                           \
90     data_section ();                                    \
91     ASM_OUTPUT_ALIGN ((FILE), align == -1 ? 2 : align); \
92     ASM_OUTPUT_LABEL ((FILE), (NAME));                  \
93     fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED));     \
94   } while (0)
95
96 #if 0 /* For now, let's leave these machine-specific.  */
97 /* Use crt1.o as a startup file and crtn.o as a closing file.  */
98
99 #define STARTFILE_SPEC  \
100   "%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}"
101
102 #define LIB_SPEC "%{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp} -lc crtn.o%s"
103
104 /* Special flags for the linker.  I don't know what they do.  */
105
106 #define LINK_SPEC "%{T*} %{z:-lm}"
107 #endif
108
109 /* Allow #sccs in preprocessor.  */
110
111 #define SCCS_DIRECTIVE
112
113 /* Output #ident as a .ident.  */
114
115 #define ASM_OUTPUT_IDENT(FILE, NAME) \
116   fprintf (FILE, "\t.ident \"%s\"\n", NAME);
117
118 /* Use periods rather than dollar signs in special g++ assembler names.  */
119
120 #define NO_DOLLAR_IN_LABEL
121
122 /* Implicit library calls should use memcpy, not bcopy, etc.  */
123
124 #define TARGET_MEM_FUNCTIONS
125
126 /* System V Release 3 uses COFF debugging info.  */
127
128 #define SDB_DEBUGGING_INFO
129
130 /* We don't want to output DBX debugging information.  */
131
132 #undef DBX_DEBUGGING_INFO
133
134 /* Define the actual types of some ANSI-mandated types.  These
135    definitions should work for most SVR3 systems.  */
136
137 #undef SIZE_TYPE
138 #define SIZE_TYPE "unsigned int"
139
140 #undef PTRDIFF_TYPE
141 #define PTRDIFF_TYPE "int"
142
143 #undef WCHAR_TYPE
144 #define WCHAR_TYPE "long int"
145
146 #undef WCHAR_TYPE_SIZE
147 #define WCHAR_TYPE_SIZE BITS_PER_WORD
148
149 /* Assembler pseudos to introduce constants of various size.  These
150    definitions hsould work for most svr3 systems.  */
151
152 #undef ASM_BYTE_OP
153 #define ASM_BYTE_OP "\t.byte"
154
155 /* This is how to output a reference to a user-level label named NAME.
156    `assemble_name' uses this.
157
158    For System V Release 3 the convention is to prepend a leading
159    underscore onto user-level symbol names.  */
160
161 #undef ASM_OUTPUT_LABELREF
162 #define ASM_OUTPUT_LABELREF(FILE,NAME) fprintf (FILE, "_%s", NAME)
163
164 /* This is how to output an internal numbered label where
165    PREFIX is the class of label and NUM is the number within the class.
166
167    For most svr3 systems, the convention is that any symbol which begins
168    with a period is not put into the linker symbol table by the assembler.  */
169
170 #undef ASM_OUTPUT_INTERNAL_LABEL
171 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)      \
172   asm_fprintf (FILE, "%0L%s%d:\n", PREFIX, NUM)
173
174 /* This is how to store into the string LABEL
175    the symbol_ref name of an internal numbered label where
176    PREFIX is the class of label and NUM is the number within the class.
177    This is suitable for output with `assemble_name'.
178
179    For most svr3 systems, the convention is that any symbol which begins
180    with a period is not put into the linker symbol table by the assembler.  */
181
182 #undef ASM_GENERATE_INTERNAL_LABEL
183 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
184   sprintf (LABEL, "*%s%s%d", LOCAL_LABEL_PREFIX, PREFIX, NUM)
185
186 /* We want local labels to start with period if made with asm_fprintf.  */
187 #undef LOCAL_LABEL_PREFIX
188 #define LOCAL_LABEL_PREFIX "."
189
190 /* Support const sections and the ctors and dtors sections for g++.
191    Note that there appears to be two different ways to support const
192    sections at the moment.  You can either #define the symbol
193    READONLY_DATA_SECTION (giving it some code which switches to the
194    readonly data section) or else you can #define the symbols
195    EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
196    SELECT_RTX_SECTION.  We do both here just to be on the safe side.
197    However, use of the const section is turned off by default
198    unless the specific tm.h file turns it on by defining
199    USE_CONST_SECTION as 1.  */
200
201 /* Define a few machine-specific details of the implementation of
202    constructors.
203
204    The __CTORS_LIST__ goes in the .init section.  Define CTOR_LIST_BEGIN
205    and CTOR_LIST_END to contribute to the .init section an instruction to
206    push a word containing 0 (or some equivalent of that).
207
208    Define ASM_OUTPUT_CONSTRUCTOR to push the address of the constructor.  */
209
210 #define USE_CONST_SECTION       0
211
212 #define INIT_SECTION_ASM_OP     ".section\t.init"
213 #define FINI_SECTION_ASM_OP     ".section .fini,\"x\""
214 #define CONST_SECTION_ASM_OP    ".section\t.rodata, \"x\""
215 #define CTORS_SECTION_ASM_OP    INIT_SECTION_ASM_OP
216 #define DTORS_SECTION_ASM_OP    FINI_SECTION_ASM_OP
217
218 /* CTOR_LIST_BEGIN and CTOR_LIST_END are machine-dependent
219    because they push on the stack.  */
220
221 #ifdef STACK_GROWS_DOWNWARD
222
223 /* Constructor list on stack is in reverse order.  Go to the end of the
224    list and go backwards to call constructors in the right order.  */
225 #define DO_GLOBAL_CTORS_BODY                                    \
226 do {                                                            \
227   func_ptr *p, *beg = alloca (0);                               \
228   for (p = beg; *p; p++)                                        \
229     ;                                                           \
230   while (p != beg)                                              \
231     (*--p) ();                                                  \
232 } while (0)
233
234 #else
235
236 /* Constructor list on stack is in correct order.  Just call them.  */
237 #define DO_GLOBAL_CTORS_BODY                                    \
238 do {                                                            \
239   func_ptr *p, *beg = alloca (0);                               \
240   for (p = beg; *p; )                                           \
241     (*p++) ();                                                  \
242 } while (0)
243
244 #endif /* STACK_GROWS_DOWNWARD */
245
246 /* Add extra sections .init and .fini, in addition to .bss from att386.h. */
247
248 #undef EXTRA_SECTIONS
249 #define EXTRA_SECTIONS in_const, in_bss, in_init, in_fini
250
251 #undef EXTRA_SECTION_FUNCTIONS
252 #define EXTRA_SECTION_FUNCTIONS                                 \
253   CONST_SECTION_FUNCTION                                        \
254   BSS_SECTION_FUNCTION                                          \
255   INIT_SECTION_FUNCTION                                         \
256   FINI_SECTION_FUNCTION
257
258 #define BSS_SECTION_FUNCTION                                    \
259 void                                                            \
260 bss_section ()                                                  \
261 {                                                               \
262   if (in_section != in_bss)                                     \
263     {                                                           \
264       fprintf (asm_out_file, "\t%s\n", BSS_SECTION_ASM_OP);     \
265       in_section = in_bss;                                      \
266     }                                                           \
267 }
268
269 #define INIT_SECTION_FUNCTION                                   \
270 void                                                            \
271 init_section ()                                                 \
272 {                                                               \
273   if (in_section != in_init)                                    \
274     {                                                           \
275       fprintf (asm_out_file, "\t%s\n", INIT_SECTION_ASM_OP);    \
276       in_section = in_init;                                     \
277     }                                                           \
278 }
279
280 #define FINI_SECTION_FUNCTION                                   \
281 void                                                            \
282 fini_section ()                                                 \
283 {                                                               \
284   if (in_section != in_fini)                                    \
285     {                                                           \
286       fprintf (asm_out_file, "\t%s\n", FINI_SECTION_ASM_OP);    \
287       in_section = in_fini;                                     \
288     }                                                           \
289 }
290
291 #define READONLY_DATA_SECTION() const_section ()
292
293 #define CONST_SECTION_FUNCTION                                          \
294 void                                                                    \
295 const_section ()                                                        \
296 {                                                                       \
297   extern void text_section();                                           \
298   if (!USE_CONST_SECTION)                                               \
299     text_section();                                                     \
300   else if (in_section != in_const)                                      \
301     {                                                                   \
302       fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);             \
303       in_section = in_const;                                            \
304     }                                                                   \
305 }
306
307 /* The ctors and dtors sections are not normally put into use 
308    by EXTRA_SECTIONS and EXTRA_SECTION_FUNCTIONS as defined in svr3.h,
309    but it can't hurt to define these macros for whatever systems use them.  */
310 #define CTORS_SECTION_FUNCTION                                          \
311 void                                                                    \
312 ctors_section ()                                                        \
313 {                                                                       \
314   if (in_section != in_ctors)                                           \
315     {                                                                   \
316       fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);             \
317       in_section = in_ctors;                                            \
318     }                                                                   \
319 }
320
321 #define DTORS_SECTION_FUNCTION                                          \
322 void                                                                    \
323 dtors_section ()                                                        \
324 {                                                                       \
325   if (in_section != in_dtors)                                           \
326     {                                                                   \
327       fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);             \
328       in_section = in_dtors;                                            \
329     }                                                                   \
330 }
331
332 /* This is machine-dependent
333    because it needs to push something on the stack.  */
334 #undef ASM_OUTPUT_CONSTRUCTOR
335
336 /* A C statement (sans semicolon) to output an element in the table of
337    global destructors.  */
338 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                                \
339   do {                                                                  \
340     fini_section ();                                            \
341     fprintf (FILE, "%s\t ", ASM_LONG);                                  \
342     assemble_name (FILE, NAME);                                         \
343     fprintf (FILE, "\n");                                               \
344   } while (0)
345
346 /* A C statement or statements to switch to the appropriate
347    section for output of DECL.  DECL is either a `VAR_DECL' node
348    or a constant of some sort.  RELOC indicates whether forming
349    the initial value of DECL requires link-time relocations.  */
350
351 #define SELECT_SECTION(DECL,RELOC)                                      \
352 {                                                                       \
353   if (TREE_CODE (DECL) == STRING_CST)                                   \
354     {                                                                   \
355       if (! flag_writable_strings)                                      \
356         const_section ();                                               \
357       else                                                              \
358         data_section ();                                                \
359     }                                                                   \
360   else if (TREE_CODE (DECL) == VAR_DECL)                                \
361     {                                                                   \
362       if ((0 && RELOC)  /* should be (flag_pic && RELOC) */             \
363           || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL))         \
364         data_section ();                                                \
365       else                                                              \
366         const_section ();                                               \
367     }                                                                   \
368   else                                                                  \
369     const_section ();                                                   \
370 }
371
372 /* A C statement or statements to switch to the appropriate
373    section for output of RTX in mode MODE.  RTX is some kind
374    of constant in RTL.  The argument MODE is redundant except
375    in the case of a `const_int' rtx.  Currently, these always
376    go into the const section.  */
377
378 #define SELECT_RTX_SECTION(MODE,RTX) const_section()