]>
gcc.gnu.org Git - gcc.git/blob - 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.
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. */
22 #define OBJECT_FORMAT_ELF
24 /* Default to -mips3. */
25 #define TARGET_DEFAULT MASK_FLOAT64|MASK_64BIT
26 #define MIPS_ISA_DEFAULT 3
28 /* Until we figure out what MIPS ELF targets normally use, just do
30 #ifndef PREFERRED_DEBUGGING_TYPE
31 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
34 /* US Software GOFAST library support. */
36 #define INIT_SUBTARGET_OPTABS INIT_GOFAST_OPTABS
38 #include "mips/mips.h"
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" }
46 #define MULTILIB_DEFAULTS { "EB", "mips3" }
50 #define CPP_PREDEFINES "-Dmips -DMIPSEB -DR4000 -D_mips -D_MIPSEB -D_R4000"
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}}"
58 /* Use memcpy, et. al., rather than bcopy. */
59 #define TARGET_MEM_FUNCTIONS
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'. */
66 #define MAX_OFILE_ALIGNMENT (32768*8)
68 /* We need to use .esize and .etype instead of .size and .type to
69 avoid conflicting with ELF directives. */
71 #define PUT_SDB_SIZE(a) \
73 extern FILE *asm_out_text_file; \
74 fprintf (asm_out_text_file, "\t.esize\t%d;", (a)); \
78 #define PUT_SDB_TYPE(a) \
80 extern FILE *asm_out_text_file; \
81 fprintf (asm_out_text_file, "\t.etype\t0x%x;", (a)); \
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. */
89 #define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \
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)); \
97 fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \
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). */
106 #define TYPE_OPERAND_FMT "@%s"
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. */
116 #define TYPE_ASM_OP ".type"
117 #define SIZE_ASM_OP ".size"
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. */
124 /* Write the extra assembler code needed to declare an object properly. */
126 #undef ASM_DECLARE_OBJECT_NAME
127 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
129 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
130 assemble_name (FILE, NAME); \
132 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
134 size_directive_output = 0; \
135 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
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))); \
142 mips_declare_object (FILE, NAME, "", ":\n", 0); \
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. */
151 #undef ASM_FINISH_DECLARE_OBJECT
152 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
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) \
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))); \
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); \
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
182 #define ASM_WEAKEN_LABEL(FILE,NAME) ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,0)
183 #define ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,VALUE) \
186 fputs ("\t.weak\t", FILE); \
188 fputs ("\t.weakext\t", FILE); \
189 assemble_name (FILE, NAME); \
193 assemble_name (FILE, VALUE); \
195 fputc ('\n', FILE); \
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) \
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." } \
212 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
213 size = int_size_in_bytes (TREE_TYPE (decl)); \
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) \
219 else if ((TARGET_EMBEDDED_PIC || TARGET_MIPS16) \
220 && TREE_CODE (decl) == STRING_CST \
221 && !flag_writable_strings) \
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. */ \
230 else if (TARGET_EMBEDDED_DATA) \
232 /* For embedded applications, always put an object in read-only data \
233 if possible, in order to reduce RAM usage. */ \
235 if (DECL_READONLY_SECTION (DECL, RELOC)) \
237 else if (size > 0 && size <= mips_section_threshold) \
244 /* For hosted applications, always put an object in small data if \
245 possible, as this gives the best performance. */ \
247 if (size > 0 && size <= mips_section_threshold) \
249 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
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); \
260 DECL_SECTION_NAME (DECL) = build_string (len, string); \
263 /* Support the ctors/dtors and other sections. */
265 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
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.) */
280 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
281 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
283 /* A list of other sections which the compiler might be "in" at any
285 #undef EXTRA_SECTIONS
286 #define EXTRA_SECTIONS in_sdata, in_rdata, in_ctors, in_dtors
289 #define NAME__MAIN "__gccmain"
290 #define SYMBOL__MAIN __gccmain
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)
299 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
302 if (in_section != ENUM) \
304 fprintf (asm_out_file, "%s\n", OP); \
310 /* A C statement (sans semicolon) to output an element in the table of
311 global constructors. */
312 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
315 fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word"); \
316 assemble_name (FILE, NAME); \
317 fprintf (FILE, "\n"); \
321 /* A C statement (sans semicolon) to output an element in the table of
322 global destructors. */
323 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
326 fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word"); \
327 assemble_name (FILE, NAME); \
328 fprintf (FILE, "\n"); \
331 #define CTOR_LIST_BEGIN \
332 asm (CTORS_SECTION_ASM_OP); \
333 func_ptr __CTOR_LIST__[1] = { (func_ptr) (-1) }
335 #define CTOR_LIST_END \
336 asm (CTORS_SECTION_ASM_OP); \
337 func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
339 #define DTOR_LIST_BEGIN \
340 asm (DTORS_SECTION_ASM_OP); \
341 func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) }
343 #define DTOR_LIST_END \
344 asm (DTORS_SECTION_ASM_OP); \
345 func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
347 /* Don't set the target flags, this is done by the linker script */
351 #undef STARTFILE_SPEC
352 #define STARTFILE_SPEC "crtbegin%O%s crt0%O%s"
355 #define ENDFILE_SPEC "crtend%O%s"
This page took 0.059254 seconds and 6 git commands to generate.