OSDN Git Service

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