1 /* Definitions for MIPS running Linux-based GNU systems with ELF format.
2 Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 #if TARGET_ENDIAN_DEFAULT == 0
23 #define TARGET_VERSION fprintf (stderr, " (MIPSel GNU/Linux with ELF)");
25 #define TARGET_VERSION fprintf (stderr, " (MIPS GNU/Linux with ELF)");
29 #undef MD_STARTFILE_PREFIX
31 /* Required to keep collect2.c happy */
32 #undef OBJECT_FORMAT_COFF
34 /* If we don't set MASK_ABICALLS, we can't default to PIC. */
36 #define TARGET_DEFAULT (MASK_ABICALLS|MASK_GAS)
39 /* Handle #pragma weak and #pragma pack. */
40 #undef HANDLE_SYSV_PRAGMA
41 #define HANDLE_SYSV_PRAGMA 1
43 /* Don't assume anything about the header files. */
44 #define NO_IMPLICIT_EXTERN_C
46 /* Generate calls to memcpy, etc., not bcopy, etc. */
47 #define TARGET_MEM_FUNCTIONS
49 /* Specify predefined symbols in preprocessor. */
51 #if TARGET_ENDIAN_DEFAULT == 0
52 #define CPP_PREDEFINES "-DMIPSEL -D_MIPSEL -Dunix -Dmips -D_mips \
53 -DR3000 -D_R3000 -Dlinux -Asystem=posix -Acpu=mips \
54 -Amachine=mips -D__ELF__ -D__PIC__ -D__pic__"
56 #define CPP_PREDEFINES "-DMIPSEB -D_MIPSEB -Dunix -Dmips -D_mips \
57 -DR3000 -D_R3000 -Dlinux -Asystem=posix -Acpu=mips \
58 -Amachine=mips -D__ELF__ -D__PIC__ -D__pic__"
61 #undef SUBTARGET_CPP_SIZE_SPEC
62 #define SUBTARGET_CPP_SIZE_SPEC "\
63 %{mabi=32: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \
64 %{mabi=n32: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \
65 %{mabi=64: -D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int} \
66 %{!mabi*: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int}"
68 /* We must make -mips3 do what -mlong64 used to do. */
69 /* ??? If no mipsX option given, but a mabi=X option is, then should set
70 _MIPS_ISA based on the mabi=X option. */
71 /* ??? If no mabi=X option give, but a mipsX option is, then should set
72 _MIPS_SIM based on the mipsX option. */
73 /* ??? Same for _MIPS_SZINT. */
74 /* ??? Same for _MIPS_SZPTR. */
75 /* ??? Same for __SIZE_TYPE and __PTRDIFF_TYPE. */
76 #undef SUBTARGET_CPP_SPEC
77 #define SUBTARGET_CPP_SPEC "\
78 %{mfp32: -D_MIPS_FPSET=16} \
79 %{mfp64: -D_MIPS_FPSET=32} \
80 %{!mfp*: -D_MIPS_FPSET=32} \
81 %{mips1: -D_MIPS_ISA=_MIPS_ISA_MIPS1} \
82 %{mips2: -D_MIPS_ISA=_MIPS_ISA_MIPS2} \
83 %{mips3: -D_MIPS_ISA=_MIPS_ISA_MIPS3} \
84 %{mips4: -D_MIPS_ISA=_MIPS_ISA_MIPS4} \
85 %{!mips*: -D_MIPS_ISA=_MIPS_ISA_MIPS1} \
86 %{mabi=32: -D_MIPS_SIM=_MIPS_SIM_ABI32} \
87 %{mabi=n32: -D_ABIN32=2 -D_MIPS_SIM=_ABIN32} \
88 %{mabi=64: -D_ABI64=3 -D_MIPS_SIM=_ABI64} \
89 %{!mabi*: -D_MIPS_SIM=_MIPS_SIM_ABI32} \
90 %{!mint64: -D_MIPS_SZINT=32}%{mint64: -D_MIPS_SZINT=64} \
91 %{mabi=32: -D_MIPS_SZLONG=32} \
92 %{mabi=n32: -D_MIPS_SZLONG=32} \
93 %{mabi=64: -D_MIPS_SZLONG=64} \
94 %{!mabi*: -D_MIPS_SZLONG=32} \
95 %{mabi=32: -D_MIPS_SZPTR=32} \
96 %{mabi=n32: -D_MIPS_SZPTR=32} \
97 %{mabi=64: -D_MIPS_SZPTR=64} \
98 %{!mabi*: -D_MIPS_SZPTR=32} \
99 %{!mips*: -U__mips -D__mips} \
100 %{mabi=32: -U__mips64} \
101 %{mabi=n32: -D__mips64} \
102 %{mabi=64: -U__mips64} \
103 %{!mabi*: -U__mips64} \
104 %{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \
105 %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \
106 %{pthread:-D_REENTRANT}"
108 /* The GNU C++ standard library requires that these macros be defined. */
109 #undef CPLUSPLUS_CPP_SPEC
110 #define CPLUSPLUS_CPP_SPEC "\
111 -D__LANGUAGE_C_PLUS_PLUS -D_LANGUAGE_C_PLUS_PLUS \
112 -D_GNU_SOURCE %(cpp) \
115 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
116 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
117 provides part of the support for getting C++ file-scope static
118 object constructed before entering `main'. */
120 #undef STARTFILE_SPEC
121 #define STARTFILE_SPEC \
123 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
124 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
126 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
127 the GNU/Linux magical crtend.o file (see crtstuff.c) which
128 provides part of the support for getting C++ file-scope static
129 object constructed before entering `main', followed by a normal
130 GNU/Linux "finalizer" file, `crtn.o'. */
133 #define ENDFILE_SPEC \
134 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
137 /* -G is incompatible with -KPIC which is the default, so only allow objects
138 in the small data section if the user explicitly asks for it. */
139 #undef MIPS_DEFAULT_GVALUE
140 #define MIPS_DEFAULT_GVALUE 0
143 /* Taken from sparc/linux.h. */
146 %{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} \
147 %{profile:-lc_p} %{!profile: -lc}}"
149 /* Borrowed from sparc/linux.h */
157 %{rdynamic:-export-dynamic} \
158 %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
162 #undef SUBTARGET_ASM_SPEC
163 #define SUBTARGET_ASM_SPEC "\
165 %{!fno-PIC:%{!fno-pic:-KPIC}} \
166 %{fno-PIC:-non_shared} %{fno-pic:-non_shared}"
168 /* We don't need those nonsenses. */
170 #undef CTOR_LIST_BEGIN
172 #undef DTOR_LIST_BEGIN
175 /* The MIPS assembler has different syntax for .set. We set it to
176 .dummy to trap any errors. */
178 #define SET_ASM_OP "\t.dummy\t"
180 /* This is how we tell the assembler that two symbols have the
182 #undef ASM_OUTPUT_DEF
183 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
185 fprintf ((FILE), "\t"); \
186 assemble_name (FILE, LABEL1); \
187 fprintf (FILE, "="); \
188 assemble_name (FILE, LABEL2); \
189 fprintf (FILE, "\n"); \
192 #undef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
193 #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO) \
195 fputc ('\t', FILE); \
196 assemble_name (FILE, SY); \
198 assemble_name (FILE, HI); \
200 assemble_name (FILE, LO); \
203 #undef ASM_DECLARE_FUNCTION_NAME
204 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
206 if (!flag_inhibit_size_directive) \
208 fputs ("\t.ent\t", STREAM); \
209 assemble_name (STREAM, NAME); \
210 putc ('\n', STREAM); \
212 fprintf (STREAM, "\t%s\t ", TYPE_ASM_OP); \
213 assemble_name (STREAM, NAME); \
214 putc (',', STREAM); \
215 fprintf (STREAM, TYPE_OPERAND_FMT, "function"); \
216 putc ('\n', STREAM); \
217 assemble_name (STREAM, NAME); \
218 fputs (":\n", STREAM); \
221 #undef ASM_DECLARE_FUNCTION_SIZE
222 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \
224 if (!flag_inhibit_size_directive) \
226 fputs ("\t.end\t", STREAM); \
227 assemble_name (STREAM, NAME); \
228 putc ('\n', STREAM); \
232 /* Tell function_prologue in mips.c that we have already output the .ent/.end
234 #define FUNCTION_NAME_ALREADY_DECLARED