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 HOST_WIDE_INT size; \
152 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
153 size_directive_output = 0; \
154 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
156 size_directive_output = 1; \
157 size = int_size_in_bytes (TREE_TYPE (DECL)); \
158 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
160 mips_declare_object (FILE, NAME, "", ":\n", 0); \
163 /* Output the size directive for a decl in rest_of_decl_compilation
164 in the case where we did not do so before the initializer.
165 Once we find the error_mark_node, we know that the value of
166 size_directive_output was set
167 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
169 #undef ASM_FINISH_DECLARE_OBJECT
170 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
172 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
173 HOST_WIDE_INT size; \
175 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
176 && ! AT_END && TOP_LEVEL \
177 && DECL_INITIAL (DECL) == error_mark_node \
178 && !size_directive_output) \
180 size_directive_output = 1; \
181 size = int_size_in_bytes (TREE_TYPE (DECL)); \
182 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \
186 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
187 do { fputc ( '\t', FILE); \
188 assemble_name (FILE, LABEL1); \
189 fputs ( " = ", FILE); \
190 assemble_name (FILE, LABEL2); \
191 fputc ( '\n', FILE); \
194 /* Note about .weak vs. .weakext
195 The mips native assemblers support .weakext, but not .weak.
196 mips-elf gas supports .weak, but not .weakext.
197 mips-elf gas has been changed to support both .weak and .weakext,
198 but until that support is generally available, the 'if' below
201 #undef ASM_WEAKEN_LABEL
202 #define ASM_WEAKEN_LABEL(FILE,NAME) ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,0)
203 #define ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,VALUE) \
206 fputs ("\t.weak\t", FILE); \
208 fputs ("\t.weakext\t", FILE); \
209 assemble_name (FILE, NAME); \
213 assemble_name (FILE, VALUE); \
215 fputc ('\n', FILE); \
218 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
220 #define TARGET_ASM_UNIQUE_SECTION mips_unique_section
222 /* A list of other sections which the compiler might be "in" at any
224 #undef EXTRA_SECTIONS
225 #define EXTRA_SECTIONS in_sdata, in_sbss
227 #undef EXTRA_SECTION_FUNCTIONS
228 #define EXTRA_SECTION_FUNCTIONS \
229 SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
230 SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP)
232 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
235 if (in_section != ENUM) \
237 fprintf (asm_out_file, "%s\n", OP); \
242 /* On elf, we *do* have support for the .init and .fini sections, and we
243 can put stuff in there to be executed before and after `main'. We let
244 crtstuff.c and other files know this by defining the following symbols.
245 The definitions say how to change sections to the .init and .fini
246 sections. This is the same for all known elf assemblers. */
248 #undef INIT_SECTION_ASM_OP
249 #define INIT_SECTION_ASM_OP "\t.section\t.init"
250 #undef FINI_SECTION_ASM_OP
251 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
253 /* Don't set the target flags, this is done by the linker script */
257 #undef STARTFILE_SPEC
258 #define STARTFILE_SPEC "crti%O%s crtbegin%O%s %{!mno-crt0:crt0%O%s}"
261 #define ENDFILE_SPEC "crtend%O%s crtn%O%s"