Move 'temporary' bits so they don't conflict with windows/cygwin/dgux bits
[official-gcc.git] / gcc / config / i386 / freebsd-elf.h
blobe97d4ca07bb269d29be8aa3c194a4cf1fce5c729
1 /* Definitions for Intel 386 running FreeBSD with ELF format
2 Copyright (C) 1996 Free Software Foundation, Inc.
3 Contributed by Eric Youngdale.
4 Modified for stabs-in-ELF by H.J. Lu.
5 Adapted from GNU/Linux version by John Polstra.
6 Continued development by David O'Brien <obrien@freebsd.org>
8 This file is part of GNU CC.
10 GNU CC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
15 GNU CC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GNU CC; see the file COPYING. If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
25 #undef TARGET_VERSION
26 #define TARGET_VERSION fprintf (stderr, " (i386 FreeBSD/ELF)");
28 /* The svr4 ABI for the i386 says that records and unions are returned
29 in memory. */
30 /* On FreeBSD, we do not. */
31 #undef DEFAULT_PCC_STRUCT_RETURN
32 #define DEFAULT_PCC_STRUCT_RETURN 0
34 /* This gets defined in tm.h->linux.h->svr4.h, and keeps us from using
35 libraries compiled with the native cc, so undef it. */
36 #undef NO_DOLLAR_IN_LABEL
38 /* Use more efficient ``thunks'' to implement C++ vtables. */
39 #undef DEFAULT_VTABLE_THUNKS
40 #define DEFAULT_VTABLE_THUNKS 1
42 /* Override the default comment-starter of "/". */
43 #undef ASM_COMMENT_START
44 #define ASM_COMMENT_START "#"
46 #undef ASM_APP_ON
47 #define ASM_APP_ON "#APP\n"
49 #undef ASM_APP_OFF
50 #define ASM_APP_OFF "#NO_APP\n"
52 #undef SET_ASM_OP
53 #define SET_ASM_OP ".set"
55 /* This is how to output an element of a case-vector that is relative.
56 This is only used for PIC code. See comments by the `casesi' insn in
57 i386.md for an explanation of the expression this outputs. */
58 #undef ASM_OUTPUT_ADDR_DIFF_ELT
59 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
60 fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
62 /* Indicate that jump tables go in the text section. This is
63 necessary when compiling PIC code. */
64 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
66 /* Use stabs instead of DWARF debug format. */
67 #undef PREFERRED_DEBUGGING_TYPE
68 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
70 /* Copy this from the svr4 specifications... */
71 /* Define the register numbers to be used in Dwarf debugging information.
72 The SVR4 reference port C compiler uses the following register numbers
73 in its Dwarf output code:
74 0 for %eax (gnu regno = 0)
75 1 for %ecx (gnu regno = 2)
76 2 for %edx (gnu regno = 1)
77 3 for %ebx (gnu regno = 3)
78 4 for %esp (gnu regno = 7)
79 5 for %ebp (gnu regno = 6)
80 6 for %esi (gnu regno = 4)
81 7 for %edi (gnu regno = 5)
82 The following three DWARF register numbers are never generated by
83 the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4
84 believes these numbers have these meanings.
85 8 for %eip (no gnu equivalent)
86 9 for %eflags (no gnu equivalent)
87 10 for %trapno (no gnu equivalent)
88 It is not at all clear how we should number the FP stack registers
89 for the x86 architecture. If the version of SDB on x86/svr4 were
90 a bit less brain dead with respect to floating-point then we would
91 have a precedent to follow with respect to DWARF register numbers
92 for x86 FP registers, but the SDB on x86/svr4 is so completely
93 broken with respect to FP registers that it is hardly worth thinking
94 of it as something to strive for compatibility with.
95 The version of x86/svr4 SDB I have at the moment does (partially)
96 seem to believe that DWARF register number 11 is associated with
97 the x86 register %st(0), but that's about all. Higher DWARF
98 register numbers don't seem to be associated with anything in
99 particular, and even for DWARF regno 11, SDB only seems to under-
100 stand that it should say that a variable lives in %st(0) (when
101 asked via an `=' command) if we said it was in DWARF regno 11,
102 but SDB still prints garbage when asked for the value of the
103 variable in question (via a `/' command).
104 (Also note that the labels SDB prints for various FP stack regs
105 when doing an `x' command are all wrong.)
106 Note that these problems generally don't affect the native SVR4
107 C compiler because it doesn't allow the use of -O with -g and
108 because when it is *not* optimizing, it allocates a memory
109 location for each floating-point variable, and the memory
110 location is what gets described in the DWARF AT_location
111 attribute for the variable in question.
112 Regardless of the severe mental illness of the x86/svr4 SDB, we
113 do something sensible here and we use the following DWARF
114 register numbers. Note that these are all stack-top-relative
115 numbers.
116 11 for %st(0) (gnu regno = 8)
117 12 for %st(1) (gnu regno = 9)
118 13 for %st(2) (gnu regno = 10)
119 14 for %st(3) (gnu regno = 11)
120 15 for %st(4) (gnu regno = 12)
121 16 for %st(5) (gnu regno = 13)
122 17 for %st(6) (gnu regno = 14)
123 18 for %st(7) (gnu regno = 15)
125 #undef DBX_REGISTER_NUMBER
126 #define DBX_REGISTER_NUMBER(n) \
127 ((n) == 0 ? 0 \
128 : (n) == 1 ? 2 \
129 : (n) == 2 ? 1 \
130 : (n) == 3 ? 3 \
131 : (n) == 4 ? 6 \
132 : (n) == 5 ? 7 \
133 : (n) == 6 ? 5 \
134 : (n) == 7 ? 4 \
135 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \
136 : (-1))
138 /* Tell final.c that we don't need a label passed to mcount. */
140 #undef FUNCTION_PROFILER
141 #define FUNCTION_PROFILER(FILE, LABELNO) \
143 if (flag_pic) \
144 fprintf (FILE, "\tcall *.mcount@GOT(%%ebx)\n"); \
145 else \
146 fprintf (FILE, "\tcall .mcount\n"); \
149 #undef SIZE_TYPE
150 #define SIZE_TYPE "unsigned int"
152 #undef PTRDIFF_TYPE
153 #define PTRDIFF_TYPE "int"
155 #undef WCHAR_TYPE
156 #define WCHAR_TYPE "int"
158 #undef WCHAR_UNSIGNED
159 #define WCHAR_UNSIGNED 0
161 #undef WCHAR_TYPE_SIZE
162 #define WCHAR_TYPE_SIZE BITS_PER_WORD
164 #undef CPP_PREDEFINES
165 #define CPP_PREDEFINES "-Di386 -Dunix -D__ELF__ -D__FreeBSD__ -Asystem(unix) -Asystem(FreeBSD) -Acpu(i386) -Amachine(i386)"
167 #undef CPP_SPEC
168 #define CPP_SPEC "%(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}"
170 /* This defines which switch letters take arguments. On FreeBSD, most of
171 the normal cases (defined in gcc.c) apply, and we also have -h* and
172 -z* options (for the linker) (comming from svr4).
173 We also have -R (alias --rpath), no -z, --soname (-h), --assert etc. */
175 #undef SWITCH_TAKES_ARG
176 #define SWITCH_TAKES_ARG(CHAR) \
177 (DEFAULT_SWITCH_TAKES_ARG (CHAR) \
178 || (CHAR) == 'h' \
179 || (CHAR) == 'z' \
180 || (CHAR) == 'R')
182 /* Provide a STARTFILE_SPEC appropriate for FreeBSD. Here we add
183 the magical crtbegin.o file (see crtstuff.c) which provides part
184 of the support for getting C++ file-scope static object constructed
185 before entering `main'. */
187 #undef STARTFILE_SPEC
188 #define STARTFILE_SPEC \
189 "%{!shared: \
190 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
191 %{!p:%{profile:gcrt1.o%s} \
192 %{!profile:crt1.o%s}}}} \
193 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
195 /* Provide a ENDFILE_SPEC appropriate for FreeBSD. Here we tack on
196 the magical crtend.o file (see crtstuff.c) which provides part of
197 the support for getting C++ file-scope static object constructed
198 before entering `main', followed by a normal "finalizer" file,
199 `crtn.o'. */
201 #undef ENDFILE_SPEC
202 #define ENDFILE_SPEC \
203 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
205 /* Provide a LIB_SPEC appropriate for FreeBSD. Just select the appropriate
206 libc, depending on whether we're doing profiling or need threads support.
207 (simular to the default, except no -lg, and no -p. */
209 #undef LIB_SPEC
210 #define LIB_SPEC "%{!shared: \
211 %{!pg:%{!pthread:%{!kthread:-lc} \
212 %{kthread:-lpthread -lc}} \
213 %{pthread:-lc_r}} \
214 %{pg:%{!pthread:%{!kthread:-lc_p} \
215 %{kthread:-lpthread_p -lc_p}} \
216 %{pthread:-lc_r_p}}}"
218 /* Provide a LINK_SPEC appropriate for FreeBSD. Here we provide support
219 for the special GCC options -static and -shared, which allow us to
220 link things in one of these three modes by applying the appropriate
221 combinations of options at link-time. We like to support here for
222 as many of the other GNU linker options as possible. But I don't
223 have the time to search for those flags. I am sure how to add
224 support for -soname shared_object_name. H.J.
226 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
227 -Wl,-V.
229 When the -shared link option is used a final link is not being
230 done. */
232 #undef LINK_SPEC
233 #define LINK_SPEC "-m elf_i386 \
234 %{Wl,*:%*} \
235 %{v:-V} \
236 %{assert*} %{R*} %{rpath*} %{defsym*} \
237 %{shared:-Bshareable %{h*} %{soname*}} \
238 %{!shared: \
239 %{!static: \
240 %{rdynamic:-export-dynamic} \
241 %{!dynamic-linker:-dynamic-linker /usr/libexec/ld-elf.so.1}} \
242 %{static:-Bstatic}} \
243 %{symbolic:-Bsymbolic}"
245 /* A C statement to output to the stdio stream FILE an assembler
246 command to advance the location counter to a multiple of 1<<LOG
247 bytes if it is within MAX_SKIP bytes.
249 This is used to align code labels according to Intel recommendations. */
251 #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
252 #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \
253 if ((LOG) != 0) {\
254 if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
255 else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \
257 #endif