OSDN Git Service

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