]>
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"
41 #define CPP_PREDEFINES "-Dmips -DMIPSEB -DR4000 -D_mips -D_MIPSEB -D_R4000"
43 /* I would rather put this in CPP_PREDEFINES, but the gcc driver
44 doesn't handle -U options in CPP_PREDEFINES. */
45 #undef SUBTARGET_CPP_SPEC
46 #define SUBTARGET_CPP_SPEC "\
47 %{!mips1:%{!mips2:-U__mips -D__mips=3 -D__mips64}}"
49 /* Use memcpy, et. al., rather than bcopy. */
50 #define TARGET_MEM_FUNCTIONS
52 /* Biggest alignment supported by the object file format of this
53 machine. Use this macro to limit the alignment which can be
54 specified using the `__attribute__ ((aligned (N)))' construct. If
55 not defined, the default value is `BIGGEST_ALIGNMENT'. */
57 #define MAX_OFILE_ALIGNMENT (32768*8)
59 /* We need to use .esize and .etype instead of .size and .type to
60 avoid conflicting with ELF directives. */
62 #define PUT_SDB_SIZE(a) \
64 extern FILE *asm_out_text_file; \
65 fprintf (asm_out_text_file, "\t.esize\t%d;", (a)); \
69 #define PUT_SDB_TYPE(a) \
71 extern FILE *asm_out_text_file; \
72 fprintf (asm_out_text_file, "\t.etype\t0x%x;", (a)); \
75 /* A C statement to output something to the assembler file to switch to section
76 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
77 NULL_TREE. Some target formats do not support arbitrary sections. Do not
78 define this macro in such cases. */
80 #define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \
82 extern FILE *asm_out_text_file; \
83 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
84 fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
85 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
86 fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \
88 fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \
91 /* The following macro defines the format used to output the second
92 operand of the .type assembler directive. Different svr4 assemblers
93 expect various different forms for this operand. The one given here
94 is just a default. You may need to override it in your machine-
95 specific tm.h file (depending upon the particulars of your assembler). */
97 #define TYPE_OPERAND_FMT "@%s"
99 /* Define the strings used for the special svr4 .type and .size directives.
100 These strings generally do not vary from one system running svr4 to
101 another, but if a given system (e.g. m88k running svr) needs to use
102 different pseudo-op names for these, they may be overridden in the
103 file which includes this one. */
107 #define TYPE_ASM_OP ".type"
108 #define SIZE_ASM_OP ".size"
110 /* These macros generate the special .type and .size directives which
111 are used to set the corresponding fields of the linker symbol table
112 entries in an ELF object file under SVR4. These macros also output
113 the starting labels for the relevant functions/objects. */
115 /* Write the extra assembler code needed to declare an object properly. */
117 #undef ASM_DECLARE_OBJECT_NAME
118 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
120 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
121 assemble_name (FILE, NAME); \
123 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
125 size_directive_output = 0; \
126 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
128 size_directive_output = 1; \
129 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
130 assemble_name (FILE, NAME); \
131 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
133 mips_declare_object (FILE, NAME, "", ":\n", 0); \
136 /* Output the size directive for a decl in rest_of_decl_compilation
137 in the case where we did not do so before the initializer.
138 Once we find the error_mark_node, we know that the value of
139 size_directive_output was set
140 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
142 #undef ASM_FINISH_DECLARE_OBJECT
143 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
145 char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
146 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
147 && ! AT_END && TOP_LEVEL \
148 && DECL_INITIAL (DECL) == error_mark_node \
149 && !size_directive_output) \
151 size_directive_output = 1; \
152 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
153 assemble_name (FILE, name); \
154 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
158 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
159 do { fputc ( '\t', FILE); \
160 assemble_name (FILE, LABEL1); \
161 fputs ( " = ", FILE); \
162 assemble_name (FILE, LABEL2); \
163 fputc ( '\n', FILE); \
166 /* Note about .weak vs. .weakext
167 The mips native assemblers support .weakext, but not .weak.
168 mips-elf gas supports .weak, but not .weakext.
169 mips-elf gas has been changed to support both .weak and .weakext,
170 but until that support is generally available, the 'if' below
173 #define ASM_WEAKEN_LABEL(FILE,NAME) ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,0)
174 #define ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,VALUE) \
177 fputs ("\t.weak\t", FILE); \
179 fputs ("\t.weakext\t", FILE); \
180 assemble_name (FILE, NAME); \
184 assemble_name (FILE, VALUE); \
186 fputc ('\n', FILE); \
189 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
190 #undef UNIQUE_SECTION_P
191 #define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
192 #define UNIQUE_SECTION(DECL,RELOC) \
194 int len, size, sec; \
195 char *name, *string, *prefix; \
196 static char *prefixes[4][2] = { \
197 { ".text.", ".gnu.linkonce.t." }, \
198 { ".rodata.", ".gnu.linkonce.r." }, \
199 { ".data.", ".gnu.linkonce.d." }, \
200 { ".sdata.", ".gnu.linkonce.s." } \
203 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
204 size = int_size_in_bytes (TREE_TYPE (decl)); \
206 /* Determine the base section we are interested in: \
207 0=text, 1=rodata, 2=data, 3=sdata, [4=bss]. */ \
208 if (TREE_CODE (DECL) == FUNCTION_DECL) \
210 else if (DECL_INITIAL (DECL) == 0 \
211 || DECL_INITIAL (DECL) == error_mark_node) \
213 else if ((TARGET_EMBEDDED_PIC || TARGET_MIPS16) \
214 && TREE_CODE (decl) == STRING_CST \
215 && !flag_writable_strings) \
217 /* For embedded position independent code, put constant strings \
218 in the text section, because the data section is limited to \
219 64K in size. For mips16 code, put strings in the text \
220 section so that a PC relative load instruction can be used to \
221 get their address. */ \
224 else if (TARGET_EMBEDDED_DATA) \
226 /* For embedded applications, always put an object in read-only data \
227 if possible, in order to reduce RAM usage. */ \
229 if (DECL_READONLY_SECTION (DECL, RELOC)) \
231 else if (size > 0 && size <= mips_section_threshold) \
238 /* For hosted applications, always put an object in small data if \
239 possible, as this gives the best performance. */ \
241 if (size > 0 && size <= mips_section_threshold) \
243 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
249 prefix = prefixes[sec][DECL_ONE_ONLY (DECL)]; \
250 len = strlen (name) + strlen (prefix); \
251 string = alloca (len + 1); \
252 sprintf (string, "%s%s", prefix, name); \
254 DECL_SECTION_NAME (DECL) = build_string (len, string); \
257 /* Support the ctors/dtors and other sections. */
259 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
261 Note that we want to give these sections the SHF_WRITE attribute
262 because these sections will actually contain data (i.e. tables of
263 addresses of functions in the current root executable or shared library
264 file) and, in the case of a shared library, the relocatable addresses
265 will have to be properly resolved/relocated (and then written into) by
266 the dynamic linker when it actually attaches the given shared library
267 to the executing process. (Note that on SVR4, you may wish to use the
268 `-z text' option to the ELF linker, when building a shared library, as
269 an additional check that you are doing everything right. But if you do
270 use the `-z text' option when building a shared library, you will get
271 errors unless the .ctors and .dtors sections are marked as writable
272 via the SHF_WRITE attribute.) */
274 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
275 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
277 /* A list of other sections which the compiler might be "in" at any
279 #undef EXTRA_SECTIONS
280 #define EXTRA_SECTIONS in_sdata, in_rdata, in_ctors, in_dtors
284 #undef EXTRA_SECTION_FUNCTIONS
285 #define EXTRA_SECTION_FUNCTIONS \
286 SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
287 SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP) \
288 SECTION_FUNCTION_TEMPLATE(ctors_section, in_ctors, CTORS_SECTION_ASM_OP) \
289 SECTION_FUNCTION_TEMPLATE(dtors_section, in_dtors, DTORS_SECTION_ASM_OP)
291 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
294 if (in_section != ENUM) \
296 fprintf (asm_out_file, "%s\n", OP); \
302 /* A C statement (sans semicolon) to output an element in the table of
303 global constructors. */
304 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
307 fprintf (FILE, "\t%s\t", (Pmode == SImode) ? ".word" : ".dword"); \
308 assemble_name (FILE, NAME); \
309 fprintf (FILE, "\n"); \
313 /* A C statement (sans semicolon) to output an element in the table of
314 global destructors. */
315 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
318 fprintf (FILE, "\t%s\t", (Pmode == SImode) ? ".word" : ".dword"); \
319 assemble_name (FILE, NAME); \
320 fprintf (FILE, "\n"); \
323 #define CTOR_LIST_BEGIN \
324 asm (CTORS_SECTION_ASM_OP); \
325 func_ptr __CTOR_LIST__[1] = { (func_ptr) (-1) }
327 #define CTOR_LIST_END \
328 asm (CTORS_SECTION_ASM_OP); \
329 func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
331 #define DTOR_LIST_BEGIN \
332 asm (DTORS_SECTION_ASM_OP); \
333 func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) }
335 #define DTOR_LIST_END \
336 asm (DTORS_SECTION_ASM_OP); \
337 func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
339 /* Don't set the target flags, this is done by the linker script */
343 #undef STARTFILE_SPEC
344 #define STARTFILE_SPEC "crtbegin%O%s %{!mno-crt0:crt0%O%s}"
347 #define ENDFILE_SPEC "crtend%O%s"
This page took 0.058515 seconds and 6 git commands to generate.