OSDN Git Service

710df19b518f79d2f0dbbed8b9c270bf9e24616f
[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 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
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)
9 any later version.
10
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.
15
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.  */
20
21 #undef TARGET_VERSION
22 #if TARGET_ENDIAN_DEFAULT == 0
23 #define TARGET_VERSION fprintf (stderr, " (MIPSel GNU/Linux with ELF)");
24 #else
25 #define TARGET_VERSION fprintf (stderr, " (MIPS GNU/Linux with ELF)");
26 #endif
27
28 #undef MD_EXEC_PREFIX
29 #undef MD_STARTFILE_PREFIX
30
31 /* Required to keep collect2.c happy */
32 #undef OBJECT_FORMAT_COFF
33
34 /* If we don't set MASK_ABICALLS, we can't default to PIC. */
35 #undef TARGET_DEFAULT
36 #define TARGET_DEFAULT (MASK_ABICALLS|MASK_GAS)
37
38
39 /* Handle #pragma weak and #pragma pack.  */
40 #undef HANDLE_SYSV_PRAGMA
41 #define HANDLE_SYSV_PRAGMA 1
42
43 /* Don't assume anything about the header files.  */
44 #define NO_IMPLICIT_EXTERN_C
45
46 /* Generate calls to memcpy, etc., not bcopy, etc.  */
47 #define TARGET_MEM_FUNCTIONS
48
49 /* Specify predefined symbols in preprocessor.  */
50 #undef CPP_PREDEFINES
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__"
55 #else
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__"
59 #endif
60
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}"
67
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}"
107
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'. */
112
113 #undef  STARTFILE_SPEC
114 #define STARTFILE_SPEC \
115   "%{!shared: \
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}"
118
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'.  */
124
125 #undef  ENDFILE_SPEC
126 #define ENDFILE_SPEC \
127   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
128
129 /* From iris5.h */
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
134
135 #undef LIB_SPEC
136 /* Taken from sparc/linux.h.  */
137 #define LIB_SPEC \
138   "%{shared: -lc} \
139    %{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} \
140      %{profile:-lc_p} %{!profile: -lc}}"
141
142 /* Borrowed from sparc/linux.h */
143 #undef LINK_SPEC
144 #define LINK_SPEC \
145  "%(endian_spec) \
146   %{shared:-shared} \
147   %{!shared: \
148     %{!ibcs: \
149       %{!static: \
150         %{rdynamic:-export-dynamic} \
151         %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
152         %{static:-static}}}"
153
154
155 #undef SUBTARGET_ASM_SPEC
156 #define SUBTARGET_ASM_SPEC "\
157 %{mabi=64: -64} \
158 %{!fno-PIC:%{!fno-pic:-KPIC}} \
159 %{fno-PIC:-non_shared} %{fno-pic:-non_shared}"
160
161 /* We don't need those nonsenses.  */
162 #undef INVOKE__main
163 #undef CTOR_LIST_BEGIN
164 #undef CTOR_LIST_END
165 #undef DTOR_LIST_BEGIN
166 #undef DTOR_LIST_END
167
168 /* The MIPS assembler has different syntax for .set. We set it to
169    .dummy to trap any errors.  */
170 #undef SET_ASM_OP
171 #define SET_ASM_OP "\t.dummy\t"
172
173 /* This is how we tell the assembler that two symbols have the
174    same value.  */
175 #undef ASM_OUTPUT_DEF
176 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
177   do {                                                                  \
178         fprintf ((FILE), "\t");                                         \
179         assemble_name (FILE, LABEL1);                                   \
180         fprintf (FILE, "=");                                            \
181         assemble_name (FILE, LABEL2);                                   \
182         fprintf (FILE, "\n");                                           \
183  } while (0)
184
185 #undef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
186 #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO)     \
187   do {                                                                  \
188         fputc ('\t', FILE);                                             \
189         assemble_name (FILE, SY);                                       \
190         fputc ('=', FILE);                                              \
191         assemble_name (FILE, HI);                                       \
192         fputc ('-', FILE);                                              \
193         assemble_name (FILE, LO);                                       \
194   } while (0)
195
196 #undef ASM_DECLARE_FUNCTION_NAME
197 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)                   \
198   do {                                                                  \
199     if (!flag_inhibit_size_directive)                                   \
200       {                                                                 \
201         fputs ("\t.ent\t", STREAM);                                     \
202         assemble_name (STREAM, NAME);                                   \
203         putc ('\n', STREAM);                                            \
204       }                                                                 \
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);                                              \
212   } while (0)
213
214 #undef ASM_DECLARE_FUNCTION_SIZE
215 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL)                   \
216   do {                                                                  \
217     if (!flag_inhibit_size_directive)                                   \
218       {                                                                 \
219         fputs ("\t.end\t", STREAM);                                     \
220         assemble_name (STREAM, NAME);                                   \
221         putc ('\n', STREAM);                                            \
222       }                                                                 \
223   } while (0)
224
225 /* Tell function_prologue in mips.c that we have already output the .ent/.end
226    pseudo-ops.  */
227 #define FUNCTION_NAME_ALREADY_DECLARED