OSDN Git Service

Merge branch 'trunk' of git://gcc.gnu.org/git/gcc into rework
[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, 2002, 2004, 2005,
3    2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4    Contributed by Eric Youngdale.
5    Modified for stabs-in-ELF by H.J. Lu.
6
7 This file is part of GCC.
8
9 GCC 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 3, or (at your option)
12 any later version.
13
14 GCC 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 GCC; see the file COPYING3.  If not see
21 <http://www.gnu.org/licenses/>.  */
22
23 /* Output at beginning of assembler file.  */
24 /* The .file command should always begin the output.  */
25 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
26
27 #define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)");
28
29 /* The svr4 ABI for the i386 says that records and unions are returned
30    in memory.  */
31 #undef DEFAULT_PCC_STRUCT_RETURN
32 #define DEFAULT_PCC_STRUCT_RETURN 1
33
34 /* We arrange for the whole %gs segment to map the tls area.  */
35 #undef TARGET_TLS_DIRECT_SEG_REFS_DEFAULT
36 #define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT MASK_TLS_DIRECT_SEG_REFS
37
38 #undef ASM_COMMENT_START
39 #define ASM_COMMENT_START "#"
40
41 #undef DBX_REGISTER_NUMBER
42 #define DBX_REGISTER_NUMBER(n) \
43   (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
44
45 /* Output assembler code to FILE to call the profiler.
46    To the best of my knowledge, no Linux libc has required the label
47    argument to mcount.  */
48
49 #define NO_PROFILE_COUNTERS     1
50
51 #undef MCOUNT_NAME
52 #define MCOUNT_NAME "mcount"
53
54 /* The GLIBC version of mcount for the x86 assumes that there is a
55    frame, so we cannot allow profiling without a frame pointer.  */
56
57 #undef SUBTARGET_FRAME_POINTER_REQUIRED
58 #define SUBTARGET_FRAME_POINTER_REQUIRED crtl->profile
59
60 #undef SIZE_TYPE
61 #define SIZE_TYPE "unsigned int"
62  
63 #undef PTRDIFF_TYPE
64 #define PTRDIFF_TYPE "int"
65   
66 #undef WCHAR_TYPE
67 #define WCHAR_TYPE "long int"
68    
69 #undef WCHAR_TYPE_SIZE
70 #define WCHAR_TYPE_SIZE BITS_PER_WORD
71     
72 #define TARGET_OS_CPP_BUILTINS()                \
73   do                                            \
74     {                                           \
75         LINUX_TARGET_OS_CPP_BUILTINS();         \
76     }                                           \
77   while (0)
78
79 #undef CPP_SPEC
80 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
81
82 #undef CC1_SPEC
83 #define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
84
85 /* Provide a LINK_SPEC appropriate for Linux.  Here we provide support
86    for the special GCC options -static and -shared, which allow us to
87    link things in one of these three modes by applying the appropriate
88    combinations of options at link-time.
89
90    When the -shared link option is used a final link is not being
91    done.  */
92
93 /* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */
94 #define LINK_EMULATION "elf_i386"
95 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
96
97 #undef  ASM_SPEC
98 #define ASM_SPEC \
99   "%{v} --32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
100
101 #undef  SUBTARGET_EXTRA_SPECS
102 #define SUBTARGET_EXTRA_SPECS \
103   { "link_emulation", LINK_EMULATION },\
104   { "dynamic_linker", LINUX_DYNAMIC_LINKER }
105
106 #undef  LINK_SPEC
107 #define LINK_SPEC "-m %(link_emulation) %{shared:-shared} \
108   %{!shared: \
109     %{!ibcs: \
110       %{!static: \
111         %{rdynamic:-export-dynamic} \
112         %{!dynamic-linker:-dynamic-linker %(dynamic_linker)}} \
113         %{static:-static}}}"
114
115 /* Similar to standard Linux, but adding -ffast-math support.  */
116 #undef  ENDFILE_SPEC
117 #define ENDFILE_SPEC \
118   "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
119    %{mpc32:crtprec32.o%s} \
120    %{mpc64:crtprec64.o%s} \
121    %{mpc80:crtprec80.o%s} \
122    %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
123
124 /* A C statement (sans semicolon) to output to the stdio stream
125    FILE the assembler definition of uninitialized global DECL named
126    NAME whose size is SIZE bytes and alignment is ALIGN bytes.
127    Try to use asm_output_aligned_bss to implement this macro.  */
128
129 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
130   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
131
132 /* A C statement to output to the stdio stream FILE an assembler
133    command to advance the location counter to a multiple of 1<<LOG
134    bytes if it is within MAX_SKIP bytes.
135
136    This is used to align code labels according to Intel recommendations.  */
137
138 #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
139 #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)                    \
140   do {                                                                  \
141     if ((LOG) != 0) {                                                   \
142       if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG));  \
143       else {                                                            \
144         fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));     \
145         /* Make sure that we have at least 8 byte alignment if > 8 byte \
146            alignment is preferred.  */                                  \
147         if ((LOG) > 3                                                   \
148             && (1 << (LOG)) > ((MAX_SKIP) + 1)                          \
149             && (MAX_SKIP) >= 7)                                         \
150           fputs ("\t.p2align 3\n", (FILE));                             \
151       }                                                                 \
152     }                                                                   \
153   } while (0)
154 #endif
155
156 /* Handle special EH pointer encodings.  Absolute, pc-relative, and
157    indirect are handled automatically.  */
158 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
159   do {                                                                  \
160     if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_datarel)         \
161       {                                                                 \
162         fputs (ASM_LONG, FILE);                 \
163         assemble_name (FILE, XSTR (ADDR, 0));                           \
164         fputs (((ENCODING) & DW_EH_PE_indirect ? "@GOT" : "@GOTOFF"), FILE); \
165         goto DONE;                                                      \
166       }                                                                 \
167   } while (0)
168
169 /* Used by crtstuff.c to initialize the base of data-relative relocations.
170    These are GOT relative on x86, so return the pic register.  */
171 #ifdef __PIC__
172 #define CRT_GET_RFIB_DATA(BASE)                 \
173   {                                             \
174     register void *ebx_ __asm__("ebx");         \
175     BASE = ebx_;                                \
176   }
177 #else
178 #define CRT_GET_RFIB_DATA(BASE)                                         \
179   __asm__ ("call\t.LPR%=\n"                                             \
180            ".LPR%=:\n\t"                                                \
181            "pop{l}\t%0\n\t"                                             \
182            /* Due to a GAS bug, this cannot use EAX.  That encodes      \
183               smaller than the traditional EBX, which results in the    \
184               offset being off by one.  */                              \
185            "add{l}\t{$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0"              \
186                    "|%0,_GLOBAL_OFFSET_TABLE_+(.-.LPR%=)}"              \
187            : "=d"(BASE))
188 #endif
189
190 /* Put all *tf routines in libgcc.  */
191 #undef LIBGCC2_HAS_TF_MODE
192 #define LIBGCC2_HAS_TF_MODE 1
193 #define LIBGCC2_TF_CEXT q
194 #define TF_SIZE 113
195
196 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
197
198 #define MD_UNWIND_SUPPORT "config/i386/linux-unwind.h"
199
200 /* The stack pointer needs to be moved while checking the stack.  */
201 #define STACK_CHECK_MOVING_SP 1
202
203 /* Static stack checking is supported by means of probes.  */
204 #define STACK_CHECK_STATIC_BUILTIN 1
205
206 /* This macro may be overridden in i386/k*bsd-gnu.h.  */
207 #define REG_NAME(reg) reg
208
209 #ifdef TARGET_LIBC_PROVIDES_SSP
210 /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
211 #define TARGET_THREAD_SSP_OFFSET        0x14
212
213 /* We steal the last transactional memory word.  */
214 #define TARGET_CAN_SPLIT_STACK
215 #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
216 #endif