OSDN Git Service

2001-07-30 H.J. Lu <hjl@gnu.org>
[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 /* 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) \
113 "
114
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'. */
119
120 #undef  STARTFILE_SPEC
121 #define STARTFILE_SPEC \
122   "%{!shared: \
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}"
125
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'.  */
131
132 #undef  ENDFILE_SPEC
133 #define ENDFILE_SPEC \
134   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
135
136 /* From iris5.h */
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
141
142 #undef LIB_SPEC
143 /* Taken from sparc/linux.h.  */
144 #define LIB_SPEC \
145   "%{shared: -lc} \
146    %{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} \
147      %{profile:-lc_p} %{!profile: -lc}}"
148
149 /* Borrowed from sparc/linux.h */
150 #undef LINK_SPEC
151 #define LINK_SPEC \
152  "%(endian_spec) \
153   %{shared:-shared} \
154   %{!shared: \
155     %{!ibcs: \
156       %{!static: \
157         %{rdynamic:-export-dynamic} \
158         %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
159         %{static:-static}}}"
160
161
162 #undef SUBTARGET_ASM_SPEC
163 #define SUBTARGET_ASM_SPEC "\
164 %{mabi=64: -64} \
165 %{!fno-PIC:%{!fno-pic:-KPIC}} \
166 %{fno-PIC:-non_shared} %{fno-pic:-non_shared}"
167
168 /* We don't need those nonsenses.  */
169 #undef INVOKE__main
170 #undef CTOR_LIST_BEGIN
171 #undef CTOR_LIST_END
172 #undef DTOR_LIST_BEGIN
173 #undef DTOR_LIST_END
174
175 /* The MIPS assembler has different syntax for .set. We set it to
176    .dummy to trap any errors.  */
177 #undef SET_ASM_OP
178 #define SET_ASM_OP "\t.dummy\t"
179
180 /* This is how we tell the assembler that two symbols have the
181    same value.  */
182 #undef ASM_OUTPUT_DEF
183 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
184   do {                                                                  \
185         fprintf ((FILE), "\t");                                         \
186         assemble_name (FILE, LABEL1);                                   \
187         fprintf (FILE, "=");                                            \
188         assemble_name (FILE, LABEL2);                                   \
189         fprintf (FILE, "\n");                                           \
190  } while (0)
191
192 #undef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
193 #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO)     \
194   do {                                                                  \
195         fputc ('\t', FILE);                                             \
196         assemble_name (FILE, SY);                                       \
197         fputc ('=', FILE);                                              \
198         assemble_name (FILE, HI);                                       \
199         fputc ('-', FILE);                                              \
200         assemble_name (FILE, LO);                                       \
201   } while (0)
202
203 #undef ASM_DECLARE_FUNCTION_NAME
204 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)                   \
205   do {                                                                  \
206     if (!flag_inhibit_size_directive)                                   \
207       {                                                                 \
208         fputs ("\t.ent\t", STREAM);                                     \
209         assemble_name (STREAM, NAME);                                   \
210         putc ('\n', STREAM);                                            \
211       }                                                                 \
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);                                              \
219   } while (0)
220
221 #undef ASM_DECLARE_FUNCTION_SIZE
222 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL)                   \
223   do {                                                                  \
224     if (!flag_inhibit_size_directive)                                   \
225       {                                                                 \
226         fputs ("\t.end\t", STREAM);                                     \
227         assemble_name (STREAM, NAME);                                   \
228         putc ('\n', STREAM);                                            \
229       }                                                                 \
230   } while (0)
231
232 /* Tell function_prologue in mips.c that we have already output the .ent/.end
233    pseudo-ops.  */
234 #define FUNCTION_NAME_ALREADY_DECLARED