import of gcc-2.8
[official-gcc.git] / gcc / config / i386 / freebsd-elf.h
blob252ebf5cf846b914d293f241d7cd3ebcceb3b9e1
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.
7 This file is part of GNU CC.
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.
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.
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. */
24 #undef TARGET_VERSION
25 #define TARGET_VERSION fprintf (stderr, " (i386 FreeBSD/ELF)");
27 /* The svr4 ABI for the i386 says that records and unions are returned
28 in memory. */
29 #undef DEFAULT_PCC_STRUCT_RETURN
30 #define DEFAULT_PCC_STRUCT_RETURN 1
32 /* This is how to output an element of a case-vector that is relative.
33 This is only used for PIC code. See comments by the `casesi' insn in
34 i386.md for an explanation of the expression this outputs. */
35 #undef ASM_OUTPUT_ADDR_DIFF_ELT
36 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
37 fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
39 /* Indicate that jump tables go in the text section. This is
40 necessary when compiling PIC code. */
41 #define JUMP_TABLES_IN_TEXT_SECTION
43 /* Copy this from the svr4 specifications... */
44 /* Define the register numbers to be used in Dwarf debugging information.
45 The SVR4 reference port C compiler uses the following register numbers
46 in its Dwarf output code:
47 0 for %eax (gnu regno = 0)
48 1 for %ecx (gnu regno = 2)
49 2 for %edx (gnu regno = 1)
50 3 for %ebx (gnu regno = 3)
51 4 for %esp (gnu regno = 7)
52 5 for %ebp (gnu regno = 6)
53 6 for %esi (gnu regno = 4)
54 7 for %edi (gnu regno = 5)
55 The following three DWARF register numbers are never generated by
56 the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4
57 believes these numbers have these meanings.
58 8 for %eip (no gnu equivalent)
59 9 for %eflags (no gnu equivalent)
60 10 for %trapno (no gnu equivalent)
61 It is not at all clear how we should number the FP stack registers
62 for the x86 architecture. If the version of SDB on x86/svr4 were
63 a bit less brain dead with respect to floating-point then we would
64 have a precedent to follow with respect to DWARF register numbers
65 for x86 FP registers, but the SDB on x86/svr4 is so completely
66 broken with respect to FP registers that it is hardly worth thinking
67 of it as something to strive for compatibility with.
68 The version of x86/svr4 SDB I have at the moment does (partially)
69 seem to believe that DWARF register number 11 is associated with
70 the x86 register %st(0), but that's about all. Higher DWARF
71 register numbers don't seem to be associated with anything in
72 particular, and even for DWARF regno 11, SDB only seems to under-
73 stand that it should say that a variable lives in %st(0) (when
74 asked via an `=' command) if we said it was in DWARF regno 11,
75 but SDB still prints garbage when asked for the value of the
76 variable in question (via a `/' command).
77 (Also note that the labels SDB prints for various FP stack regs
78 when doing an `x' command are all wrong.)
79 Note that these problems generally don't affect the native SVR4
80 C compiler because it doesn't allow the use of -O with -g and
81 because when it is *not* optimizing, it allocates a memory
82 location for each floating-point variable, and the memory
83 location is what gets described in the DWARF AT_location
84 attribute for the variable in question.
85 Regardless of the severe mental illness of the x86/svr4 SDB, we
86 do something sensible here and we use the following DWARF
87 register numbers. Note that these are all stack-top-relative
88 numbers.
89 11 for %st(0) (gnu regno = 8)
90 12 for %st(1) (gnu regno = 9)
91 13 for %st(2) (gnu regno = 10)
92 14 for %st(3) (gnu regno = 11)
93 15 for %st(4) (gnu regno = 12)
94 16 for %st(5) (gnu regno = 13)
95 17 for %st(6) (gnu regno = 14)
96 18 for %st(7) (gnu regno = 15)
98 #undef DBX_REGISTER_NUMBER
99 #define DBX_REGISTER_NUMBER(n) \
100 ((n) == 0 ? 0 \
101 : (n) == 1 ? 2 \
102 : (n) == 2 ? 1 \
103 : (n) == 3 ? 3 \
104 : (n) == 4 ? 6 \
105 : (n) == 5 ? 7 \
106 : (n) == 6 ? 5 \
107 : (n) == 7 ? 4 \
108 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \
109 : (-1))
111 /* Output assembler code to FILE to increment profiler label # LABELNO
112 for profiling a function entry. */
114 #undef FUNCTION_PROFILER
115 #define FUNCTION_PROFILER(FILE, LABELNO) \
117 if (flag_pic) \
119 fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \
120 LPREFIX, (LABELNO)); \
121 fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \
123 else \
125 fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \
126 fprintf (FILE, "\tcall mcount\n"); \
130 #undef SIZE_TYPE
131 #define SIZE_TYPE "unsigned int"
133 #undef PTRDIFF_TYPE
134 #define PTRDIFF_TYPE "int"
136 #undef WCHAR_TYPE
137 #define WCHAR_TYPE "int"
139 #undef WCHAR_TYPE_SIZE
140 #define WCHAR_TYPE_SIZE BITS_PER_WORD
142 #undef CPP_PREDEFINES
143 #define CPP_PREDEFINES "-Dunix -D__ELF__ -D__FreeBSD__=2 -Asystem(FreeBSD)"
145 #undef CPP_SPEC
146 #define CPP_SPEC "%(cpp_cpu) %[cpp_cpu] %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}"
148 #undef LIB_SPEC
149 #if 1
150 /* We no longer link with libc_p.a or libg.a by default. If you
151 * want to profile or debug the C library, please add
152 * -lc_p or -ggdb to LDFLAGS at the link time, respectively.
154 #define LIB_SPEC \
155 "%{!shared: %{mieee-fp:-lieee} %{p:-lgmon} %{pg:-lgmon} \
156 %{!ggdb:-lc} %{ggdb:-lg}}"
157 #else
158 #define LIB_SPEC \
159 "%{!shared: \
160 %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
161 %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}"
162 #endif
164 /* Provide a LINK_SPEC appropriate for FreeBSD. Here we provide support
165 for the special GCC options -static and -shared, which allow us to
166 link things in one of these three modes by applying the appropriate
167 combinations of options at link-time. We like to support here for
168 as many of the other GNU linker options as possible. But I don't
169 have the time to search for those flags. I am sure how to add
170 support for -soname shared_object_name. H.J.
172 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
173 -Wl,-V.
175 When the -shared link option is used a final link is not being
176 done. */
178 #undef LINK_SPEC
179 #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
180 %{!shared: \
181 %{!ibcs: \
182 %{!static: \
183 %{rdynamic:-export-dynamic} \
184 %{!dynamic-linker:-dynamic-linker /usr/libexec/ld-elf.so.1}} \
185 %{static:-static}}}"
187 /* Get perform_* macros to build libgcc.a. */