]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/i386/i386elf.h
Opps. -Di386 slipped through. Convert to -D__i386__.
[thirdparty/gcc.git] / gcc / config / i386 / i386elf.h
1 /* Target definitions for GNU compiler for Intel 80386 using ELF
2 Copyright (C) 1988, 1991, 1995 Free Software Foundation, Inc.
3
4 Derived from sysv4.h written by Ron Guilmette (rfg@netcom.com).
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21
22 /* Use stabs instead of DWARF debug format. */
23 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
24
25 #include "i386/i386.h"
26 #include "i386/att.h"
27 #include "elfos.h"
28
29 #undef TARGET_VERSION
30 #define TARGET_VERSION fprintf (stderr, " (i386 bare ELF target)");
31
32 /* By default, target has a 80387, uses IEEE compatible arithmetic,
33 and returns float values in the 387, ie,
34 (TARGET_80387 | TARGET_IEEE_FP | TARGET_FLOAT_RETURNS_IN_80387) */
35
36 #define TARGET_DEFAULT 0301
37
38 /* The svr4 ABI for the i386 says that records and unions are returned
39 in memory. */
40
41 #undef RETURN_IN_MEMORY
42 #define RETURN_IN_MEMORY(TYPE) \
43 (TYPE_MODE (TYPE) == BLKmode)
44
45 /* Define which macros to predefine. __svr4__ is our extension. */
46 /* This used to define X86, but james@bigtex.cactus.org says that
47 is supposed to be defined optionally by user programs--not by default. */
48 #define CPP_PREDEFINES \
49 "-D__i386__ -Acpu(i386) -Amachine(i386)"
50
51 #undef CPP_SPEC
52 #define CPP_SPEC "%(cpp_cpu)"
53
54 /* This is how to output assembly code to define a `float' constant.
55 We always have to use a .long pseudo-op to do this because the native
56 SVR4 ELF assembler is buggy and it generates incorrect values when we
57 try to use the .float pseudo-op instead. */
58
59 #undef ASM_OUTPUT_FLOAT
60 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
61 do { long value; \
62 REAL_VALUE_TO_TARGET_SINGLE ((VALUE), value); \
63 if (sizeof (int) == sizeof (long)) \
64 fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value); \
65 else \
66 fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value); \
67 } while (0)
68
69 /* This is how to output assembly code to define a `double' constant.
70 We always have to use a pair of .long pseudo-ops to do this because
71 the native SVR4 ELF assembler is buggy and it generates incorrect
72 values when we try to use the the .double pseudo-op instead. */
73
74 #undef ASM_OUTPUT_DOUBLE
75 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
76 do { long value[2]; \
77 REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), value); \
78 if (sizeof (int) == sizeof (long)) \
79 { \
80 fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[0]); \
81 fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[1]); \
82 } \
83 else \
84 { \
85 fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value[0]); \
86 fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value[1]); \
87 } \
88 } while (0)
89
90
91 #undef ASM_OUTPUT_LONG_DOUBLE
92 #define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \
93 do { long value[3]; \
94 REAL_VALUE_TO_TARGET_LONG_DOUBLE ((VALUE), value); \
95 if (sizeof (int) == sizeof (long)) \
96 { \
97 fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[0]); \
98 fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[1]); \
99 fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[2]); \
100 } \
101 else \
102 { \
103 fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value[0]); \
104 fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value[1]); \
105 fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value[2]); \
106 } \
107 } while (0)
108
109 /* Output at beginning of assembler file. */
110 /* The .file command should always begin the output. */
111
112 #undef ASM_FILE_START
113 #define ASM_FILE_START(FILE) \
114 do { \
115 output_file_directive (FILE, main_input_filename); \
116 fprintf (FILE, "\t.version\t\"01.01\"\n"); \
117 } while (0)
118
119 /* Define the register numbers to be used in Dwarf debugging information.
120 The SVR4 reference port C compiler uses the following register numbers
121 in its Dwarf output code:
122
123 0 for %eax (gnu regno = 0)
124 1 for %ecx (gnu regno = 2)
125 2 for %edx (gnu regno = 1)
126 3 for %ebx (gnu regno = 3)
127 4 for %esp (gnu regno = 7)
128 5 for %ebp (gnu regno = 6)
129 6 for %esi (gnu regno = 4)
130 7 for %edi (gnu regno = 5)
131
132 The following three DWARF register numbers are never generated by
133 the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4
134 believes these numbers have these meanings.
135
136 8 for %eip (no gnu equivalent)
137 9 for %eflags (no gnu equivalent)
138 10 for %trapno (no gnu equivalent)
139
140 It is not at all clear how we should number the FP stack registers
141 for the x86 architecture. If the version of SDB on x86/svr4 were
142 a bit less brain dead with respect to floating-point then we would
143 have a precedent to follow with respect to DWARF register numbers
144 for x86 FP registers, but the SDB on x86/svr4 is so completely
145 broken with respect to FP registers that it is hardly worth thinking
146 of it as something to strive for compatibility with.
147
148 The verison of x86/svr4 SDB I have at the moment does (partially)
149 seem to believe that DWARF register number 11 is associated with
150 the x86 register %st(0), but that's about all. Higher DWARF
151 register numbers don't seem to be associated with anything in
152 particular, and even for DWARF regno 11, SDB only seems to under-
153 stand that it should say that a variable lives in %st(0) (when
154 asked via an `=' command) if we said it was in DWARF regno 11,
155 but SDB still prints garbage when asked for the value of the
156 variable in question (via a `/' command).
157
158 (Also note that the labels SDB prints for various FP stack regs
159 when doing an `x' command are all wrong.)
160
161 Note that these problems generally don't affect the native SVR4
162 C compiler because it doesn't allow the use of -O with -g and
163 because when it is *not* optimizing, it allocates a memory
164 location for each floating-point variable, and the memory
165 location is what gets described in the DWARF AT_location
166 attribute for the variable in question.
167
168 Regardless of the severe mental illness of the x86/svr4 SDB, we
169 do something sensible here and we use the following DWARF
170 register numbers. Note that these are all stack-top-relative
171 numbers.
172
173 11 for %st(0) (gnu regno = 8)
174 12 for %st(1) (gnu regno = 9)
175 13 for %st(2) (gnu regno = 10)
176 14 for %st(3) (gnu regno = 11)
177 15 for %st(4) (gnu regno = 12)
178 16 for %st(5) (gnu regno = 13)
179 17 for %st(6) (gnu regno = 14)
180 18 for %st(7) (gnu regno = 15)
181 */
182
183 #undef DBX_REGISTER_NUMBER
184 #define DBX_REGISTER_NUMBER(n) \
185 ((n) == 0 ? 0 \
186 : (n) == 1 ? 2 \
187 : (n) == 2 ? 1 \
188 : (n) == 3 ? 3 \
189 : (n) == 4 ? 6 \
190 : (n) == 5 ? 7 \
191 : (n) == 6 ? 5 \
192 : (n) == 7 ? 4 \
193 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \
194 : (-1))
195
196 /* The routine used to output sequences of byte values. We use a special
197 version of this for most svr4 targets because doing so makes the
198 generated assembly code more compact (and thus faster to assemble)
199 as well as more readable. Note that if we find subparts of the
200 character sequence which end with NUL (and which are shorter than
201 STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */
202
203 #undef ASM_OUTPUT_ASCII
204 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
205 do \
206 { \
207 register unsigned char *_ascii_bytes = (unsigned char *) (STR); \
208 register unsigned char *limit = _ascii_bytes + (LENGTH); \
209 register unsigned bytes_in_chunk = 0; \
210 for (; _ascii_bytes < limit; _ascii_bytes++) \
211 { \
212 register unsigned char *p; \
213 if (bytes_in_chunk >= 64) \
214 { \
215 fputc ('\n', (FILE)); \
216 bytes_in_chunk = 0; \
217 } \
218 for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \
219 continue; \
220 if (p < limit && (p - _ascii_bytes) <= STRING_LIMIT) \
221 { \
222 if (bytes_in_chunk > 0) \
223 { \
224 fputc ('\n', (FILE)); \
225 bytes_in_chunk = 0; \
226 } \
227 ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \
228 _ascii_bytes = p; \
229 } \
230 else \
231 { \
232 if (bytes_in_chunk == 0) \
233 fprintf ((FILE), "\t.byte\t"); \
234 else \
235 fputc (',', (FILE)); \
236 fprintf ((FILE), "0x%02x", *_ascii_bytes); \
237 bytes_in_chunk += 5; \
238 } \
239 } \
240 if (bytes_in_chunk > 0) \
241 fprintf ((FILE), "\n"); \
242 } \
243 while (0)
244
245 /* This is how to output an element of a case-vector that is relative.
246 This is only used for PIC code. See comments by the `casesi' insn in
247 i386.md for an explanation of the expression this outputs. */
248
249 #undef ASM_OUTPUT_ADDR_DIFF_ELT
250 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
251 fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
252
253 /* Indicate that jump tables go in the text section. This is
254 necessary when compiling PIC code. */
255
256 #define JUMP_TABLES_IN_TEXT_SECTION 1
257
258 #define LOCAL_LABEL_PREFIX "."
259
260 /* A C statement to output something to the assembler file to switch to section
261 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
262 NULL_TREE. Some target formats do not support arbitrary sections. Do not
263 define this macro in such cases. */
264
265 #undef ASM_OUTPUT_SECTION_NAME
266 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
267 do { \
268 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
269 fprintf (FILE, ".section\t%s,\"ax\"\n", (NAME)); \
270 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
271 fprintf (FILE, ".section\t%s,\"a\"\n", (NAME)); \
272 else \
273 fprintf (FILE, ".section\t%s,\"aw\"\n", (NAME)); \
274 } while (0)
275
276 /* If defined, a C expression whose value is a string containing the
277 assembler operation to identify the following data as
278 uninitialized global data. If not defined, and neither
279 `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
280 uninitialized global data will be output in the data section if
281 `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
282 used. */
283 #undef BSS_SECTION_ASM_OP
284 #define BSS_SECTION_ASM_OP ".section\t.bss"
285
286 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
287 separate, explicit argument. If you define this macro, it is used
288 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
289 handling the required alignment of the variable. The alignment is
290 specified as the number of bits.
291
292 Try to use function `asm_output_aligned_bss' defined in file
293 `varasm.c' when defining this macro. */
294 #undef ASM_OUTPUT_ALIGNED_BSS
295 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
296 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)