OSDN Git Service

* Correct omitted attribution.
[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 #include "gofast.h"
22
23 /* US Software GOFAST library support.  */
24 #define INIT_SUBTARGET_OPTABS INIT_GOFAST_OPTABS
25
26 #include "mips/mips.h"
27
28 #undef WCHAR_TYPE
29 #define WCHAR_TYPE "int"
30
31 #undef WCHAR_TYPE_SIZE
32 #define WCHAR_TYPE_SIZE 32
33
34 /* If defined, a C expression whose value is a string containing the
35    assembler operation to identify the following data as
36    uninitialized global data.  If not defined, and neither
37    `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
38    uninitialized global data will be output in the data section if
39    `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
40    used.  */
41 #define BSS_SECTION_ASM_OP      "\t.section\t.bss"
42
43 #define SBSS_SECTION_ASM_OP     "\t.section .sbss"
44
45 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
46    separate, explicit argument.  If you define this macro, it is used
47    in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
48    handling the required alignment of the variable.  The alignment is
49    specified as the number of bits.
50
51    Try to use function `asm_output_aligned_bss' defined in file
52    `varasm.c' when defining this macro. */
53 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN)   \
54 do {                                                            \
55   ASM_GLOBALIZE_LABEL (FILE, NAME);                             \
56   if (SIZE > 0 && SIZE <= mips_section_threshold)               \
57     sbss_section ();                                            \
58   else                                                          \
59     bss_section ();                                             \
60   ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT));  \
61   last_assemble_variable_decl = DECL;                           \
62   ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL);                   \
63   ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1);                      \
64 } while (0)
65
66 /* These macros generate the special .type and .size directives which
67    are used to set the corresponding fields of the linker symbol table
68    entries in an ELF object file under SVR4.  These macros also output
69    the starting labels for the relevant functions/objects.  */
70
71 /* Write the extra assembler code needed to declare an object properly.  */
72
73 #undef ASM_DECLARE_OBJECT_NAME
74 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)               \
75   do {                                                          \
76     fprintf (FILE, "%s", TYPE_ASM_OP);                          \
77     assemble_name (FILE, NAME);                                 \
78     putc (',', FILE);                                           \
79     fprintf (FILE, TYPE_OPERAND_FMT, "object");                 \
80     putc ('\n', FILE);                                          \
81     size_directive_output = 0;                                  \
82     if (!flag_inhibit_size_directive && DECL_SIZE (DECL))       \
83       {                                                         \
84         size_directive_output = 1;                              \
85         fprintf (FILE, "%s", SIZE_ASM_OP);                      \
86         assemble_name (FILE, NAME);                             \
87         fprintf (FILE, ",%d\n",                                 \
88                  int_size_in_bytes (TREE_TYPE (DECL)));         \
89       }                                                         \
90     mips_declare_object (FILE, NAME, "", ":\n", 0);             \
91   } while (0)
92
93 #undef UNIQUE_SECTION
94 #define UNIQUE_SECTION(DECL,RELOC) \
95   mips_unique_section ((DECL), (RELOC))
96
97 /* A list of other sections which the compiler might be "in" at any
98    given time.  */
99 #undef EXTRA_SECTIONS
100 #define EXTRA_SECTIONS in_sdata, in_sbss, in_rdata, in_ctors, in_dtors
101  
102 #undef EXTRA_SECTION_FUNCTIONS
103 #define EXTRA_SECTION_FUNCTIONS                                         \
104   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
105   SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \
106   SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP) \
107   SECTION_FUNCTION_TEMPLATE(ctors_section, in_ctors, CTORS_SECTION_ASM_OP) \
108   SECTION_FUNCTION_TEMPLATE(dtors_section, in_dtors, DTORS_SECTION_ASM_OP)
109
110 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP)                 \
111 void FN ()                                                      \
112 {                                                               \
113   if (in_section != ENUM)                                       \
114     {                                                           \
115       fprintf (asm_out_file, "%s\n", OP);                       \
116       in_section = ENUM;                                        \
117     }                                                           \
118 }
119
120 /* A C statement (sans semicolon) to output an element in the table of
121    global constructors.  */
122 #undef ASM_OUTPUT_CONSTRUCTOR
123 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)                         \
124   do {                                                            \
125     ctors_section ();                                             \
126     fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word"); \
127     assemble_name (FILE, NAME);                                   \
128     fprintf (FILE, "\n");                                         \
129   } while (0)
130
131
132 /* A C statement (sans semicolon) to output an element in the table of
133    global destructors.  */
134 #undef ASM_OUTPUT_DESTRUCTOR
135 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                          \
136   do {                                                            \
137     dtors_section ();                                             \
138     fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word"); \
139     assemble_name (FILE, NAME);                                   \
140     fprintf (FILE, "\n");                                         \
141   } while (0)
142
143 #undef TARGET_VERSION
144 #if TARGET_ENDIAN_DEFAULT == 0
145 #define TARGET_VERSION fprintf (stderr, " (MIPSel GNU/Linux with ELF)");
146 #else
147 #define TARGET_VERSION fprintf (stderr, " (MIPS GNU/Linux with ELF)");
148 #endif
149
150 #undef MD_EXEC_PREFIX
151 #undef MD_STARTFILE_PREFIX
152
153 /* Required to keep collect2.c happy */
154 #undef OBJECT_FORMAT_COFF
155
156 /* If we don't set MASK_ABICALLS, we can't default to PIC. */
157 #undef TARGET_DEFAULT
158 #define TARGET_DEFAULT (MASK_ABICALLS|MASK_GAS)
159
160 /* Specify predefined symbols in preprocessor.  */
161 #undef CPP_PREDEFINES
162 #if TARGET_ENDIAN_DEFAULT == 0
163 #define CPP_PREDEFINES "-DMIPSEL -D_MIPSEL -Dunix -Dmips -D_mips \
164 -DR3000 -D_R3000 -Dlinux -Asystem=posix -Acpu=mips \
165 -Amachine=mips -D__ELF__ -D__PIC__ -D__pic__"
166 #else
167 #define CPP_PREDEFINES "-DMIPSEB -D_MIPSEB -Dunix -Dmips -D_mips \
168 -DR3000 -D_R3000 -Dlinux -Asystem=posix -Acpu=mips \
169 -Amachine=mips -D__ELF__ -D__PIC__ -D__pic__"
170 #endif
171
172 #undef SUBTARGET_CPP_SIZE_SPEC
173 #define SUBTARGET_CPP_SIZE_SPEC "\
174 %{mabi=32: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \
175 %{mabi=n32: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \
176 %{mabi=64: -D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int} \
177 %{!mabi*: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int}"
178
179 /* We must make -mips3 do what -mlong64 used to do.  */
180 /* ??? If no mipsX option given, but a mabi=X option is, then should set
181    _MIPS_ISA based on the mabi=X option.  */
182 /* ??? If no mabi=X option give, but a mipsX option is, then should set
183    _MIPS_SIM based on the mipsX option.  */
184 /* ??? Same for _MIPS_SZINT.  */
185 /* ??? Same for _MIPS_SZPTR.  */
186 /* ??? Same for __SIZE_TYPE and __PTRDIFF_TYPE.  */
187 #undef SUBTARGET_CPP_SPEC
188 #define SUBTARGET_CPP_SPEC "\
189 %{mfp32: -D_MIPS_FPSET=16} \
190 %{mfp64: -D_MIPS_FPSET=32} \
191 %{!mfp*: -D_MIPS_FPSET=32} \
192 %{mips1: -D_MIPS_ISA=_MIPS_ISA_MIPS1} \
193 %{mips2: -D_MIPS_ISA=_MIPS_ISA_MIPS2} \
194 %{mips3: -D_MIPS_ISA=_MIPS_ISA_MIPS3} \
195 %{mips4: -D_MIPS_ISA=_MIPS_ISA_MIPS4} \
196 %{!mips*: -D_MIPS_ISA=_MIPS_ISA_MIPS1} \
197 %{mabi=32: -D_MIPS_SIM=_MIPS_SIM_ABI32} \
198 %{mabi=n32: -D_ABIN32=2 -D_MIPS_SIM=_ABIN32} \
199 %{mabi=64: -D_ABI64=3 -D_MIPS_SIM=_ABI64} \
200 %{!mabi*: -D_MIPS_SIM=_MIPS_SIM_ABI32}  \
201 %{!mint64: -D_MIPS_SZINT=32}%{mint64: -D_MIPS_SZINT=64} \
202 %{mabi=32: -D_MIPS_SZLONG=32} \
203 %{mabi=n32: -D_MIPS_SZLONG=32} \
204 %{mabi=64: -D_MIPS_SZLONG=64} \
205 %{!mabi*: -D_MIPS_SZLONG=32} \
206 %{mabi=32: -D_MIPS_SZPTR=32} \
207 %{mabi=n32: -D_MIPS_SZPTR=32} \
208 %{mabi=64: -D_MIPS_SZPTR=64} \
209 %{!mabi*: -D_MIPS_SZPTR=32} \
210 %{!mips*: -U__mips -D__mips} \
211 %{mabi=32: -U__mips64} \
212 %{mabi=n32: -D__mips64} \
213 %{mabi=64: -U__mips64} \
214 %{!mabi*: -U__mips64} \
215 %{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \
216 %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \
217 %{pthread:-D_REENTRANT}"
218
219 /* The GNU C++ standard library requires that these macros be defined.  */
220 #undef CPLUSPLUS_CPP_SPEC
221 #define CPLUSPLUS_CPP_SPEC "\
222 -D__LANGUAGE_C_PLUS_PLUS -D_LANGUAGE_C_PLUS_PLUS \
223 -D_GNU_SOURCE %(cpp) \
224 "
225
226 /* From iris5.h */
227 /* -G is incompatible with -KPIC which is the default, so only allow objects
228    in the small data section if the user explicitly asks for it.  */
229 #undef MIPS_DEFAULT_GVALUE
230 #define MIPS_DEFAULT_GVALUE 0
231
232 /* Borrowed from sparc/linux.h */
233 #undef LINK_SPEC
234 #define LINK_SPEC \
235  "%(endian_spec) \
236   %{shared:-shared} \
237   %{!shared: \
238     %{!ibcs: \
239       %{!static: \
240         %{rdynamic:-export-dynamic} \
241         %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
242         %{static:-static}}}"
243
244
245 #undef SUBTARGET_ASM_SPEC
246 #define SUBTARGET_ASM_SPEC "\
247 %{mabi=64: -64} \
248 %{!fno-PIC:%{!fno-pic:-KPIC}} \
249 %{fno-PIC:-non_shared} %{fno-pic:-non_shared}"
250
251 /* The MIPS assembler has different syntax for .set. We set it to
252    .dummy to trap any errors.  */
253 #undef SET_ASM_OP
254 #define SET_ASM_OP "\t.dummy\t"
255
256 #undef ASM_OUTPUT_DEF
257 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
258  do {                                                                   \
259         fputc ( '\t', FILE);                                            \
260         assemble_name (FILE, LABEL1);                                   \
261         fputs ( " = ", FILE);                                           \
262         assemble_name (FILE, LABEL2);                                   \
263         fputc ( '\n', FILE);                                            \
264  } while (0)
265
266 #undef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
267 #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO)     \
268   do {                                                                  \
269         fputc ('\t', FILE);                                             \
270         assemble_name (FILE, SY);                                       \
271         fputc ('=', FILE);                                              \
272         assemble_name (FILE, HI);                                       \
273         fputc ('-', FILE);                                              \
274         assemble_name (FILE, LO);                                       \
275   } while (0)
276
277 #undef ASM_DECLARE_FUNCTION_NAME
278 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)                   \
279   do {                                                                  \
280     if (!flag_inhibit_size_directive)                                   \
281       {                                                                 \
282         fputs ("\t.ent\t", STREAM);                                     \
283         assemble_name (STREAM, NAME);                                   \
284         putc ('\n', STREAM);                                            \
285       }                                                                 \
286     fprintf (STREAM, "\t%s\t ", TYPE_ASM_OP);                           \
287     assemble_name (STREAM, NAME);                                       \
288     putc (',', STREAM);                                                 \
289     fprintf (STREAM, TYPE_OPERAND_FMT, "function");                     \
290     putc ('\n', STREAM);                                                \
291     assemble_name (STREAM, NAME);                                       \
292     fputs (":\n", STREAM);                                              \
293   } while (0)
294
295 #undef ASM_DECLARE_FUNCTION_SIZE
296 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL)                   \
297   do {                                                                  \
298     if (!flag_inhibit_size_directive)                                   \
299       {                                                                 \
300         fputs ("\t.end\t", STREAM);                                     \
301         assemble_name (STREAM, NAME);                                   \
302         putc ('\n', STREAM);                                            \
303       }                                                                 \
304   } while (0)
305
306 /* Tell function_prologue in mips.c that we have already output the .ent/.end
307    pseudo-ops.  */
308 #define FUNCTION_NAME_ALREADY_DECLARED