1 /* Definitions for MIPS running Linux-based GNU systems with ELF format.
2 Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
4 This file is part of GNU CC.
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)
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.
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. */
21 #include "mips/mips.h"
22 #include "mips/abi64.h"
25 #define WCHAR_TYPE "int"
27 #undef WCHAR_TYPE_SIZE
28 #define WCHAR_TYPE_SIZE 32
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
37 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
39 #define SBSS_SECTION_ASM_OP "\t.section .sbss"
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.
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) \
51 ASM_GLOBALIZE_LABEL (FILE, NAME); \
52 if (SIZE > 0 && SIZE <= mips_section_threshold) \
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); \
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. */
67 /* Write the extra assembler code needed to declare an object properly. */
69 #undef ASM_DECLARE_OBJECT_NAME
70 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
72 fprintf (FILE, "%s", TYPE_ASM_OP); \
73 assemble_name (FILE, NAME); \
75 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
77 size_directive_output = 0; \
78 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
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"); \
88 mips_declare_object (FILE, NAME, "", ":\n", 0); \
91 #define TARGET_ASM_UNIQUE_SECTION mips_unique_section
93 /* A list of other sections which the compiler might be "in" at any
96 #define EXTRA_SECTIONS in_sdata, in_sbss
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)
103 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
106 if (in_section != ENUM) \
108 fprintf (asm_out_file, "%s\n", OP); \
113 #undef TARGET_VERSION
114 #if TARGET_ENDIAN_DEFAULT == 0
115 #define TARGET_VERSION fprintf (stderr, " (MIPSel GNU/Linux with ELF)");
117 #define TARGET_VERSION fprintf (stderr, " (MIPS GNU/Linux with ELF)");
120 #undef MD_EXEC_PREFIX
121 #undef MD_STARTFILE_PREFIX
123 /* Required to keep collect2.c happy */
124 #undef OBJECT_FORMAT_COFF
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)
130 /* Specify predefined symbols in preprocessor. */
131 #undef CPP_PREDEFINES
132 #if TARGET_ENDIAN_DEFAULT == 0
133 #define CPP_PREDEFINES "-DMIPSEL -D_MIPSEL -Dunix -Dmips -D_mips \
134 -DR3000 -D_R3000 -D__gnu_linux__ -Dlinux -Asystem=posix -Acpu=mips \
135 -Amachine=mips -D__ELF__ -D__PIC__ -D__pic__"
137 #define CPP_PREDEFINES "-DMIPSEB -D_MIPSEB -Dunix -Dmips -D_mips \
138 -DR3000 -D_R3000 -D__gnu_linux__ -Dlinux -Asystem=posix -Acpu=mips \
139 -Amachine=mips -D__ELF__ -D__PIC__ -D__pic__"
142 /* We must make -mips3 do what -mlong64 used to do. */
143 /* ??? If no mipsX option given, but a mabi=X option is, then should set
144 _MIPS_ISA based on the mabi=X option. */
145 /* ??? If no mabi=X option give, but a mipsX option is, then should set
146 _MIPS_SIM based on the mipsX option. */
147 /* ??? Same for _MIPS_SZINT. */
148 /* ??? Same for _MIPS_SZPTR. */
149 #undef SUBTARGET_CPP_SPEC
150 #define SUBTARGET_CPP_SPEC "\
151 %{mfp32: -D_MIPS_FPSET=16} \
152 %{mfp64: -D_MIPS_FPSET=32} \
153 %{!mfp*: -D_MIPS_FPSET=32} \
154 %{mips1: -D_MIPS_ISA=_MIPS_ISA_MIPS1} \
155 %{mips2: -D_MIPS_ISA=_MIPS_ISA_MIPS2} \
156 %{mips3: -D_MIPS_ISA=_MIPS_ISA_MIPS3} \
157 %{mips4: -D_MIPS_ISA=_MIPS_ISA_MIPS4} \
158 %{!mips*: -D_MIPS_ISA=_MIPS_ISA_MIPS1} \
159 %{mabi=32: -D_MIPS_SIM=_MIPS_SIM_ABI32} \
160 %{mabi=n32: -D_ABIN32=2 -D_MIPS_SIM=_ABIN32} \
161 %{mabi=64: -D_ABI64=3 -D_MIPS_SIM=_ABI64} \
162 %{!mabi*: -D_MIPS_SIM=_MIPS_SIM_ABI32} \
163 %{!mint64: -D_MIPS_SZINT=32}%{mint64: -D_MIPS_SZINT=64} \
164 %{mabi=32: -D_MIPS_SZLONG=32} \
165 %{mabi=n32: -D_MIPS_SZLONG=32} \
166 %{mabi=64: -D_MIPS_SZLONG=64} \
167 %{!mabi*: -D_MIPS_SZLONG=32} \
168 %{mabi=32: -D_MIPS_SZPTR=32} \
169 %{mabi=n32: -D_MIPS_SZPTR=32} \
170 %{mabi=64: -D_MIPS_SZPTR=64} \
171 %{!mabi*: -D_MIPS_SZPTR=32} \
172 %{!mips*: -U__mips -D__mips} \
173 %{mabi=32: -U__mips64} \
174 %{mabi=n32: -D__mips64} \
175 %{mabi=64: -U__mips64} \
176 %{!mabi*: -U__mips64} \
177 %{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \
178 %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \
179 %{pthread:-D_REENTRANT}"
181 /* The GNU C++ standard library requires that these macros be defined. */
182 #undef CPLUSPLUS_CPP_SPEC
183 #define CPLUSPLUS_CPP_SPEC "\
184 -D__LANGUAGE_C_PLUS_PLUS -D_LANGUAGE_C_PLUS_PLUS \
185 -D_GNU_SOURCE %(cpp) \
189 /* -G is incompatible with -KPIC which is the default, so only allow objects
190 in the small data section if the user explicitly asks for it. */
191 #undef MIPS_DEFAULT_GVALUE
192 #define MIPS_DEFAULT_GVALUE 0
194 /* Borrowed from sparc/linux.h */
202 %{rdynamic:-export-dynamic} \
203 %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
207 #undef SUBTARGET_ASM_SPEC
208 #define SUBTARGET_ASM_SPEC "\
210 %{!fno-PIC:%{!fno-pic:-KPIC}} \
211 %{fno-PIC:-non_shared} %{fno-pic:-non_shared}"
213 #undef SUBTARGET_ASM_DEBUGGING_SPEC
214 #define SUBTARGET_ASM_DEBUGGING_SPEC "-g0"
216 /* The MIPS assembler has different syntax for .set. We set it to
217 .dummy to trap any errors. */
219 #define SET_ASM_OP "\t.dummy\t"
221 #undef ASM_OUTPUT_DEF
222 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
224 fputc ( '\t', FILE); \
225 assemble_name (FILE, LABEL1); \
226 fputs ( " = ", FILE); \
227 assemble_name (FILE, LABEL2); \
228 fputc ( '\n', FILE); \
231 #undef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
232 #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO) \
234 fputc ('\t', FILE); \
235 assemble_name (FILE, SY); \
237 assemble_name (FILE, HI); \
239 assemble_name (FILE, LO); \
242 #undef ASM_DECLARE_FUNCTION_NAME
243 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
245 if (!flag_inhibit_size_directive) \
247 fputs ("\t.ent\t", STREAM); \
248 assemble_name (STREAM, NAME); \
249 putc ('\n', STREAM); \
251 fprintf (STREAM, "\t%s\t ", TYPE_ASM_OP); \
252 assemble_name (STREAM, NAME); \
253 putc (',', STREAM); \
254 fprintf (STREAM, TYPE_OPERAND_FMT, "function"); \
255 putc ('\n', STREAM); \
256 assemble_name (STREAM, NAME); \
257 fputs (":\n", STREAM); \
260 #undef ASM_DECLARE_FUNCTION_SIZE
261 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \
263 if (!flag_inhibit_size_directive) \
265 fputs ("\t.end\t", STREAM); \
266 assemble_name (STREAM, NAME); \
267 putc ('\n', STREAM); \
271 /* Tell function_prologue in mips.c that we have already output the .ent/.end
273 #define FUNCTION_NAME_ALREADY_DECLARED
275 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
277 ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4\
280 /* The glibc _mcount stub will save $v0 for us. Don't mess with saving
281 it, since ASM_OUTPUT_REG_PUSH/ASM_OUTPUT_REG_POP do not work in the
282 presence of $gp-relative calls. */
283 #undef ASM_OUTPUT_REG_PUSH
284 #undef ASM_OUTPUT_REG_POP
286 /* The current Linux binutils uses MIPS_STABS_ELF and doesn't support
288 #undef SDB_DEBUGGING_INFO