OSDN Git Service

* config/mips/elf.h (OBJECT_FORMAT_COFF, EXTENDED_COFF): Remove undefs.
[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, 2003
3    Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 #undef WCHAR_TYPE
23 #define WCHAR_TYPE "int"
24
25 #undef WCHAR_TYPE_SIZE
26 #define WCHAR_TYPE_SIZE 32
27
28 /* If defined, a C expression whose value is a string containing the
29    assembler operation to identify the following data as
30    uninitialized global data.  If not defined, and neither
31    `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
32    uninitialized global data will be output in the data section if
33    `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
34    used.  */
35 #define BSS_SECTION_ASM_OP      "\t.section\t.bss"
36
37 #define SBSS_SECTION_ASM_OP     "\t.section .sbss"
38
39 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
40    separate, explicit argument.  If you define this macro, it is used
41    in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
42    handling the required alignment of the variable.  The alignment is
43    specified as the number of bits.
44
45    Try to use function `asm_output_aligned_bss' defined in file
46    `varasm.c' when defining this macro.  */
47 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN)   \
48 do {                                                            \
49   if (SIZE > 0 && (long)(SIZE) <= mips_section_threshold)       \
50     named_section (0, ".sbss", 0);                              \
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 #undef TARGET_VERSION
82 #if TARGET_ENDIAN_DEFAULT == 0
83 #define TARGET_VERSION fprintf (stderr, " (MIPSel GNU/Linux with ELF)");
84 #else
85 #define TARGET_VERSION fprintf (stderr, " (MIPS GNU/Linux with ELF)");
86 #endif
87
88 #undef MD_EXEC_PREFIX
89 #undef MD_STARTFILE_PREFIX
90
91 /* If we don't set MASK_ABICALLS, we can't default to PIC.  */
92 #undef TARGET_DEFAULT
93 #define TARGET_DEFAULT (MASK_ABICALLS|MASK_GAS)
94
95 #define TARGET_OS_CPP_BUILTINS()                                \
96     do {                                                        \
97         builtin_define ("__gnu_linux__");                       \
98         builtin_define ("__PIC__");                             \
99         builtin_define ("__pic__");                             \
100         builtin_define_std ("unix");                            \
101         builtin_define_std ("linux");                           \
102         builtin_assert ("system=linux");                        \
103         /* The GNU C++ standard library requires this.  */      \
104         if (c_dialect_cxx ())                                   \
105           builtin_define ("_GNU_SOURCE");                       \
106                                                                 \
107       if (mips_abi == ABI_N32)                                  \
108       {                                                         \
109         builtin_define ("_ABIN32=2");                           \
110         builtin_define ("_MIPS_SIM=_ABIN32");                   \
111         builtin_define ("_MIPS_SZLONG=32");                     \
112         builtin_define ("_MIPS_SZPTR=32");                      \
113       }                                                         \
114      else if (mips_abi == ABI_64)                               \
115       {                                                         \
116         builtin_define ("_ABI64=3");                            \
117         builtin_define ("_MIPS_SIM=_ABI64");                    \
118         builtin_define ("_MIPS_SZLONG=64");                     \
119         builtin_define ("_MIPS_SZPTR=64");                      \
120       }                                                         \
121      else                                                       \
122       {                                                         \
123         builtin_define ("_MIPS_SIM=_MIPS_SIM_ABI32");           \
124         builtin_define ("_MIPS_SZLONG=32");                     \
125         builtin_define ("_MIPS_SZPTR=32");                      \
126       }                                                         \
127      if (TARGET_FLOAT64)                                        \
128         builtin_define ("_MIPS_FPSET=32");                      \
129      else                                                       \
130         builtin_define ("_MIPS_FPSET=16");                      \
131                                                                 \
132      if (TARGET_INT64)                                          \
133         builtin_define ("_MIPS_SZINT=64");                      \
134      else                                                       \
135         builtin_define ("_MIPS_SZINT=32");                      \
136 } while (0)
137
138 #undef  SUBTARGET_CPP_SPEC
139 #define SUBTARGET_CPP_SPEC "\
140 %{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \
141 %{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} \
142 %{pthread:-D_REENTRANT}"
143
144 /* From iris5.h */
145 /* -G is incompatible with -KPIC which is the default, so only allow objects
146    in the small data section if the user explicitly asks for it.  */
147 #undef MIPS_DEFAULT_GVALUE
148 #define MIPS_DEFAULT_GVALUE 0
149
150 /* Borrowed from sparc/linux.h */
151 #undef LINK_SPEC
152 #define LINK_SPEC \
153  "%(endian_spec) \
154   %{shared:-shared} \
155   %{!shared: \
156     %{!ibcs: \
157       %{!static: \
158         %{rdynamic:-export-dynamic} \
159         %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
160         %{static:-static}}}"
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 #undef  SUBTARGET_ASM_DEBUGGING_SPEC
169 #define SUBTARGET_ASM_DEBUGGING_SPEC "-g0"
170
171 /* The MIPS assembler has different syntax for .set. We set it to
172    .dummy to trap any errors.  */
173 #undef SET_ASM_OP
174 #define SET_ASM_OP "\t.dummy\t"
175
176 #undef ASM_OUTPUT_DEF
177 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
178  do {                                                                   \
179         fputc ( '\t', FILE);                                            \
180         assemble_name (FILE, LABEL1);                                   \
181         fputs ( " = ", FILE);                                           \
182         assemble_name (FILE, LABEL2);                                   \
183         fputc ( '\n', FILE);                                            \
184  } while (0)
185
186 #undef ASM_DECLARE_FUNCTION_NAME
187 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)                   \
188   do {                                                                  \
189     if (!flag_inhibit_size_directive)                                   \
190       {                                                                 \
191         fputs ("\t.ent\t", STREAM);                                     \
192         assemble_name (STREAM, NAME);                                   \
193         putc ('\n', STREAM);                                            \
194       }                                                                 \
195     ASM_OUTPUT_TYPE_DIRECTIVE (STREAM, NAME, "function");               \
196     assemble_name (STREAM, NAME);                                       \
197     fputs (":\n", STREAM);                                              \
198   } while (0)
199
200 #undef ASM_DECLARE_FUNCTION_SIZE
201 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL)                   \
202   do {                                                                  \
203     if (!flag_inhibit_size_directive)                                   \
204       {                                                                 \
205         fputs ("\t.end\t", STREAM);                                     \
206         assemble_name (STREAM, NAME);                                   \
207         putc ('\n', STREAM);                                            \
208       }                                                                 \
209   } while (0)
210
211 /* Tell function_prologue in mips.c that we have already output the .ent/.end
212    pseudo-ops.  */
213 #define FUNCTION_NAME_ALREADY_DECLARED
214
215 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL)                      \
216   (flag_pic                                                             \
217     ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4\
218    : DW_EH_PE_absptr)
219
220 /* The glibc _mcount stub will save $v0 for us.  Don't mess with saving
221    it, since ASM_OUTPUT_REG_PUSH/ASM_OUTPUT_REG_POP do not work in the
222    presence of $gp-relative calls.  */
223 #undef ASM_OUTPUT_REG_PUSH
224 #undef ASM_OUTPUT_REG_POP
225
226 #undef LIB_SPEC
227 #define LIB_SPEC "\
228 %{shared: -lc} \
229 %{!static:-rpath-link %R/lib:%R/usr/lib} \
230 %{!shared: %{pthread:-lpthread} \
231   %{profile:-lc_p} %{!profile: -lc}}"