OSDN Git Service

* i386/linux.h (STACK_BOUNDARY): Define as 64 for glibc2.
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / linux.h
1 /* Definitions for Intel 386 running Linux-based GNU systems with ELF format.
2    Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
3    Contributed by Eric Youngdale.
4    Modified for stabs-in-ELF by H.J. Lu.
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, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23 #define LINUX_DEFAULT_ELF
24
25 /* A lie, I guess, but the general idea behind linux/ELF is that we are
26    supposed to be outputting something that will assemble under SVr4.
27    This gets us pretty close.  */
28 #include <i386/i386.h>  /* Base i386 target machine definitions */
29 #include <i386/att.h>   /* Use the i386 AT&T assembler syntax */
30 #include <linux.h>      /* some common stuff */
31
32 #undef TARGET_VERSION
33 #define TARGET_VERSION fprintf (stderr, " (i386 GNU/Linux with ELF)");
34
35 /* The svr4 ABI for the i386 says that records and unions are returned
36    in memory.  */
37 #undef DEFAULT_PCC_STRUCT_RETURN
38 #define DEFAULT_PCC_STRUCT_RETURN 1
39
40 #ifndef USE_GNULIBC_1
41 #undef STACK_BOUNDARY
42 #define STACK_BOUNDARY 64       /* glibc2's crt ensures this, libc5
43                                    only gives you 32 */
44 #endif
45
46 /* This is how to output an element of a case-vector that is relative.
47    This is only used for PIC code.  See comments by the `casesi' insn in
48    i386.md for an explanation of the expression this outputs. */
49 #undef ASM_OUTPUT_ADDR_DIFF_ELT
50 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
51   fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
52
53 /* Indicate that jump tables go in the text section.  This is
54    necessary when compiling PIC code.  */
55 #define JUMP_TABLES_IN_TEXT_SECTION
56
57 /* Copy this from the svr4 specifications... */
58 /* Define the register numbers to be used in Dwarf debugging information.
59    The SVR4 reference port C compiler uses the following register numbers
60    in its Dwarf output code:
61         0 for %eax (gnu regno = 0)
62         1 for %ecx (gnu regno = 2)
63         2 for %edx (gnu regno = 1)
64         3 for %ebx (gnu regno = 3)
65         4 for %esp (gnu regno = 7)
66         5 for %ebp (gnu regno = 6)
67         6 for %esi (gnu regno = 4)
68         7 for %edi (gnu regno = 5)
69    The following three DWARF register numbers are never generated by
70    the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4
71    believes these numbers have these meanings.
72         8  for %eip    (no gnu equivalent)
73         9  for %eflags (no gnu equivalent)
74         10 for %trapno (no gnu equivalent)
75    It is not at all clear how we should number the FP stack registers
76    for the x86 architecture.  If the version of SDB on x86/svr4 were
77    a bit less brain dead with respect to floating-point then we would
78    have a precedent to follow with respect to DWARF register numbers
79    for x86 FP registers, but the SDB on x86/svr4 is so completely
80    broken with respect to FP registers that it is hardly worth thinking
81    of it as something to strive for compatibility with.
82    The version of x86/svr4 SDB I have at the moment does (partially)
83    seem to believe that DWARF register number 11 is associated with
84    the x86 register %st(0), but that's about all.  Higher DWARF
85    register numbers don't seem to be associated with anything in
86    particular, and even for DWARF regno 11, SDB only seems to under-
87    stand that it should say that a variable lives in %st(0) (when
88    asked via an `=' command) if we said it was in DWARF regno 11,
89    but SDB still prints garbage when asked for the value of the
90    variable in question (via a `/' command).
91    (Also note that the labels SDB prints for various FP stack regs
92    when doing an `x' command are all wrong.)
93    Note that these problems generally don't affect the native SVR4
94    C compiler because it doesn't allow the use of -O with -g and
95    because when it is *not* optimizing, it allocates a memory
96    location for each floating-point variable, and the memory
97    location is what gets described in the DWARF AT_location
98    attribute for the variable in question.
99    Regardless of the severe mental illness of the x86/svr4 SDB, we
100    do something sensible here and we use the following DWARF
101    register numbers.  Note that these are all stack-top-relative
102    numbers.
103         11 for %st(0) (gnu regno = 8)
104         12 for %st(1) (gnu regno = 9)
105         13 for %st(2) (gnu regno = 10)
106         14 for %st(3) (gnu regno = 11)
107         15 for %st(4) (gnu regno = 12)
108         16 for %st(5) (gnu regno = 13)
109         17 for %st(6) (gnu regno = 14)
110         18 for %st(7) (gnu regno = 15)
111 */
112 #undef DBX_REGISTER_NUMBER
113 #define DBX_REGISTER_NUMBER(n) \
114 ((n) == 0 ? 0 \
115  : (n) == 1 ? 2 \
116  : (n) == 2 ? 1 \
117  : (n) == 3 ? 3 \
118  : (n) == 4 ? 6 \
119  : (n) == 5 ? 7 \
120  : (n) == 6 ? 5 \
121  : (n) == 7 ? 4 \
122  : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \
123  : (-1))
124
125 /* Output assembler code to FILE to increment profiler label # LABELNO
126    for profiling a function entry.  */
127
128 #undef FUNCTION_PROFILER
129 #define FUNCTION_PROFILER(FILE, LABELNO)  \
130 {                                                                       \
131   if (flag_pic)                                                         \
132     {                                                                   \
133       fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n",              \
134                LPREFIX, (LABELNO));                                     \
135       fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n");                    \
136     }                                                                   \
137   else                                                                  \
138     {                                                                   \
139       fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO));      \
140       fprintf (FILE, "\tcall mcount\n");                                \
141     }                                                                   \
142 }
143
144 #undef SIZE_TYPE
145 #define SIZE_TYPE "unsigned int"
146  
147 #undef PTRDIFF_TYPE
148 #define PTRDIFF_TYPE "int"
149   
150 #undef WCHAR_TYPE
151 #define WCHAR_TYPE "long int"
152    
153 #undef WCHAR_TYPE_SIZE
154 #define WCHAR_TYPE_SIZE BITS_PER_WORD
155     
156 #undef CPP_PREDEFINES
157 #define CPP_PREDEFINES "-D__ELF__ -Dunix -Dlinux -Asystem(posix)"
158
159 #undef CPP_SPEC
160 #ifdef USE_GNULIBC_1
161 #define CPP_SPEC "%(cpp_cpu) %[cpp_cpu] %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}"
162 #else
163 #define CPP_SPEC "%(cpp_cpu) %[cpp_cpu] %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
164 #endif
165
166 #undef CC1_SPEC
167 #define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
168
169 /* Provide a LINK_SPEC appropriate for GNU/Linux.  Here we provide support
170    for the special GCC options -static and -shared, which allow us to
171    link things in one of these three modes by applying the appropriate
172    combinations of options at link-time. We like to support here for
173    as many of the other GNU linker options as possible. But I don't
174    have the time to search for those flags. I am sure how to add
175    support for -soname shared_object_name. H.J.
176
177    I took out %{v:%{!V:-V}}. It is too much :-(. They can use
178    -Wl,-V.
179
180    When the -shared link option is used a final link is not being
181    done.  */
182
183 /* If ELF is the default format, we should not use /lib/elf. */
184
185 #undef  LINK_SPEC
186 #ifdef USE_GNULIBC_1
187 #ifndef LINUX_DEFAULT_ELF
188 #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
189   %{!shared: \
190     %{!ibcs: \
191       %{!static: \
192         %{rdynamic:-export-dynamic} \
193         %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \
194         %{!rpath:-rpath /lib/elf/}} %{static:-static}}}"
195 #else
196 #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
197   %{!shared: \
198     %{!ibcs: \
199       %{!static: \
200         %{rdynamic:-export-dynamic} \
201         %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
202         %{static:-static}}}"
203 #endif
204 #else
205 #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
206   %{!shared: \
207     %{!ibcs: \
208       %{!static: \
209         %{rdynamic:-export-dynamic} \
210         %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
211         %{static:-static}}}"
212 #endif
213
214 /* Get perform_* macros to build libgcc.a.  */
215 #include "i386/perform.h"
216
217 /* A C statement (sans semicolon) to output to the stdio stream
218    FILE the assembler definition of uninitialized global DECL named
219    NAME whose size is SIZE bytes and alignment is ALIGN bytes.
220    Try to use asm_output_aligned_bss to implement this macro.  */
221
222 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
223   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)