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 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
109 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
110 provides part of the support for getting C++ file-scope static
111 object constructed before entering `main'. */
113 #undef STARTFILE_SPEC
114 #define STARTFILE_SPEC \
116 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
117 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
119 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
120 the GNU/Linux magical crtend.o file (see crtstuff.c) which
121 provides part of the support for getting C++ file-scope static
122 object constructed before entering `main', followed by a normal
123 GNU/Linux "finalizer" file, `crtn.o'. */
126 #define ENDFILE_SPEC \
127 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
130 /* -G is incompatible with -KPIC which is the default, so only allow objects
131 in the small data section if the user explicitly asks for it. */
132 #undef MIPS_DEFAULT_GVALUE
133 #define MIPS_DEFAULT_GVALUE 0
136 /* Taken from sparc/linux.h. */
139 %{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} \
140 %{profile:-lc_p} %{!profile: -lc}}"
142 /* Borrowed from sparc/linux.h */
150 %{rdynamic:-export-dynamic} \
151 %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
155 #undef SUBTARGET_ASM_SPEC
156 #define SUBTARGET_ASM_SPEC "\
158 %{!fno-PIC:%{!fno-pic:-KPIC}} \
159 %{fno-PIC:-non_shared} %{fno-pic:-non_shared}"
161 /* We don't need those nonsenses. */
163 #undef CTOR_LIST_BEGIN
165 #undef DTOR_LIST_BEGIN
168 /* The MIPS assembler has different syntax for .set. We set it to
169 .dummy to trap any errors. */
171 #define SET_ASM_OP "\t.dummy\t"
173 /* This is how we tell the assembler that two symbols have the
175 #undef ASM_OUTPUT_DEF
176 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
178 fprintf ((FILE), "\t"); \
179 assemble_name (FILE, LABEL1); \
180 fprintf (FILE, "="); \
181 assemble_name (FILE, LABEL2); \
182 fprintf (FILE, "\n"); \
185 #undef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
186 #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO) \
188 fputc ('\t', FILE); \
189 assemble_name (FILE, SY); \
191 assemble_name (FILE, HI); \
193 assemble_name (FILE, LO); \
196 #undef ASM_DECLARE_FUNCTION_NAME
197 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
199 if (!flag_inhibit_size_directive) \
201 fputs ("\t.ent\t", STREAM); \
202 assemble_name (STREAM, NAME); \
203 putc ('\n', STREAM); \
205 fprintf (STREAM, "\t%s\t ", TYPE_ASM_OP); \
206 assemble_name (STREAM, NAME); \
207 putc (',', STREAM); \
208 fprintf (STREAM, TYPE_OPERAND_FMT, "function"); \
209 putc ('\n', STREAM); \
210 assemble_name (STREAM, NAME); \
211 fputs (":\n", STREAM); \
214 #undef ASM_DECLARE_FUNCTION_SIZE
215 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \
217 if (!flag_inhibit_size_directive) \
219 fputs ("\t.end\t", STREAM); \
220 assemble_name (STREAM, NAME); \
221 putc ('\n', STREAM); \
225 /* Tell function_prologue in mips.c that we have already output the .ent/.end
227 #define FUNCTION_NAME_ALREADY_DECLARED