2002-05-09 Hassan Aurag <aurag@cae.com>
[official-gcc.git] / gcc / config / mips / elf.h
blob5add2f12d604558882b1ec3b24b4bae4e9104449
1 /* Definitions of target machine for GNU compiler. MIPS R3000 version with
2 GOFAST floating point library.
3 Copyright (C) 1994, 1997, 1999, 2000 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)
10 any later version.
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. */
22 /* Use ELF. */
23 #define OBJECT_FORMAT_ELF
25 /* Until we figure out what MIPS ELF targets normally use, just do
26 stabs in ELF. */
27 #ifndef PREFERRED_DEBUGGING_TYPE
28 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
29 #endif
31 /* Mostly like ECOFF. */
32 #include "gofast.h"
33 #include "mips/ecoff.h"
35 /* We need to use .esize and .etype instead of .size and .type to
36 avoid conflicting with ELF directives. */
37 #undef PUT_SDB_SIZE
38 #define PUT_SDB_SIZE(a) \
39 do { \
40 extern FILE *asm_out_text_file; \
41 fprintf (asm_out_text_file, "\t.esize\t"); \
42 fprintf (asm_out_text_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) (a)); \
43 fprintf (asm_out_text_file, ";"); \
44 } while (0)
46 #undef PUT_SDB_TYPE
47 #define PUT_SDB_TYPE(a) \
48 do { \
49 extern FILE *asm_out_text_file; \
50 fprintf (asm_out_text_file, "\t.etype\t0x%x;", (a)); \
51 } while (0)
53 /* Biggest alignment supported by the object file format of this
54 machine. Use this macro to limit the alignment which can be
55 specified using the `__attribute__ ((aligned (N)))' construct. If
56 not defined, the default value is `BIGGEST_ALIGNMENT'. */
58 #undef MAX_OFILE_ALIGNMENT
59 #define MAX_OFILE_ALIGNMENT (32768*8)
61 /* Switch into a generic section. */
62 #undef TARGET_ASM_NAMED_SECTION
63 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
65 /* Given that Irix has it's own headers, not having TARGET_GAS here
66 seems a mistake. If we actually need to be prepared for file
67 switching, then we need a custom TARGET_ASM_NAMED_SECTION too. */
69 #undef TEXT_SECTION
70 #define TEXT_SECTION() \
71 do { \
72 if (TARGET_FILE_SWITCHING) \
73 abort (); \
74 fputs (TEXT_SECTION_ASM_OP, asm_out_file); \
75 fputc ('\n', asm_out_file); \
76 } while (0)
78 /* The following macro defines the format used to output the second
79 operand of the .type assembler directive. Different svr4 assemblers
80 expect various different forms for this operand. The one given here
81 is just a default. You may need to override it in your machine-
82 specific tm.h file (depending upon the particulars of your assembler). */
84 #define TYPE_OPERAND_FMT "@%s"
86 /* Define the strings used for the special svr4 .type and .size directives.
87 These strings generally do not vary from one system running svr4 to
88 another, but if a given system (e.g. m88k running svr) needs to use
89 different pseudo-op names for these, they may be overridden in the
90 file which includes this one. */
92 #undef TYPE_ASM_OP
93 #undef SIZE_ASM_OP
94 #define TYPE_ASM_OP "\t.type\t"
95 #define SIZE_ASM_OP "\t.size\t"
97 /* If defined, a C expression whose value is a string containing the
98 assembler operation to identify the following data as
99 uninitialized global data. If not defined, and neither
100 `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
101 uninitialized global data will be output in the data section if
102 `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
103 used. */
105 #ifndef BSS_SECTION_ASM_OP
106 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
107 #endif
109 #undef SBSS_SECTION_ASM_OP
110 #define SBSS_SECTION_ASM_OP "\t.section .sbss"
112 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
113 separate, explicit argument. If you define this macro, it is used
114 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
115 handling the required alignment of the variable. The alignment is
116 specified as the number of bits.
118 Try to use function `asm_output_aligned_bss' defined in file
119 `varasm.c' when defining this macro. */
120 #ifndef ASM_OUTPUT_ALIGNED_BSS
121 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
122 do { \
123 ASM_GLOBALIZE_LABEL (FILE, NAME); \
124 if (SIZE > 0 && SIZE <= mips_section_threshold) \
125 sbss_section (); \
126 else \
127 bss_section (); \
128 ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT)); \
129 last_assemble_variable_decl = DECL; \
130 ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL); \
131 ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1); \
132 } while (0)
133 #endif
135 /* These macros generate the special .type and .size directives which
136 are used to set the corresponding fields of the linker symbol table
137 entries in an ELF object file under SVR4. These macros also output
138 the starting labels for the relevant functions/objects. */
140 /* Write the extra assembler code needed to declare an object properly. */
142 #undef ASM_DECLARE_OBJECT_NAME
143 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
144 do { \
145 fprintf (FILE, "%s", TYPE_ASM_OP); \
146 assemble_name (FILE, NAME); \
147 putc (',', FILE); \
148 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
149 putc ('\n', FILE); \
150 size_directive_output = 0; \
151 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
153 size_directive_output = 1; \
154 fprintf (FILE, "%s", SIZE_ASM_OP); \
155 assemble_name (FILE, NAME); \
156 fprintf (FILE, ","); \
157 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
158 int_size_in_bytes (TREE_TYPE (DECL))); \
159 fprintf (FILE, "\n"); \
161 mips_declare_object (FILE, NAME, "", ":\n", 0); \
162 } while (0)
164 /* Output the size directive for a decl in rest_of_decl_compilation
165 in the case where we did not do so before the initializer.
166 Once we find the error_mark_node, we know that the value of
167 size_directive_output was set
168 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
170 #undef ASM_FINISH_DECLARE_OBJECT
171 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
172 do { \
173 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
174 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
175 && ! AT_END && TOP_LEVEL \
176 && DECL_INITIAL (DECL) == error_mark_node \
177 && !size_directive_output) \
179 size_directive_output = 1; \
180 fprintf (FILE, "%s", SIZE_ASM_OP); \
181 assemble_name (FILE, name); \
182 fprintf (FILE, ","); \
183 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
184 int_size_in_bytes (TREE_TYPE (DECL))); \
185 fprintf (FILE, "\n"); \
187 } while (0)
189 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
190 do { fputc ( '\t', FILE); \
191 assemble_name (FILE, LABEL1); \
192 fputs ( " = ", FILE); \
193 assemble_name (FILE, LABEL2); \
194 fputc ( '\n', FILE); \
195 } while (0)
197 /* Note about .weak vs. .weakext
198 The mips native assemblers support .weakext, but not .weak.
199 mips-elf gas supports .weak, but not .weakext.
200 mips-elf gas has been changed to support both .weak and .weakext,
201 but until that support is generally available, the 'if' below
202 should serve. */
204 #undef ASM_WEAKEN_LABEL
205 #define ASM_WEAKEN_LABEL(FILE,NAME) ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,0)
206 #define ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,VALUE) \
207 do { \
208 if (TARGET_GAS) \
209 fputs ("\t.weak\t", FILE); \
210 else \
211 fputs ("\t.weakext\t", FILE); \
212 assemble_name (FILE, NAME); \
213 if (VALUE) \
215 fputc (' ', FILE); \
216 assemble_name (FILE, VALUE); \
218 fputc ('\n', FILE); \
219 } while (0)
221 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
222 #undef UNIQUE_SECTION
223 #define UNIQUE_SECTION(DECL,RELOC) \
224 mips_unique_section ((DECL), (RELOC))
226 /* A list of other sections which the compiler might be "in" at any
227 given time. */
228 #undef EXTRA_SECTIONS
229 #define EXTRA_SECTIONS in_sdata, in_sbss, in_rdata
231 #undef EXTRA_SECTION_FUNCTIONS
232 #define EXTRA_SECTION_FUNCTIONS \
233 SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
234 SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \
235 SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
237 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
238 void FN () \
240 if (in_section != ENUM) \
242 fprintf (asm_out_file, "%s\n", OP); \
243 in_section = ENUM; \
247 /* On elf, we *do* have support for the .init and .fini sections, and we
248 can put stuff in there to be executed before and after `main'. We let
249 crtstuff.c and other files know this by defining the following symbols.
250 The definitions say how to change sections to the .init and .fini
251 sections. This is the same for all known elf assemblers. */
253 #undef INIT_SECTION_ASM_OP
254 #define INIT_SECTION_ASM_OP "\t.section\t.init"
255 #undef FINI_SECTION_ASM_OP
256 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
258 /* Don't set the target flags, this is done by the linker script */
259 #undef LIB_SPEC
260 #define LIB_SPEC ""
262 #undef STARTFILE_SPEC
263 #define STARTFILE_SPEC "crti%O%s crtbegin%O%s %{!mno-crt0:crt0%O%s}"
265 #undef ENDFILE_SPEC
266 #define ENDFILE_SPEC "crtend%O%s crtn%O%s"