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