1 /* Definitions of target machine for GNU compiler. MIPS R3000 version with
2 GOFAST floating point library.
3 Copyright (C) 1994, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
5 This file is part of GNU CC.
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)
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.
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. */
23 #define OBJECT_FORMAT_ELF
25 /* All ELF targets can support DWARF-2. */
27 #ifndef DWARF2_DEBUGGING_INFO
28 #define DWARF2_DEBUGGING_INFO 1
31 /* Until we figure out what MIPS ELF targets normally use, just do
33 #ifndef PREFERRED_DEBUGGING_TYPE
34 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
37 /* Mostly like ECOFF. */
39 #include "mips/ecoff.h"
41 /* We need to use .esize and .etype instead of .size and .type to
42 avoid conflicting with ELF directives. */
44 #define PUT_SDB_SIZE(a) \
46 extern FILE *asm_out_text_file; \
47 fprintf (asm_out_text_file, "\t.esize\t"); \
48 fprintf (asm_out_text_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) (a)); \
49 fprintf (asm_out_text_file, ";"); \
53 #define PUT_SDB_TYPE(a) \
55 extern FILE *asm_out_text_file; \
56 fprintf (asm_out_text_file, "\t.etype\t0x%x;", (a)); \
59 /* Biggest alignment supported by the object file format of this
60 machine. Use this macro to limit the alignment which can be
61 specified using the `__attribute__ ((aligned (N)))' construct. If
62 not defined, the default value is `BIGGEST_ALIGNMENT'. */
64 #undef MAX_OFILE_ALIGNMENT
65 #define MAX_OFILE_ALIGNMENT (32768*8)
67 /* Switch into a generic section. */
68 #undef TARGET_ASM_NAMED_SECTION
69 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
71 /* Given that Irix has it's own headers, not having TARGET_GAS here
72 seems a mistake. If we actually need to be prepared for file
73 switching, then we need a custom TARGET_ASM_NAMED_SECTION too. */
76 #define TEXT_SECTION() \
78 if (TARGET_FILE_SWITCHING) \
80 fputs (TEXT_SECTION_ASM_OP, asm_out_file); \
81 fputc ('\n', asm_out_file); \
84 /* The following macro defines the format used to output the second
85 operand of the .type assembler directive. Different svr4 assemblers
86 expect various different forms for this operand. The one given here
87 is just a default. You may need to override it in your machine-
88 specific tm.h file (depending upon the particulars of your assembler). */
90 #define TYPE_OPERAND_FMT "@%s"
92 /* Define the strings used for the special svr4 .type and .size directives.
93 These strings generally do not vary from one system running svr4 to
94 another, but if a given system (e.g. m88k running svr) needs to use
95 different pseudo-op names for these, they may be overridden in the
96 file which includes this one. */
100 #define TYPE_ASM_OP "\t.type\t"
101 #define SIZE_ASM_OP "\t.size\t"
103 /* If defined, a C expression whose value is a string containing the
104 assembler operation to identify the following data as
105 uninitialized global data. If not defined, and neither
106 `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
107 uninitialized global data will be output in the data section if
108 `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
111 #ifndef BSS_SECTION_ASM_OP
112 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
115 #undef SBSS_SECTION_ASM_OP
116 #define SBSS_SECTION_ASM_OP "\t.section .sbss"
118 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
119 separate, explicit argument. If you define this macro, it is used
120 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
121 handling the required alignment of the variable. The alignment is
122 specified as the number of bits.
124 Try to use function `asm_output_aligned_bss' defined in file
125 `varasm.c' when defining this macro. */
126 #ifndef ASM_OUTPUT_ALIGNED_BSS
127 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
129 ASM_GLOBALIZE_LABEL (FILE, NAME); \
130 if (SIZE > 0 && SIZE <= mips_section_threshold) \
134 ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT)); \
135 last_assemble_variable_decl = DECL; \
136 ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL); \
137 ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1); \
141 /* These macros generate the special .type and .size directives which
142 are used to set the corresponding fields of the linker symbol table
143 entries in an ELF object file under SVR4. These macros also output
144 the starting labels for the relevant functions/objects. */
146 /* Write the extra assembler code needed to declare an object properly. */
148 #undef ASM_DECLARE_OBJECT_NAME
149 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
151 fprintf (FILE, "%s", TYPE_ASM_OP); \
152 assemble_name (FILE, NAME); \
154 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
156 size_directive_output = 0; \
157 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
159 size_directive_output = 1; \
160 fprintf (FILE, "%s", SIZE_ASM_OP); \
161 assemble_name (FILE, NAME); \
162 fprintf (FILE, ","); \
163 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
164 int_size_in_bytes (TREE_TYPE (DECL))); \
165 fprintf (FILE, "\n"); \
167 mips_declare_object (FILE, NAME, "", ":\n", 0); \
170 /* Output the size directive for a decl in rest_of_decl_compilation
171 in the case where we did not do so before the initializer.
172 Once we find the error_mark_node, we know that the value of
173 size_directive_output was set
174 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
176 #undef ASM_FINISH_DECLARE_OBJECT
177 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
179 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
180 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
181 && ! AT_END && TOP_LEVEL \
182 && DECL_INITIAL (DECL) == error_mark_node \
183 && !size_directive_output) \
185 size_directive_output = 1; \
186 fprintf (FILE, "%s", SIZE_ASM_OP); \
187 assemble_name (FILE, name); \
188 fprintf (FILE, ","); \
189 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
190 int_size_in_bytes (TREE_TYPE (DECL))); \
191 fprintf (FILE, "\n"); \
195 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
196 do { fputc ( '\t', FILE); \
197 assemble_name (FILE, LABEL1); \
198 fputs ( " = ", FILE); \
199 assemble_name (FILE, LABEL2); \
200 fputc ( '\n', FILE); \
203 /* Note about .weak vs. .weakext
204 The mips native assemblers support .weakext, but not .weak.
205 mips-elf gas supports .weak, but not .weakext.
206 mips-elf gas has been changed to support both .weak and .weakext,
207 but until that support is generally available, the 'if' below
210 #undef ASM_WEAKEN_LABEL
211 #define ASM_WEAKEN_LABEL(FILE,NAME) ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,0)
212 #define ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,VALUE) \
215 fputs ("\t.weak\t", FILE); \
217 fputs ("\t.weakext\t", FILE); \
218 assemble_name (FILE, NAME); \
222 assemble_name (FILE, VALUE); \
224 fputc ('\n', FILE); \
227 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
229 #define TARGET_ASM_UNIQUE_SECTION mips_unique_section
231 /* A list of other sections which the compiler might be "in" at any
233 #undef EXTRA_SECTIONS
234 #define EXTRA_SECTIONS in_sdata, in_sbss
236 #undef EXTRA_SECTION_FUNCTIONS
237 #define EXTRA_SECTION_FUNCTIONS \
238 SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
239 SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP)
241 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
244 if (in_section != ENUM) \
246 fprintf (asm_out_file, "%s\n", OP); \
251 /* On elf, we *do* have support for the .init and .fini sections, and we
252 can put stuff in there to be executed before and after `main'. We let
253 crtstuff.c and other files know this by defining the following symbols.
254 The definitions say how to change sections to the .init and .fini
255 sections. This is the same for all known elf assemblers. */
257 #undef INIT_SECTION_ASM_OP
258 #define INIT_SECTION_ASM_OP "\t.section\t.init"
259 #undef FINI_SECTION_ASM_OP
260 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
262 /* Don't set the target flags, this is done by the linker script */
266 #undef STARTFILE_SPEC
267 #define STARTFILE_SPEC "crti%O%s crtbegin%O%s %{!mno-crt0:crt0%O%s}"
270 #define ENDFILE_SPEC "crtend%O%s crtn%O%s"