1 /* Definitions for MIPS running Linux-based GNU systems with ELF format.
2 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
3 Free Software Foundation, Inc.
5 This file is part of GCC.
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)
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.
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. */
23 #define WCHAR_TYPE "int"
25 #undef WCHAR_TYPE_SIZE
26 #define WCHAR_TYPE_SIZE 32
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
35 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
37 #define ASM_OUTPUT_ALIGNED_BSS mips_output_aligned_bss
39 #undef ASM_DECLARE_OBJECT_NAME
40 #define ASM_DECLARE_OBJECT_NAME mips_declare_object_name
43 #if TARGET_ENDIAN_DEFAULT == 0
44 #define TARGET_VERSION fprintf (stderr, " (MIPSel GNU/Linux with ELF)");
46 #define TARGET_VERSION fprintf (stderr, " (MIPS GNU/Linux with ELF)");
50 #undef MD_STARTFILE_PREFIX
52 /* If we don't set MASK_ABICALLS, we can't default to PIC. */
54 #define TARGET_DEFAULT (MASK_ABICALLS|MASK_GAS)
56 #define TARGET_OS_CPP_BUILTINS() \
58 builtin_define ("__gnu_linux__"); \
59 builtin_define ("__PIC__"); \
60 builtin_define ("__pic__"); \
61 builtin_define_std ("unix"); \
62 builtin_define_std ("linux"); \
63 builtin_assert ("system=linux"); \
64 /* The GNU C++ standard library requires this. */ \
65 if (c_dialect_cxx ()) \
66 builtin_define ("_GNU_SOURCE"); \
68 if (mips_abi == ABI_N32) \
70 builtin_define ("_ABIN32=2"); \
71 builtin_define ("_MIPS_SIM=_ABIN32"); \
72 builtin_define ("_MIPS_SZLONG=32"); \
73 builtin_define ("_MIPS_SZPTR=32"); \
75 else if (mips_abi == ABI_64) \
77 builtin_define ("_ABI64=3"); \
78 builtin_define ("_MIPS_SIM=_ABI64"); \
79 builtin_define ("_MIPS_SZLONG=64"); \
80 builtin_define ("_MIPS_SZPTR=64"); \
84 builtin_define ("_ABIO32=1"); \
85 builtin_define ("_MIPS_SIM=_ABIO32"); \
86 builtin_define ("_MIPS_SZLONG=32"); \
87 builtin_define ("_MIPS_SZPTR=32"); \
90 builtin_define ("_MIPS_FPSET=32"); \
92 builtin_define ("_MIPS_FPSET=16"); \
95 builtin_define ("_MIPS_SZINT=64"); \
97 builtin_define ("_MIPS_SZINT=32"); \
100 #undef SUBTARGET_CPP_SPEC
101 #define SUBTARGET_CPP_SPEC "\
102 %{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \
103 %{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} \
104 %{pthread:-D_REENTRANT}"
107 /* -G is incompatible with -KPIC which is the default, so only allow objects
108 in the small data section if the user explicitly asks for it. */
109 #undef MIPS_DEFAULT_GVALUE
110 #define MIPS_DEFAULT_GVALUE 0
112 /* Borrowed from sparc/linux.h */
120 %{rdynamic:-export-dynamic} \
121 %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
124 #undef SUBTARGET_ASM_SPEC
125 #define SUBTARGET_ASM_SPEC "\
127 %{!fno-PIC:%{!fno-pic:-KPIC}} \
128 %{fno-PIC:-non_shared} %{fno-pic:-non_shared}"
130 #undef SUBTARGET_ASM_DEBUGGING_SPEC
131 #define SUBTARGET_ASM_DEBUGGING_SPEC "-g0"
133 /* The MIPS assembler has different syntax for .set. We set it to
134 .dummy to trap any errors. */
136 #define SET_ASM_OP "\t.dummy\t"
138 #undef ASM_OUTPUT_DEF
139 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
141 fputc ( '\t', FILE); \
142 assemble_name (FILE, LABEL1); \
143 fputs ( " = ", FILE); \
144 assemble_name (FILE, LABEL2); \
145 fputc ( '\n', FILE); \
148 #undef ASM_DECLARE_FUNCTION_NAME
149 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
151 if (!flag_inhibit_size_directive) \
153 fputs ("\t.ent\t", STREAM); \
154 assemble_name (STREAM, NAME); \
155 putc ('\n', STREAM); \
157 ASM_OUTPUT_TYPE_DIRECTIVE (STREAM, NAME, "function"); \
158 assemble_name (STREAM, NAME); \
159 fputs (":\n", STREAM); \
162 #undef ASM_DECLARE_FUNCTION_SIZE
163 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \
165 if (!flag_inhibit_size_directive) \
167 fputs ("\t.end\t", STREAM); \
168 assemble_name (STREAM, NAME); \
169 putc ('\n', STREAM); \
173 /* Tell function_prologue in mips.c that we have already output the .ent/.end
175 #undef FUNCTION_NAME_ALREADY_DECLARED
176 #define FUNCTION_NAME_ALREADY_DECLARED 1
178 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
180 ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4\
183 /* The glibc _mcount stub will save $v0 for us. Don't mess with saving
184 it, since ASM_OUTPUT_REG_PUSH/ASM_OUTPUT_REG_POP do not work in the
185 presence of $gp-relative calls. */
186 #undef ASM_OUTPUT_REG_PUSH
187 #undef ASM_OUTPUT_REG_POP
192 %{!static:-rpath-link %R/lib:%R/usr/lib} \
193 %{!shared: %{pthread:-lpthread} \
194 %{profile:-lc_p} %{!profile: -lc}}"
196 /* Do code reading to identify a signal frame, and set the frame
197 state data appropriately. See unwind-dw2.c for the structs. */
201 /* The third parameter to the signal handler points to something with
202 * this structure defined in asm/ucontext.h, but the name clashes with
203 * struct ucontext from sys/ucontext.h so this private copy is used. */
204 typedef struct _sig_ucontext {
205 unsigned long uc_flags;
206 struct _sig_ucontext *uc_link;
208 struct sigcontext uc_mcontext;
212 #endif /* IN_LIBGCC2 */
214 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
216 u_int32_t *pc_ = (u_int32_t *) (CONTEXT)->ra; \
217 struct sigcontext *sc_; \
218 _Unwind_Ptr new_cfa_; \
221 /* 24021061 li v0, 0x1061 (rt_sigreturn)*/ \
222 /* 0000000c syscall */ \
224 /* 24021017 li v0, 0x1017 (sigreturn) */ \
225 /* 0000000c syscall */ \
226 if (*(pc_ + 1) != 0x0000000c) \
228 if (*(pc_ + 0) == 0x24021017) \
231 u_int32_t trampoline[2]; \
232 struct sigcontext sigctx; \
233 } *rt_ = (CONTEXT)->ra; \
234 sc_ = &rt_->sigctx; \
236 else if (*(pc_ + 0) == 0x24021061) \
238 struct rt_sigframe { \
239 u_int32_t trampoline[2]; \
240 struct siginfo info; \
241 _sig_ucontext_t uc; \
242 } *rt_ = (CONTEXT)->ra; \
243 sc_ = &rt_->uc.uc_mcontext; \
248 new_cfa_ = (_Unwind_Ptr)sc_; \
249 (FS)->cfa_how = CFA_REG_OFFSET; \
250 (FS)->cfa_reg = STACK_POINTER_REGNUM; \
251 (FS)->cfa_offset = new_cfa_ - (_Unwind_Ptr) (CONTEXT)->cfa; \
253 for (i_ = 0; i_ < 32; i_++) { \
254 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
255 (FS)->regs.reg[i_].loc.offset \
256 = (_Unwind_Ptr)&(sc_->sc_regs[i_]) - new_cfa_; \
258 (FS)->regs.reg[SIGNAL_UNWIND_RETURN_COLUMN].how = REG_SAVED_OFFSET; \
259 (FS)->regs.reg[SIGNAL_UNWIND_RETURN_COLUMN].loc.offset \
260 = (_Unwind_Ptr)&(sc_->sc_pc) - new_cfa_; \
261 (FS)->retaddr_column = SIGNAL_UNWIND_RETURN_COLUMN; \