OSDN Git Service

* config.gcc: Don't include mips/abi64.h in $tm_file.
[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, 2002 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 WCHAR_TYPE
22 #define WCHAR_TYPE "int"
23
24 #undef WCHAR_TYPE_SIZE
25 #define WCHAR_TYPE_SIZE 32
26
27 /* If defined, a C expression whose value is a string containing the
28    assembler operation to identify the following data as
29    uninitialized global data.  If not defined, and neither
30    `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
31    uninitialized global data will be output in the data section if
32    `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
33    used.  */
34 #define BSS_SECTION_ASM_OP      "\t.section\t.bss"
35
36 #define SBSS_SECTION_ASM_OP     "\t.section .sbss"
37
38 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
39    separate, explicit argument.  If you define this macro, it is used
40    in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
41    handling the required alignment of the variable.  The alignment is
42    specified as the number of bits.
43
44    Try to use function `asm_output_aligned_bss' defined in file
45    `varasm.c' when defining this macro.  */
46 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN)   \
47 do {                                                            \
48   ASM_GLOBALIZE_LABEL (FILE, NAME);                             \
49   if (SIZE > 0 && SIZE <= mips_section_threshold)               \
50     sbss_section ();                                            \
51   else                                                          \
52     bss_section ();                                             \
53   ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT));  \
54   last_assemble_variable_decl = DECL;                           \
55   ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL);                   \
56   ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1);                      \
57 } while (0)
58
59 /* These macros generate the special .type and .size directives which
60    are used to set the corresponding fields of the linker symbol table
61    entries in an ELF object file under SVR4.  These macros also output
62    the starting labels for the relevant functions/objects.  */
63
64 /* Write the extra assembler code needed to declare an object properly.  */
65
66 #undef ASM_DECLARE_OBJECT_NAME
67 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                       \
68   do {                                                                  \
69     HOST_WIDE_INT size;                                                 \
70     ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");                   \
71     size_directive_output = 0;                                          \
72     if (!flag_inhibit_size_directive && DECL_SIZE (DECL))               \
73       {                                                                 \
74         size_directive_output = 1;                                      \
75         size = int_size_in_bytes (TREE_TYPE (DECL));                    \
76         ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);                   \
77       }                                                                 \
78     mips_declare_object (FILE, NAME, "", ":\n", 0);                     \
79   } while (0)
80
81 #define TARGET_ASM_UNIQUE_SECTION  mips_unique_section
82
83 /* A list of other sections which the compiler might be "in" at any
84    given time.  */
85 #undef EXTRA_SECTIONS
86 #define EXTRA_SECTIONS in_sdata, in_sbss
87
88 #undef EXTRA_SECTION_FUNCTIONS
89 #define EXTRA_SECTION_FUNCTIONS                                         \
90   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
91   SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP)
92
93 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP)                 \
94 void FN ()                                                      \
95 {                                                               \
96   if (in_section != ENUM)                                       \
97     {                                                           \
98       fprintf (asm_out_file, "%s\n", OP);                       \
99       in_section = ENUM;                                        \
100     }                                                           \
101 }
102
103 #undef TARGET_VERSION
104 #if TARGET_ENDIAN_DEFAULT == 0
105 #define TARGET_VERSION fprintf (stderr, " (MIPSel GNU/Linux with ELF)");
106 #else
107 #define TARGET_VERSION fprintf (stderr, " (MIPS GNU/Linux with ELF)");
108 #endif
109
110 #undef MD_EXEC_PREFIX
111 #undef MD_STARTFILE_PREFIX
112
113 /* Required to keep collect2.c happy */
114 #undef OBJECT_FORMAT_COFF
115
116 /* If we don't set MASK_ABICALLS, we can't default to PIC.  */
117 #undef TARGET_DEFAULT
118 #define TARGET_DEFAULT (MASK_ABICALLS|MASK_GAS)
119
120 #define TARGET_OS_CPP_BUILTINS()                                \
121     do {                                                        \
122         builtin_define ("__gnu_linux__");                       \
123         builtin_define ("__ELF__");                             \
124         builtin_define ("__PIC__");                             \
125         builtin_define ("__pic__");                             \
126         builtin_define_std ("unix");                            \
127         builtin_define_std ("linux");                           \
128         builtin_assert ("system=linux");                        \
129         /* The GNU C++ standard library requires this.  */      \
130         if (c_language = clk_cplusplus)                         \
131           builtin_define ("_GNU_SOURCE");                       \
132                                                                 \
133       if (mips_abi == ABI_N32)                                  \
134       {                                                         \
135         builtin_define ("_ABIN32=2");                           \
136         builtin_define ("_MIPS_SIM=_ABIN32");                   \
137         builtin_define ("_MIPS_SZLONG=32");                     \
138         builtin_define ("_MIPS_SZPTR=32");                      \
139       }                                                         \
140      else if (mips_abi == ABI_64)                               \
141       {                                                         \
142         builtin_define ("_ABI64=3");                            \
143         builtin_define ("_MIPS_SIM=_ABI64");                    \
144         builtin_define ("_MIPS_SZLONG=64");                     \
145         builtin_define ("_MIPS_SZPTR=64");                      \
146       }                                                         \
147      else                                                       \
148       {                                                         \
149         builtin_define ("_MIPS_SIM=_MIPS_SIM_ABI32");           \
150         builtin_define ("_MIPS_SZLONG=32");                     \
151         builtin_define ("_MIPS_SZPTR=32");                      \
152       }                                                         \
153      if (TARGET_FLOAT64)                                        \
154         builtin_define ("_MIPS_FPSET=32");                      \
155      else                                                       \
156         builtin_define ("_MIPS_FPSET=16");                      \
157                                                                 \
158      if (TARGET_INT64)                                          \
159         builtin_define ("_MIPS_SZINT=64");                      \
160      else                                                       \
161         builtin_define ("_MIPS_SZINT=32");                      \
162 } while (0)
163
164 #undef  SUBTARGET_CPP_SPEC
165 #define SUBTARGET_CPP_SPEC "\
166 %{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \
167 %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \
168 %{pthread:-D_REENTRANT}"
169
170 /* From iris5.h */
171 /* -G is incompatible with -KPIC which is the default, so only allow objects
172    in the small data section if the user explicitly asks for it.  */
173 #undef MIPS_DEFAULT_GVALUE
174 #define MIPS_DEFAULT_GVALUE 0
175
176 /* Borrowed from sparc/linux.h */
177 #undef LINK_SPEC
178 #define LINK_SPEC \
179  "%(endian_spec) \
180   %{shared:-shared} \
181   %{!shared: \
182     %{!ibcs: \
183       %{!static: \
184         %{rdynamic:-export-dynamic} \
185         %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
186         %{static:-static}}}"
187
188 #undef SUBTARGET_ASM_SPEC
189 #define SUBTARGET_ASM_SPEC "\
190 %{mabi=64: -64} \
191 %{!fno-PIC:%{!fno-pic:-KPIC}} \
192 %{fno-PIC:-non_shared} %{fno-pic:-non_shared}"
193
194 #undef  SUBTARGET_ASM_DEBUGGING_SPEC
195 #define SUBTARGET_ASM_DEBUGGING_SPEC "-g0"
196
197 /* The MIPS assembler has different syntax for .set. We set it to
198    .dummy to trap any errors.  */
199 #undef SET_ASM_OP
200 #define SET_ASM_OP "\t.dummy\t"
201
202 #undef ASM_OUTPUT_DEF
203 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
204  do {                                                                   \
205         fputc ( '\t', FILE);                                            \
206         assemble_name (FILE, LABEL1);                                   \
207         fputs ( " = ", FILE);                                           \
208         assemble_name (FILE, LABEL2);                                   \
209         fputc ( '\n', FILE);                                            \
210  } while (0)
211
212 #undef ASM_DECLARE_FUNCTION_NAME
213 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)                   \
214   do {                                                                  \
215     if (!flag_inhibit_size_directive)                                   \
216       {                                                                 \
217         fputs ("\t.ent\t", STREAM);                                     \
218         assemble_name (STREAM, NAME);                                   \
219         putc ('\n', STREAM);                                            \
220       }                                                                 \
221     ASM_OUTPUT_TYPE_DIRECTIVE (STREAM, NAME, "function");               \
222     assemble_name (STREAM, NAME);                                       \
223     fputs (":\n", STREAM);                                              \
224   } while (0)
225
226 #undef ASM_DECLARE_FUNCTION_SIZE
227 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL)                   \
228   do {                                                                  \
229     if (!flag_inhibit_size_directive)                                   \
230       {                                                                 \
231         fputs ("\t.end\t", STREAM);                                     \
232         assemble_name (STREAM, NAME);                                   \
233         putc ('\n', STREAM);                                            \
234       }                                                                 \
235   } while (0)
236
237 /* Tell function_prologue in mips.c that we have already output the .ent/.end
238    pseudo-ops.  */
239 #define FUNCTION_NAME_ALREADY_DECLARED
240
241 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL)                      \
242   (flag_pic                                                             \
243     ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4\
244    : DW_EH_PE_absptr)
245
246 /* The glibc _mcount stub will save $v0 for us.  Don't mess with saving
247    it, since ASM_OUTPUT_REG_PUSH/ASM_OUTPUT_REG_POP do not work in the
248    presence of $gp-relative calls.  */
249 #undef ASM_OUTPUT_REG_PUSH
250 #undef ASM_OUTPUT_REG_POP
251
252 /* The current Linux binutils uses MIPS_STABS_ELF and doesn't support
253    COFF.  */
254 #undef SDB_DEBUGGING_INFO