OSDN Git Service

* config.gcc (mips-*-*): Remove definitions of MASK_GAS and
[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
55
56 #define TARGET_OS_CPP_BUILTINS()                                \
57     do {                                                        \
58         LINUX_TARGET_OS_CPP_BUILTINS();                         \
59         builtin_define ("__PIC__");                             \
60         builtin_define ("__pic__");                             \
61         builtin_assert ("machine=mips");                        \
62         /* The GNU C++ standard library requires this.  */      \
63         if (c_dialect_cxx ())                                   \
64           builtin_define ("_GNU_SOURCE");                       \
65                                                                 \
66       if (mips_abi == ABI_N32)                                  \
67       {                                                         \
68         builtin_define ("_ABIN32=2");                           \
69         builtin_define ("_MIPS_SIM=_ABIN32");                   \
70         builtin_define ("_MIPS_SZLONG=32");                     \
71         builtin_define ("_MIPS_SZPTR=32");                      \
72       }                                                         \
73      else if (mips_abi == ABI_64)                               \
74       {                                                         \
75         builtin_define ("_ABI64=3");                            \
76         builtin_define ("_MIPS_SIM=_ABI64");                    \
77         builtin_define ("_MIPS_SZLONG=64");                     \
78         builtin_define ("_MIPS_SZPTR=64");                      \
79       }                                                         \
80      else                                                       \
81       {                                                         \
82         builtin_define ("_ABIO32=1");                   \
83         builtin_define ("_MIPS_SIM=_ABIO32");           \
84         builtin_define ("_MIPS_SZLONG=32");                     \
85         builtin_define ("_MIPS_SZPTR=32");                      \
86       }                                                         \
87      if (TARGET_FLOAT64)                                        \
88         builtin_define ("_MIPS_FPSET=32");                      \
89      else                                                       \
90         builtin_define ("_MIPS_FPSET=16");                      \
91                                                                 \
92      if (TARGET_INT64)                                          \
93         builtin_define ("_MIPS_SZINT=64");                      \
94      else                                                       \
95         builtin_define ("_MIPS_SZINT=32");                      \
96 } while (0)
97
98 #undef  SUBTARGET_CPP_SPEC
99 #define SUBTARGET_CPP_SPEC "\
100 %{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \
101 %{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} \
102 %{pthread:-D_REENTRANT}"
103
104 /* From iris5.h */
105 /* -G is incompatible with -KPIC which is the default, so only allow objects
106    in the small data section if the user explicitly asks for it.  */
107 #undef MIPS_DEFAULT_GVALUE
108 #define MIPS_DEFAULT_GVALUE 0
109
110 /* Borrowed from sparc/linux.h */
111 #undef LINK_SPEC
112 #define LINK_SPEC \
113  "%(endian_spec) \
114   %{shared:-shared} \
115   %{!shared: \
116     %{!ibcs: \
117       %{!static: \
118         %{rdynamic:-export-dynamic} \
119         %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
120         %{static:-static}}}"
121
122 #undef SUBTARGET_ASM_SPEC
123 #define SUBTARGET_ASM_SPEC "\
124 %{mabi=64: -64} \
125 %{!fno-PIC:%{!fno-pic:-KPIC}} \
126 %{fno-PIC:-non_shared} %{fno-pic:-non_shared}"
127
128 /* The MIPS assembler has different syntax for .set. We set it to
129    .dummy to trap any errors.  */
130 #undef SET_ASM_OP
131 #define SET_ASM_OP "\t.dummy\t"
132
133 #undef ASM_OUTPUT_DEF
134 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
135  do {                                                                   \
136         fputc ( '\t', FILE);                                            \
137         assemble_name (FILE, LABEL1);                                   \
138         fputs ( " = ", FILE);                                           \
139         assemble_name (FILE, LABEL2);                                   \
140         fputc ( '\n', FILE);                                            \
141  } while (0)
142
143 #undef ASM_DECLARE_FUNCTION_NAME
144 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)                   \
145   do {                                                                  \
146     if (!flag_inhibit_size_directive)                                   \
147       {                                                                 \
148         fputs ("\t.ent\t", STREAM);                                     \
149         assemble_name (STREAM, NAME);                                   \
150         putc ('\n', STREAM);                                            \
151       }                                                                 \
152     ASM_OUTPUT_TYPE_DIRECTIVE (STREAM, NAME, "function");               \
153     assemble_name (STREAM, NAME);                                       \
154     fputs (":\n", STREAM);                                              \
155   } while (0)
156
157 #undef ASM_DECLARE_FUNCTION_SIZE
158 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL)                   \
159   do {                                                                  \
160     if (!flag_inhibit_size_directive)                                   \
161       {                                                                 \
162         fputs ("\t.end\t", STREAM);                                     \
163         assemble_name (STREAM, NAME);                                   \
164         putc ('\n', STREAM);                                            \
165       }                                                                 \
166   } while (0)
167
168 /* Tell function_prologue in mips.c that we have already output the .ent/.end
169    pseudo-ops.  */
170 #undef FUNCTION_NAME_ALREADY_DECLARED
171 #define FUNCTION_NAME_ALREADY_DECLARED 1
172
173 /* The glibc _mcount stub will save $v0 for us.  Don't mess with saving
174    it, since ASM_OUTPUT_REG_PUSH/ASM_OUTPUT_REG_POP do not work in the
175    presence of $gp-relative calls.  */
176 #undef ASM_OUTPUT_REG_PUSH
177 #undef ASM_OUTPUT_REG_POP
178
179 #undef LIB_SPEC
180 #define LIB_SPEC "\
181 %{shared: -lc} \
182 %{!static:-rpath-link %R/lib:%R/usr/lib} \
183 %{!shared: %{pthread:-lpthread} \
184   %{profile:-lc_p} %{!profile: -lc}}"
185
186 #ifndef inhibit_libc
187 /* Do code reading to identify a signal frame, and set the frame
188    state data appropriately.  See unwind-dw2.c for the structs.  */
189 #ifdef IN_LIBGCC2
190 #include <signal.h>
191
192 /* The third parameter to the signal handler points to something with
193  * this structure defined in asm/ucontext.h, but the name clashes with
194  * struct ucontext from sys/ucontext.h so this private copy is used.  */
195 typedef struct _sig_ucontext {
196     unsigned long         uc_flags;
197     struct _sig_ucontext  *uc_link;
198     stack_t               uc_stack;
199     struct sigcontext uc_mcontext;
200     sigset_t      uc_sigmask;
201 } _sig_ucontext_t;
202
203 #endif /* IN_LIBGCC2  */
204
205 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)            \
206   do {                                                               \
207     u_int32_t *pc_ = (u_int32_t *) (CONTEXT)->ra;                \
208     struct sigcontext *sc_;                                          \
209     _Unwind_Ptr new_cfa_;                                            \
210     int i_;                                                          \
211                                                                      \
212     /* 24021061 li v0, 0x1061 (rt_sigreturn)*/                       \
213     /* 0000000c syscall    */                                        \
214     /*    or */                                                      \
215     /* 24021017 li v0, 0x1017 (sigreturn) */                         \
216     /* 0000000c syscall  */                                          \
217     if (*(pc_ + 1) != 0x0000000c)                                    \
218       break;                                                         \
219     if (*(pc_ + 0) == 0x24021017)                                    \
220       {                                                              \
221         struct sigframe {                                            \
222           u_int32_t  trampoline[2];                                \
223           struct sigcontext sigctx;                                  \
224         } *rt_ = (CONTEXT)->ra;                                      \
225         sc_ = &rt_->sigctx;                                          \
226       }                                                              \
227     else if (*(pc_ + 0) == 0x24021061)                               \
228       {                                                              \
229         struct rt_sigframe {                                         \
230           u_int32_t  trampoline[2];                                \
231           struct siginfo info;                                       \
232           _sig_ucontext_t uc;                                        \
233         } *rt_ = (CONTEXT)->ra;                                      \
234         sc_ = &rt_->uc.uc_mcontext;                                  \
235       }                                                              \
236     else                                                             \
237       break;                                                         \
238                                                                      \
239     new_cfa_ = (_Unwind_Ptr)sc_;                                     \
240     (FS)->cfa_how = CFA_REG_OFFSET;                                  \
241     (FS)->cfa_reg = STACK_POINTER_REGNUM;                            \
242     (FS)->cfa_offset = new_cfa_ - (_Unwind_Ptr) (CONTEXT)->cfa;      \
243                                                                      \
244     for (i_ = 0; i_ < 32; i_++) {                                    \
245       (FS)->regs.reg[i_].how = REG_SAVED_OFFSET;                     \
246       (FS)->regs.reg[i_].loc.offset                                  \
247         = (_Unwind_Ptr)&(sc_->sc_regs[i_]) - new_cfa_;               \
248     }                                                                \
249     (FS)->regs.reg[SIGNAL_UNWIND_RETURN_COLUMN].how = REG_SAVED_OFFSET; \
250     (FS)->regs.reg[SIGNAL_UNWIND_RETURN_COLUMN].loc.offset           \
251         = (_Unwind_Ptr)&(sc_->sc_pc) - new_cfa_;                     \
252     (FS)->retaddr_column = SIGNAL_UNWIND_RETURN_COLUMN;              \
253                                                                      \
254     goto SUCCESS;                                                    \
255   } while (0)
256 #endif