]> gcc.gnu.org Git - gcc.git/blob - gcc/config/mips/elf64.h
Fix irix5 native build failure resulting from my previous patch.
[gcc.git] / gcc / config / mips / elf64.h
1 /* Definitions of target machine for GNU compiler. MIPS R4000 version with
2 GOFAST floating point library.
3 Copyright (C) 1994, 1995, 1996, 1997, 1999 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 #define OBJECT_FORMAT_ELF
23
24 /* Default to -mips3. */
25 #define TARGET_DEFAULT MASK_FLOAT64|MASK_64BIT
26 #define MIPS_ISA_DEFAULT 3
27
28 /* Until we figure out what MIPS ELF targets normally use, just do
29 stabs in ELF. */
30 #ifndef PREFERRED_DEBUGGING_TYPE
31 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
32 #endif
33
34 /* US Software GOFAST library support. */
35 #include "gofast.h"
36 #define INIT_SUBTARGET_OPTABS INIT_GOFAST_OPTABS
37
38 #include "mips/mips.h"
39
40 /* This must be done after mips.h, because mips.h defines
41 TARGET_ENDIAN_DEFAULT. */
42 #undef MULTILIB_DEFAULTS
43 #if TARGET_ENDIAN_DEFAULT == 0
44 #define MULTILIB_DEFAULTS { "EL", "mips3" }
45 #else
46 #define MULTILIB_DEFAULTS { "EB", "mips3" }
47 #endif
48
49 #undef CPP_PREDEFINES
50 #define CPP_PREDEFINES "-Dmips -DMIPSEB -DR4000 -D_mips -D_MIPSEB -D_R4000"
51
52 /* I would rather put this in CPP_PREDEFINES, but the gcc driver
53 doesn't handle -U options in CPP_PREDEFINES. */
54 #undef SUBTARGET_CPP_SPEC
55 #define SUBTARGET_CPP_SPEC "\
56 %{!mips1:%{!mips2:-U__mips -D__mips=3 -D__mips64}}"
57
58 /* Use memcpy, et. al., rather than bcopy. */
59 #define TARGET_MEM_FUNCTIONS
60
61 /* Biggest alignment supported by the object file format of this
62 machine. Use this macro to limit the alignment which can be
63 specified using the `__attribute__ ((aligned (N)))' construct. If
64 not defined, the default value is `BIGGEST_ALIGNMENT'. */
65
66 #define MAX_OFILE_ALIGNMENT (32768*8)
67
68 /* We need to use .esize and .etype instead of .size and .type to
69 avoid conflicting with ELF directives. */
70 #undef PUT_SDB_SIZE
71 #define PUT_SDB_SIZE(a) \
72 do { \
73 extern FILE *asm_out_text_file; \
74 fprintf (asm_out_text_file, "\t.esize\t%d;", (a)); \
75 } while (0)
76
77 #undef PUT_SDB_TYPE
78 #define PUT_SDB_TYPE(a) \
79 do { \
80 extern FILE *asm_out_text_file; \
81 fprintf (asm_out_text_file, "\t.etype\t0x%x;", (a)); \
82 } while (0)
83
84 /* A C statement to output something to the assembler file to switch to section
85 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
86 NULL_TREE. Some target formats do not support arbitrary sections. Do not
87 define this macro in such cases. */
88
89 #define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \
90 do { \
91 extern FILE *asm_out_text_file; \
92 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
93 fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
94 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
95 fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \
96 else \
97 fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \
98 } while (0)
99
100 /* The following macro defines the format used to output the second
101 operand of the .type assembler directive. Different svr4 assemblers
102 expect various different forms for this operand. The one given here
103 is just a default. You may need to override it in your machine-
104 specific tm.h file (depending upon the particulars of your assembler). */
105
106 #define TYPE_OPERAND_FMT "@%s"
107
108 /* Define the strings used for the special svr4 .type and .size directives.
109 These strings generally do not vary from one system running svr4 to
110 another, but if a given system (e.g. m88k running svr) needs to use
111 different pseudo-op names for these, they may be overridden in the
112 file which includes this one. */
113
114 #undef TYPE_ASM_OP
115 #undef SIZE_ASM_OP
116 #define TYPE_ASM_OP ".type"
117 #define SIZE_ASM_OP ".size"
118
119 /* These macros generate the special .type and .size directives which
120 are used to set the corresponding fields of the linker symbol table
121 entries in an ELF object file under SVR4. These macros also output
122 the starting labels for the relevant functions/objects. */
123
124 /* Write the extra assembler code needed to declare an object properly. */
125
126 #undef ASM_DECLARE_OBJECT_NAME
127 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
128 do { \
129 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
130 assemble_name (FILE, NAME); \
131 putc (',', FILE); \
132 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
133 putc ('\n', FILE); \
134 size_directive_output = 0; \
135 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
136 { \
137 size_directive_output = 1; \
138 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
139 assemble_name (FILE, NAME); \
140 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
141 } \
142 mips_declare_object (FILE, NAME, "", ":\n", 0); \
143 } while (0)
144
145 /* Output the size directive for a decl in rest_of_decl_compilation
146 in the case where we did not do so before the initializer.
147 Once we find the error_mark_node, we know that the value of
148 size_directive_output was set
149 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
150
151 #undef ASM_FINISH_DECLARE_OBJECT
152 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
153 do { \
154 char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
155 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
156 && ! AT_END && TOP_LEVEL \
157 && DECL_INITIAL (DECL) == error_mark_node \
158 && !size_directive_output) \
159 { \
160 size_directive_output = 1; \
161 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
162 assemble_name (FILE, name); \
163 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
164 } \
165 } while (0)
166
167 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
168 do { fputc ( '\t', FILE); \
169 assemble_name (FILE, LABEL1); \
170 fputs ( " = ", FILE); \
171 assemble_name (FILE, LABEL2); \
172 fputc ( '\n', FILE); \
173 } while (0)
174
175 /* Note about .weak vs. .weakext
176 The mips native assemblers support .weakext, but not .weak.
177 mips-elf gas supports .weak, but not .weakext.
178 mips-elf gas has been changed to support both .weak and .weakext,
179 but until that support is generally available, the 'if' below
180 should serve. */
181
182 #define ASM_WEAKEN_LABEL(FILE,NAME) ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,0)
183 #define ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,VALUE) \
184 do { \
185 if (TARGET_GAS) \
186 fputs ("\t.weak\t", FILE); \
187 else \
188 fputs ("\t.weakext\t", FILE); \
189 assemble_name (FILE, NAME); \
190 if (VALUE) \
191 { \
192 fputc (' ', FILE); \
193 assemble_name (FILE, VALUE); \
194 } \
195 fputc ('\n', FILE); \
196 } while (0)
197
198 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
199 #undef UNIQUE_SECTION_P
200 #define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
201 #define UNIQUE_SECTION(DECL,RELOC) \
202 do { \
203 int len, size, sec; \
204 char *name, *string, *prefix; \
205 static char *prefixes[4][2] = { \
206 { ".text.", ".gnu.linkonce.t." }, \
207 { ".rodata.", ".gnu.linkonce.r." }, \
208 { ".data.", ".gnu.linkonce.d." }, \
209 { ".sdata.", ".gnu.linkonce.s." } \
210 }; \
211 \
212 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
213 size = int_size_in_bytes (TREE_TYPE (decl)); \
214 \
215 /* Determine the base section we are interested in: \
216 0=text, 1=rodata, 2=data, 3=sdata. */ \
217 if (TREE_CODE (DECL) == FUNCTION_DECL) \
218 sec = 0; \
219 else if ((TARGET_EMBEDDED_PIC || TARGET_MIPS16) \
220 && TREE_CODE (decl) == STRING_CST \
221 && !flag_writable_strings) \
222 { \
223 /* For embedded position independent code, put constant strings \
224 in the text section, because the data section is limited to \
225 64K in size. For mips16 code, put strings in the text \
226 section so that a PC relative load instruction can be used to \
227 get their address. */ \
228 sec = 0; \
229 } \
230 else if (TARGET_EMBEDDED_DATA) \
231 { \
232 /* For embedded applications, always put an object in read-only data \
233 if possible, in order to reduce RAM usage. */ \
234 \
235 if (DECL_READONLY_SECTION (DECL, RELOC)) \
236 sec = 1; \
237 else if (size > 0 && size <= mips_section_threshold) \
238 sec = 3; \
239 else \
240 sec = 2; \
241 } \
242 else \
243 { \
244 /* For hosted applications, always put an object in small data if \
245 possible, as this gives the best performance. */ \
246 \
247 if (size > 0 && size <= mips_section_threshold) \
248 sec = 3; \
249 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
250 sec = 1; \
251 else \
252 sec = 2; \
253 } \
254 \
255 prefix = prefixes[sec][DECL_ONE_ONLY (DECL)]; \
256 len = strlen (name) + strlen (prefix); \
257 string = alloca (len + 1); \
258 sprintf (string, "%s%s", prefix, name); \
259 \
260 DECL_SECTION_NAME (DECL) = build_string (len, string); \
261 } while (0)
262
263 /* Support the ctors/dtors and other sections. */
264
265 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
266
267 Note that we want to give these sections the SHF_WRITE attribute
268 because these sections will actually contain data (i.e. tables of
269 addresses of functions in the current root executable or shared library
270 file) and, in the case of a shared library, the relocatable addresses
271 will have to be properly resolved/relocated (and then written into) by
272 the dynamic linker when it actually attaches the given shared library
273 to the executing process. (Note that on SVR4, you may wish to use the
274 `-z text' option to the ELF linker, when building a shared library, as
275 an additional check that you are doing everything right. But if you do
276 use the `-z text' option when building a shared library, you will get
277 errors unless the .ctors and .dtors sections are marked as writable
278 via the SHF_WRITE attribute.) */
279
280 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
281 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
282
283 /* A list of other sections which the compiler might be "in" at any
284 given time. */
285 #undef EXTRA_SECTIONS
286 #define EXTRA_SECTIONS in_sdata, in_rdata, in_ctors, in_dtors
287
288 #define INVOKE__main
289 #define NAME__MAIN "__gccmain"
290 #define SYMBOL__MAIN __gccmain
291
292 #undef EXTRA_SECTION_FUNCTIONS
293 #define EXTRA_SECTION_FUNCTIONS \
294 SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
295 SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP) \
296 SECTION_FUNCTION_TEMPLATE(ctors_section, in_ctors, CTORS_SECTION_ASM_OP) \
297 SECTION_FUNCTION_TEMPLATE(dtors_section, in_dtors, DTORS_SECTION_ASM_OP)
298
299 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
300 void FN () \
301 { \
302 if (in_section != ENUM) \
303 { \
304 fprintf (asm_out_file, "%s\n", OP); \
305 in_section = ENUM; \
306 } \
307 }
308
309
310 /* A C statement (sans semicolon) to output an element in the table of
311 global constructors. */
312 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
313 do { \
314 ctors_section (); \
315 fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word"); \
316 assemble_name (FILE, NAME); \
317 fprintf (FILE, "\n"); \
318 } while (0)
319
320
321 /* A C statement (sans semicolon) to output an element in the table of
322 global destructors. */
323 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
324 do { \
325 dtors_section (); \
326 fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word"); \
327 assemble_name (FILE, NAME); \
328 fprintf (FILE, "\n"); \
329 } while (0)
330
331 #define CTOR_LIST_BEGIN \
332 asm (CTORS_SECTION_ASM_OP); \
333 func_ptr __CTOR_LIST__[1] = { (func_ptr) (-1) }
334
335 #define CTOR_LIST_END \
336 asm (CTORS_SECTION_ASM_OP); \
337 func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
338
339 #define DTOR_LIST_BEGIN \
340 asm (DTORS_SECTION_ASM_OP); \
341 func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) }
342
343 #define DTOR_LIST_END \
344 asm (DTORS_SECTION_ASM_OP); \
345 func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
346
347 /* Don't set the target flags, this is done by the linker script */
348 #undef LIB_SPEC
349 #define LIB_SPEC ""
350
351 #undef STARTFILE_SPEC
352 #define STARTFILE_SPEC "crtbegin%O%s crt0%O%s"
353
354 #undef ENDFILE_SPEC
355 #define ENDFILE_SPEC "crtend%O%s"
This page took 0.059254 seconds and 6 git commands to generate.