|
|
1.1 root 1: /* Definitions for Intel 386 running system V, using gas.
2: Copyright (C) 1992 Free Software Foundation, Inc.
3:
4: This file is part of GNU CC.
5:
6: GNU CC is free software; you can redistribute it and/or modify
7: it under the terms of the GNU General Public License as published by
8: the Free Software Foundation; either version 2, or (at your option)
9: any later version.
10:
11: GNU CC is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU General Public License for more details.
15:
16: You should have received a copy of the GNU General Public License
17: along with GNU CC; see the file COPYING. If not, write to
18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19:
20: #include "i386/gas.h"
21:
22: /* Add stuff that normally comes from i386/sysv3.h */
23:
24: /* longjmp may fail to restore the registers if called from the same
25: function that called setjmp. To compensate, the compiler avoids
26: putting variables in registers in functions that use both setjmp
27: and longjmp. */
28:
29: #define NON_SAVING_SETJMP \
30: (current_function_calls_setjmp && current_function_calls_longjmp)
31:
32: /* longjmp may fail to restore the stack pointer if the saved frame
33: pointer is the same as the caller's frame pointer. Requiring a frame
34: pointer in any function that calls setjmp or longjmp avoids this
35: problem, unless setjmp and longjmp are called from the same function.
36: Since a frame pointer will be required in such a function, it is OK
37: that the stack pointer is not restored. */
38:
39: #undef FRAME_POINTER_REQUIRED
40: #define FRAME_POINTER_REQUIRED \
41: (current_function_calls_setjmp || current_function_calls_longjmp)
42:
43: /* Modify ASM_OUTPUT_LOCAL slightly to test -msvr3-shlib, adapted to gas */
44: #undef ASM_OUTPUT_LOCAL
45: #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
46: do { \
47: int align = exact_log2 (ROUNDED); \
48: if (align > 2) align = 2; \
49: if (TARGET_SVR3_SHLIB) \
50: { \
51: data_section (); \
52: ASM_OUTPUT_ALIGN ((FILE), align == -1 ? 2 : align); \
53: ASM_OUTPUT_LABEL ((FILE), (NAME)); \
54: fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED)); \
55: } \
56: else \
57: { \
58: fputs (".lcomm ", (FILE)); \
59: assemble_name ((FILE), (NAME)); \
60: fprintf ((FILE), ",%u\n", (ROUNDED)); \
61: } \
62: } while (0)
63:
64: /* Add stuff that normally comes from i386/sysv3.h via svr3.h */
65:
66: /* Define the actual types of some ANSI-mandated types. These
67: definitions should work for most SVR3 systems. */
68:
69: #undef SIZE_TYPE
70: #define SIZE_TYPE "unsigned int"
71:
72: #undef PTRDIFF_TYPE
73: #define PTRDIFF_TYPE "int"
74:
75: #undef WCHAR_TYPE
76: #define WCHAR_TYPE "long int"
77:
78: #undef WCHAR_TYPE_SIZE
79: #define WCHAR_TYPE_SIZE BITS_PER_WORD
80:
81: /* ??? This stuff is copied from config/svr3.h. In the future,
82: this file should be rewritten to include config/svr3.h
83: and override what isn't right. */
84:
85: /* Support const sections and the ctors and dtors sections for g++.
86: Note that there appears to be two different ways to support const
87: sections at the moment. You can either #define the symbol
88: READONLY_DATA_SECTION (giving it some code which switches to the
89: readonly data section) or else you can #define the symbols
90: EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
91: SELECT_RTX_SECTION. We do both here just to be on the safe side.
92: However, use of the const section is turned off by default
93: unless the specific tm.h file turns it on by defining
94: USE_CONST_SECTION as 1. */
95:
96: /* Define a few machine-specific details of the implementation of
97: constructors.
98:
99: The __CTORS_LIST__ goes in the .init section. Define CTOR_LIST_BEGIN
100: and CTOR_LIST_END to contribute to the .init section an instruction to
101: push a word containing 0 (or some equivalent of that).
102:
103: Define ASM_OUTPUT_CONSTRUCTOR to push the address of the constructor. */
104:
105: #define USE_CONST_SECTION 0
106:
107: #define INIT_SECTION_ASM_OP ".section\t.init"
108: #define FINI_SECTION_ASM_OP ".section .fini,\"x\""
109: #define CONST_SECTION_ASM_OP ".section\t.rodata, \"x\""
110: #define CTORS_SECTION_ASM_OP INIT_SECTION_ASM_OP
111: #define DTORS_SECTION_ASM_OP FINI_SECTION_ASM_OP
112:
113: /* CTOR_LIST_BEGIN and CTOR_LIST_END are machine-dependent
114: because they push on the stack. */
115:
116: #ifdef STACK_GROWS_DOWNWARD
117:
118: /* Constructor list on stack is in reverse order. Go to the end of the
119: list and go backwards to call constructors in the right order. */
120: #define DO_GLOBAL_CTORS_BODY \
121: do { \
122: func_ptr *p, *beg = alloca (0); \
123: for (p = beg; *p; p++) \
124: ; \
125: while (p != beg) \
126: (*--p) (); \
127: } while (0)
128:
129: #else
130:
131: /* Constructor list on stack is in correct order. Just call them. */
132: #define DO_GLOBAL_CTORS_BODY \
133: do { \
134: func_ptr *p, *beg = alloca (0); \
135: for (p = beg; *p; ) \
136: (*p++) (); \
137: } while (0)
138:
139: #endif /* STACK_GROWS_DOWNWARD */
140:
141: /* Add extra sections .init and .fini, in addition to .bss from att386.h. */
142:
143: #undef EXTRA_SECTIONS
144: #define EXTRA_SECTIONS in_const, in_bss, in_init, in_fini
145:
146: #undef EXTRA_SECTION_FUNCTIONS
147: #define EXTRA_SECTION_FUNCTIONS \
148: CONST_SECTION_FUNCTION \
149: BSS_SECTION_FUNCTION \
150: INIT_SECTION_FUNCTION \
151: FINI_SECTION_FUNCTION
152:
153: #define BSS_SECTION_FUNCTION \
154: void \
155: bss_section () \
156: { \
157: if (in_section != in_bss) \
158: { \
159: fprintf (asm_out_file, "\t%s\n", BSS_SECTION_ASM_OP); \
160: in_section = in_bss; \
161: } \
162: }
163:
164: #define INIT_SECTION_FUNCTION \
165: void \
166: init_section () \
167: { \
168: if (in_section != in_init) \
169: { \
170: fprintf (asm_out_file, "\t%s\n", INIT_SECTION_ASM_OP); \
171: in_section = in_init; \
172: } \
173: }
174:
175: #define FINI_SECTION_FUNCTION \
176: void \
177: fini_section () \
178: { \
179: if (in_section != in_fini) \
180: { \
181: fprintf (asm_out_file, "\t%s\n", FINI_SECTION_ASM_OP); \
182: in_section = in_fini; \
183: } \
184: }
185:
186: #define READONLY_DATA_SECTION() const_section ()
187:
188: #define CONST_SECTION_FUNCTION \
189: void \
190: const_section () \
191: { \
192: extern void text_section(); \
193: if (!USE_CONST_SECTION) \
194: text_section(); \
195: else if (in_section != in_const) \
196: { \
197: fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
198: in_section = in_const; \
199: } \
200: }
201:
202: /* The ctors and dtors sections are not normally put into use
203: by EXTRA_SECTIONS and EXTRA_SECTION_FUNCTIONS as defined in svr3.h,
204: but it can't hurt to define these macros for whatever systems use them. */
205: #define CTORS_SECTION_FUNCTION \
206: void \
207: ctors_section () \
208: { \
209: if (in_section != in_ctors) \
210: { \
211: fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
212: in_section = in_ctors; \
213: } \
214: }
215:
216: #define DTORS_SECTION_FUNCTION \
217: void \
218: dtors_section () \
219: { \
220: if (in_section != in_dtors) \
221: { \
222: fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
223: in_section = in_dtors; \
224: } \
225: }
226:
227: /* This is machine-dependent
228: because it needs to push something on the stack. */
229: #undef ASM_OUTPUT_CONSTRUCTOR
230:
231: /* A C statement (sans semicolon) to output an element in the table of
232: global destructors. */
233: #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
234: do { \
235: fini_section (); \
236: fprintf (FILE, "%s\t ", ASM_LONG); \
237: assemble_name (FILE, NAME); \
238: fprintf (FILE, "\n"); \
239: } while (0)
240:
241: /* A C statement or statements to switch to the appropriate
242: section for output of DECL. DECL is either a `VAR_DECL' node
243: or a constant of some sort. RELOC indicates whether forming
244: the initial value of DECL requires link-time relocations. */
245:
246: #define SELECT_SECTION(DECL,RELOC) \
247: { \
248: if (TREE_CODE (DECL) == STRING_CST) \
249: { \
250: if (! flag_writable_strings) \
251: const_section (); \
252: else \
253: data_section (); \
254: } \
255: else if (TREE_CODE (DECL) == VAR_DECL) \
256: { \
257: if ((0 && RELOC) /* should be (flag_pic && RELOC) */ \
258: || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)) \
259: data_section (); \
260: else \
261: const_section (); \
262: } \
263: else \
264: const_section (); \
265: }
266:
267: /* A C statement or statements to switch to the appropriate
268: section for output of RTX in mode MODE. RTX is some kind
269: of constant in RTL. The argument MODE is redundant except
270: in the case of a `const_int' rtx. Currently, these always
271: go into the const section. */
272:
273: #define SELECT_RTX_SECTION(MODE,RTX) const_section()
274:
275: /* This is copied from i386/sysv3.h. */
276:
277: /* Define a few machine-specific details of the implementation of
278: constructors.
279:
280: The __CTORS_LIST__ goes in the .init section. Define CTOR_LIST_BEGIN
281: and CTOR_LIST_END to contribute to the .init section an instruction to
282: push a word containing 0 (or some equivalent of that).
283:
284: ASM_OUTPUT_CONSTRUCTOR should be defined to push the address of the
285: constructor. */
286:
287: #undef INIT_SECTION_ASM_OP
288: #define INIT_SECTION_ASM_OP ".section .init,\"x\""
289:
290: #define CTOR_LIST_BEGIN \
291: asm (INIT_SECTION_ASM_OP); \
292: asm ("pushl $0")
293: #define CTOR_LIST_END CTOR_LIST_BEGIN
294:
295: #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
296: do { \
297: init_section (); \
298: fprintf (FILE, "\tpushl $"); \
299: assemble_name (FILE, NAME); \
300: fprintf (FILE, "\n"); \
301: } while (0)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.