OSDN Git Service

i * libgcc1-test.c, libgcc1.c, config/i386/perform.h: Delete file.
[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, 1998, 1999, 2001 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 /* Output at beginning of assembler file.  */
26 /* The .file command should always begin the output.  */
27 #undef ASM_FILE_START
28 #define ASM_FILE_START(FILE)                                            \
29   do {                                                                  \
30         output_file_directive (FILE, main_input_filename);              \
31         if (target_flags & MASK_INTEL_SYNTAX)                           \
32           fputs ("\t.intel_syntax\n", FILE);                            \
33   } while (0)
34
35 #undef TARGET_VERSION
36 #define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)");
37
38 /* The svr4 ABI for the i386 says that records and unions are returned
39    in memory.  */
40 #undef DEFAULT_PCC_STRUCT_RETURN
41 #define DEFAULT_PCC_STRUCT_RETURN 1
42
43 #undef ASM_COMMENT_START
44 #define ASM_COMMENT_START "#"
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, BODY, 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 (flag_pic)
56
57 #undef DBX_REGISTER_NUMBER
58 #define DBX_REGISTER_NUMBER(n) \
59   (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
60
61 /* Output assembler code to FILE to call the profiler.
62    To the best of my knowledge, no Linux libc has required the label
63    argument to mcount.  */
64
65 #define NO_PROFILE_COUNTERS
66
67 #undef FUNCTION_PROFILER
68 #define FUNCTION_PROFILER(FILE, LABELNO)  \
69 {                                                                       \
70   if (flag_pic)                                                         \
71     fprintf (FILE, "\tcall\t*mcount@GOT(%%ebx)\n");                     \
72   else                                                                  \
73     fprintf (FILE, "\tcall\tmcount\n");                                 \
74 }
75
76 #undef SIZE_TYPE
77 #define SIZE_TYPE "unsigned int"
78  
79 #undef PTRDIFF_TYPE
80 #define PTRDIFF_TYPE "int"
81   
82 #undef WCHAR_TYPE
83 #define WCHAR_TYPE "long int"
84    
85 #undef WCHAR_TYPE_SIZE
86 #define WCHAR_TYPE_SIZE BITS_PER_WORD
87     
88 #undef CPP_PREDEFINES
89 #define CPP_PREDEFINES "-D__ELF__ -Dunix -Dlinux -Asystem=posix"
90
91 #undef CPP_SPEC
92 #ifdef USE_GNULIBC_1
93 #define CPP_SPEC "%(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}"
94 #else
95 #define CPP_SPEC "%(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
96 #endif
97
98 #undef CC1_SPEC
99 #define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
100
101 /* Provide a LINK_SPEC appropriate for Linux.  Here we provide support
102    for the special GCC options -static and -shared, which allow us to
103    link things in one of these three modes by applying the appropriate
104    combinations of options at link-time. We like to support here for
105    as many of the other GNU linker options as possible. But I don't
106    have the time to search for those flags. I am sure how to add
107    support for -soname shared_object_name. H.J.
108
109    I took out %{v:%{!V:-V}}. It is too much :-(. They can use
110    -Wl,-V.
111
112    When the -shared link option is used a final link is not being
113    done.  */
114
115 /* If ELF is the default format, we should not use /lib/elf. */
116
117 #undef  LINK_SPEC
118 #ifdef USE_GNULIBC_1
119 #ifndef LINUX_DEFAULT_ELF
120 #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
121   %{!shared: \
122     %{!ibcs: \
123       %{!static: \
124         %{rdynamic:-export-dynamic} \
125         %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \
126         %{!rpath:-rpath /lib/elf/}} %{static:-static}}}"
127 #else
128 #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
129   %{!shared: \
130     %{!ibcs: \
131       %{!static: \
132         %{rdynamic:-export-dynamic} \
133         %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
134         %{static:-static}}}"
135 #endif
136 #else
137 #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
138   %{!shared: \
139     %{!ibcs: \
140       %{!static: \
141         %{rdynamic:-export-dynamic} \
142         %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
143         %{static:-static}}}"
144 #endif
145
146 /* A C statement (sans semicolon) to output to the stdio stream
147    FILE the assembler definition of uninitialized global DECL named
148    NAME whose size is SIZE bytes and alignment is ALIGN bytes.
149    Try to use asm_output_aligned_bss to implement this macro.  */
150
151 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
152   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
153
154 /* A C statement to output to the stdio stream FILE an assembler
155    command to advance the location counter to a multiple of 1<<LOG
156    bytes if it is within MAX_SKIP bytes.
157
158    This is used to align code labels according to Intel recommendations.  */
159
160 #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
161 #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)                    \
162   do {                                                                  \
163     if ((LOG) != 0) {                                                   \
164       if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG));  \
165       else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));  \
166     }                                                                   \
167   } while (0)
168 #endif
169
170 #if defined(__PIC__) && defined (USE_GNULIBC_1)
171 /* This is a kludge. The i386 GNU/Linux dynamic linker needs ___brk_addr,
172    __environ and atexit (). We have to make sure they are in the .dynsym
173    section. We accomplish it by making a dummy call here. This
174    code is never reached.  */
175          
176 #define CRT_END_INIT_DUMMY              \
177   do                                    \
178     {                                   \
179       extern void *___brk_addr;         \
180       extern char **__environ;          \
181                                         \
182       ___brk_addr = __environ;          \
183       atexit (0);                       \
184     }                                   \
185   while (0)
186 #endif
187
188 /* Do code reading to identify a signal frame, and set the frame
189    state data appropriately.  See unwind-dw2.c for the structs.  */
190
191 #ifdef IN_LIBGCC2
192 #include <signal.h>
193 #include <sys/ucontext.h>
194 #endif
195
196 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)               \
197   do {                                                                  \
198     unsigned char *pc_ = (CONTEXT)->ra;                                 \
199     struct sigcontext *sc_;                                             \
200     long new_cfa_;                                                      \
201                                                                         \
202     /* popl %eax ; movl $__NR_sigreturn,%eax ; int $0x80  */            \
203     if (*(unsigned short *)(pc_+0) == 0xb858                            \
204         && *(unsigned int *)(pc_+2) == 119                              \
205         && *(unsigned short *)(pc_+6) == 0x80cd)                        \
206       sc_ = (CONTEXT)->cfa + 4;                                         \
207     /* movl $__NR_rt_sigreturn,%eax ; int $0x80  */                     \
208     else if (*(unsigned char *)(pc_+0) == 0xb8                          \
209              && *(unsigned int *)(pc_+1) == 173                         \
210              && *(unsigned short *)(pc_+5) == 0x80cd)                   \
211       {                                                                 \
212         struct rt_sigframe {                                            \
213           int sig;                                                      \
214           struct siginfo *pinfo;                                        \
215           void *puc;                                                    \
216           struct siginfo info;                                          \
217           struct ucontext uc;                                           \
218         } *rt_ = (CONTEXT)->cfa;                                        \
219         sc_ = (struct sigcontext *) &rt_->uc.uc_mcontext;               \
220       }                                                                 \
221     else                                                                \
222       break;                                                            \
223                                                                         \
224     new_cfa_ = sc_->esp;                                                \
225     (FS)->cfa_how = CFA_REG_OFFSET;                                     \
226     (FS)->cfa_reg = 4;                                                  \
227     (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa;                \
228                                                                         \
229     /* The SVR4 register numbering macros aren't usable in libgcc.  */  \
230     (FS)->regs.reg[0].how = REG_SAVED_OFFSET;                           \
231     (FS)->regs.reg[0].loc.offset = (long)&sc_->eax - new_cfa_;          \
232     (FS)->regs.reg[3].how = REG_SAVED_OFFSET;                           \
233     (FS)->regs.reg[3].loc.offset = (long)&sc_->ebx - new_cfa_;          \
234     (FS)->regs.reg[1].how = REG_SAVED_OFFSET;                           \
235     (FS)->regs.reg[1].loc.offset = (long)&sc_->ecx - new_cfa_;          \
236     (FS)->regs.reg[2].how = REG_SAVED_OFFSET;                           \
237     (FS)->regs.reg[2].loc.offset = (long)&sc_->edx - new_cfa_;          \
238     (FS)->regs.reg[6].how = REG_SAVED_OFFSET;                           \
239     (FS)->regs.reg[6].loc.offset = (long)&sc_->esi - new_cfa_;          \
240     (FS)->regs.reg[7].how = REG_SAVED_OFFSET;                           \
241     (FS)->regs.reg[7].loc.offset = (long)&sc_->edi - new_cfa_;          \
242     (FS)->regs.reg[5].how = REG_SAVED_OFFSET;                           \
243     (FS)->regs.reg[5].loc.offset = (long)&sc_->ebp - new_cfa_;          \
244     (FS)->regs.reg[8].how = REG_SAVED_OFFSET;                           \
245     (FS)->regs.reg[8].loc.offset = (long)&sc_->eip - new_cfa_;          \
246     (FS)->retaddr_column = 8;                                           \
247     goto SUCCESS;                                                       \
248   } while (0)