OSDN Git Service

(CPP_SPEC): Use %[cpp_cpu].
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / freebsd-elf.h
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 Linux version by John Polstra.
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 #undef TARGET_VERSION
25 #define TARGET_VERSION fprintf (stderr, " (i386 FreeBSD/ELF)");
26
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
31
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)
38
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
42
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)
97 */
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))
110
111 /* Output assembler code to FILE to increment profiler label # LABELNO
112    for profiling a function entry.  */
113
114 #undef FUNCTION_PROFILER
115 #define FUNCTION_PROFILER(FILE, LABELNO)  \
116 {                                                                       \
117   if (flag_pic)                                                         \
118     {                                                                   \
119       fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n",              \
120                LPREFIX, (LABELNO));                                     \
121       fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n");                    \
122     }                                                                   \
123   else                                                                  \
124     {                                                                   \
125       fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO));      \
126       fprintf (FILE, "\tcall mcount\n");                                \
127     }                                                                   \
128 }
129
130 #undef SIZE_TYPE
131 #define SIZE_TYPE "unsigned int"
132  
133 #undef PTRDIFF_TYPE
134 #define PTRDIFF_TYPE "int"
135   
136 #undef WCHAR_TYPE
137 #define WCHAR_TYPE "int"
138    
139 #undef WCHAR_TYPE_SIZE
140 #define WCHAR_TYPE_SIZE BITS_PER_WORD
141     
142 #undef CPP_PREDEFINES
143 #define CPP_PREDEFINES "-Dunix -D__ELF__ -D__FreeBSD__=2 -Asystem(FreeBSD)"
144
145 #undef CPP_SPEC
146 #if TARGET_CPU_DEFAULT == 2
147 #define CPP_SPEC "%(cpp_cpu) %[cpp_cpu] %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}"
148 #else
149 #define CPP_SPEC "%(cpp_cpu) %[cpp_cpu] %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}"
150 #endif
151
152 #undef  LIB_SPEC
153 #if 1
154 /* We no longer link with libc_p.a or libg.a by default. If you
155  * want to profile or debug the C library, please add
156  * -lc_p or -ggdb to LDFLAGS at the link time, respectively.
157  */
158 #define LIB_SPEC \
159   "%{!shared: %{mieee-fp:-lieee} %{p:-lgmon} %{pg:-lgmon} \
160      %{!ggdb:-lc} %{ggdb:-lg}}"
161 #else
162 #define LIB_SPEC \
163   "%{!shared: \
164      %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
165        %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}"
166 #endif
167
168 /* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
169    for the special GCC options -static and -shared, which allow us to
170    link things in one of these three modes by applying the appropriate
171    combinations of options at link-time. We like to support here for
172    as many of the other GNU linker options as possible. But I don't
173    have the time to search for those flags. I am sure how to add
174    support for -soname shared_object_name. H.J.
175
176    I took out %{v:%{!V:-V}}. It is too much :-(. They can use
177    -Wl,-V.
178
179    When the -shared link option is used a final link is not being
180    done.  */
181
182 #undef  LINK_SPEC
183 #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
184   %{!shared: \
185     %{!ibcs: \
186       %{!static: \
187         %{rdynamic:-export-dynamic} \
188         %{!dynamic-linker:-dynamic-linker /usr/libexec/ld-elf.so.1}} \
189         %{static:-static}}}"
190
191 /* Get perform_* macros to build libgcc.a.  */