OSDN Git Service

alloc-pool.c, c-lex.c, c-pragma.h, c-semantics.c, cfghooks.c,
[pf3gnuchains/gcc-fork.git] / gcc / config / mips / linux.h
1 /* Definitions for MIPS running Linux-based GNU systems with ELF format.
2    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
3    Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 #undef WCHAR_TYPE
23 #define WCHAR_TYPE "int"
24
25 #undef WCHAR_TYPE_SIZE
26 #define WCHAR_TYPE_SIZE 32
27
28 /* If defined, a C expression whose value is a string containing the
29    assembler operation to identify the following data as
30    uninitialized global data.  If not defined, and neither
31    `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
32    uninitialized global data will be output in the data section if
33    `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
34    used.  */
35 #define BSS_SECTION_ASM_OP      "\t.section\t.bss"
36
37 #define ASM_OUTPUT_ALIGNED_BSS mips_output_aligned_bss
38
39 #undef ASM_DECLARE_OBJECT_NAME
40 #define ASM_DECLARE_OBJECT_NAME mips_declare_object_name
41
42 #undef TARGET_VERSION
43 #if TARGET_ENDIAN_DEFAULT == 0
44 #define TARGET_VERSION fprintf (stderr, " (MIPSel GNU/Linux with ELF)");
45 #else
46 #define TARGET_VERSION fprintf (stderr, " (MIPS GNU/Linux with ELF)");
47 #endif
48
49 #undef MD_EXEC_PREFIX
50 #undef MD_STARTFILE_PREFIX
51
52 /* If we don't set MASK_ABICALLS, we can't default to PIC.  */
53 #undef TARGET_DEFAULT
54 #define TARGET_DEFAULT (MASK_ABICALLS|MASK_GAS)
55
56 #define TARGET_OS_CPP_BUILTINS()                                \
57     do {                                                        \
58         LINUX_TARGET_OS_CPP_BUILTINS();                         \
59         builtin_define ("__PIC__");                             \
60         builtin_define ("__pic__");                             \
61         /* The GNU C++ standard library requires this.  */      \
62         if (c_dialect_cxx ())                                   \
63           builtin_define ("_GNU_SOURCE");                       \
64                                                                 \
65       if (mips_abi == ABI_N32)                                  \
66       {                                                         \
67         builtin_define ("_ABIN32=2");                           \
68         builtin_define ("_MIPS_SIM=_ABIN32");                   \
69         builtin_define ("_MIPS_SZLONG=32");                     \
70         builtin_define ("_MIPS_SZPTR=32");                      \
71       }                                                         \
72      else if (mips_abi == ABI_64)                               \
73       {                                                         \
74         builtin_define ("_ABI64=3");                            \
75         builtin_define ("_MIPS_SIM=_ABI64");                    \
76         builtin_define ("_MIPS_SZLONG=64");                     \
77         builtin_define ("_MIPS_SZPTR=64");                      \
78       }                                                         \
79      else                                                       \
80       {                                                         \
81         builtin_define ("_ABIO32=1");                   \
82         builtin_define ("_MIPS_SIM=_ABIO32");           \
83         builtin_define ("_MIPS_SZLONG=32");                     \
84         builtin_define ("_MIPS_SZPTR=32");                      \
85       }                                                         \
86      if (TARGET_FLOAT64)                                        \
87         builtin_define ("_MIPS_FPSET=32");                      \
88      else                                                       \
89         builtin_define ("_MIPS_FPSET=16");                      \
90                                                                 \
91      if (TARGET_INT64)                                          \
92         builtin_define ("_MIPS_SZINT=64");                      \
93      else                                                       \
94         builtin_define ("_MIPS_SZINT=32");                      \
95 } while (0)
96
97 #undef  SUBTARGET_CPP_SPEC
98 #define SUBTARGET_CPP_SPEC "\
99 %{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \
100 %{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} \
101 %{pthread:-D_REENTRANT}"
102
103 /* From iris5.h */
104 /* -G is incompatible with -KPIC which is the default, so only allow objects
105    in the small data section if the user explicitly asks for it.  */
106 #undef MIPS_DEFAULT_GVALUE
107 #define MIPS_DEFAULT_GVALUE 0
108
109 /* Borrowed from sparc/linux.h */
110 #undef LINK_SPEC
111 #define LINK_SPEC \
112  "%(endian_spec) \
113   %{shared:-shared} \
114   %{!shared: \
115     %{!ibcs: \
116       %{!static: \
117         %{rdynamic:-export-dynamic} \
118         %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
119         %{static:-static}}}"
120
121 #undef SUBTARGET_ASM_SPEC
122 #define SUBTARGET_ASM_SPEC "\
123 %{mabi=64: -64} \
124 %{!fno-PIC:%{!fno-pic:-KPIC}} \
125 %{fno-PIC:-non_shared} %{fno-pic:-non_shared}"
126
127 /* The MIPS assembler has different syntax for .set. We set it to
128    .dummy to trap any errors.  */
129 #undef SET_ASM_OP
130 #define SET_ASM_OP "\t.dummy\t"
131
132 #undef ASM_OUTPUT_DEF
133 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
134  do {                                                                   \
135         fputc ( '\t', FILE);                                            \
136         assemble_name (FILE, LABEL1);                                   \
137         fputs ( " = ", FILE);                                           \
138         assemble_name (FILE, LABEL2);                                   \
139         fputc ( '\n', FILE);                                            \
140  } while (0)
141
142 #undef ASM_DECLARE_FUNCTION_NAME
143 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)                   \
144   do {                                                                  \
145     if (!flag_inhibit_size_directive)                                   \
146       {                                                                 \
147         fputs ("\t.ent\t", STREAM);                                     \
148         assemble_name (STREAM, NAME);                                   \
149         putc ('\n', STREAM);                                            \
150       }                                                                 \
151     ASM_OUTPUT_TYPE_DIRECTIVE (STREAM, NAME, "function");               \
152     assemble_name (STREAM, NAME);                                       \
153     fputs (":\n", STREAM);                                              \
154   } while (0)
155
156 #undef ASM_DECLARE_FUNCTION_SIZE
157 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL)                   \
158   do {                                                                  \
159     if (!flag_inhibit_size_directive)                                   \
160       {                                                                 \
161         fputs ("\t.end\t", STREAM);                                     \
162         assemble_name (STREAM, NAME);                                   \
163         putc ('\n', STREAM);                                            \
164       }                                                                 \
165   } while (0)
166
167 /* Tell function_prologue in mips.c that we have already output the .ent/.end
168    pseudo-ops.  */
169 #undef FUNCTION_NAME_ALREADY_DECLARED
170 #define FUNCTION_NAME_ALREADY_DECLARED 1
171
172 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL)                      \
173   (flag_pic                                                             \
174     ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4\
175    : DW_EH_PE_absptr)
176
177 /* The glibc _mcount stub will save $v0 for us.  Don't mess with saving
178    it, since ASM_OUTPUT_REG_PUSH/ASM_OUTPUT_REG_POP do not work in the
179    presence of $gp-relative calls.  */
180 #undef ASM_OUTPUT_REG_PUSH
181 #undef ASM_OUTPUT_REG_POP
182
183 #undef LIB_SPEC
184 #define LIB_SPEC "\
185 %{shared: -lc} \
186 %{!static:-rpath-link %R/lib:%R/usr/lib} \
187 %{!shared: %{pthread:-lpthread} \
188   %{profile:-lc_p} %{!profile: -lc}}"
189
190 #ifndef inhibit_libc
191 /* Do code reading to identify a signal frame, and set the frame
192    state data appropriately.  See unwind-dw2.c for the structs.  */
193 #ifdef IN_LIBGCC2
194 #include <signal.h>
195
196 /* The third parameter to the signal handler points to something with
197  * this structure defined in asm/ucontext.h, but the name clashes with
198  * struct ucontext from sys/ucontext.h so this private copy is used.  */
199 typedef struct _sig_ucontext {
200     unsigned long         uc_flags;
201     struct _sig_ucontext  *uc_link;
202     stack_t               uc_stack;
203     struct sigcontext uc_mcontext;
204     sigset_t      uc_sigmask;
205 } _sig_ucontext_t;
206
207 #endif /* IN_LIBGCC2  */
208
209 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)            \
210   do {                                                               \
211     u_int32_t *pc_ = (u_int32_t *) (CONTEXT)->ra;                \
212     struct sigcontext *sc_;                                          \
213     _Unwind_Ptr new_cfa_;                                            \
214     int i_;                                                          \
215                                                                      \
216     /* 24021061 li v0, 0x1061 (rt_sigreturn)*/                       \
217     /* 0000000c syscall    */                                        \
218     /*    or */                                                      \
219     /* 24021017 li v0, 0x1017 (sigreturn) */                         \
220     /* 0000000c syscall  */                                          \
221     if (*(pc_ + 1) != 0x0000000c)                                    \
222       break;                                                         \
223     if (*(pc_ + 0) == 0x24021017)                                    \
224       {                                                              \
225         struct sigframe {                                            \
226           u_int32_t  trampoline[2];                                \
227           struct sigcontext sigctx;                                  \
228         } *rt_ = (CONTEXT)->ra;                                      \
229         sc_ = &rt_->sigctx;                                          \
230       }                                                              \
231     else if (*(pc_ + 0) == 0x24021061)                               \
232       {                                                              \
233         struct rt_sigframe {                                         \
234           u_int32_t  trampoline[2];                                \
235           struct siginfo info;                                       \
236           _sig_ucontext_t uc;                                        \
237         } *rt_ = (CONTEXT)->ra;                                      \
238         sc_ = &rt_->uc.uc_mcontext;                                  \
239       }                                                              \
240     else                                                             \
241       break;                                                         \
242                                                                      \
243     new_cfa_ = (_Unwind_Ptr)sc_;                                     \
244     (FS)->cfa_how = CFA_REG_OFFSET;                                  \
245     (FS)->cfa_reg = STACK_POINTER_REGNUM;                            \
246     (FS)->cfa_offset = new_cfa_ - (_Unwind_Ptr) (CONTEXT)->cfa;      \
247                                                                      \
248     for (i_ = 0; i_ < 32; i_++) {                                    \
249       (FS)->regs.reg[i_].how = REG_SAVED_OFFSET;                     \
250       (FS)->regs.reg[i_].loc.offset                                  \
251         = (_Unwind_Ptr)&(sc_->sc_regs[i_]) - new_cfa_;               \
252     }                                                                \
253     (FS)->regs.reg[SIGNAL_UNWIND_RETURN_COLUMN].how = REG_SAVED_OFFSET; \
254     (FS)->regs.reg[SIGNAL_UNWIND_RETURN_COLUMN].loc.offset           \
255         = (_Unwind_Ptr)&(sc_->sc_pc) - new_cfa_;                     \
256     (FS)->retaddr_column = SIGNAL_UNWIND_RETURN_COLUMN;              \
257                                                                      \
258     goto SUCCESS;                                                    \
259   } while (0)
260 #endif