1015573b0618b489215ba01995b93e639de8a9ec
[platform/upstream/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, 2000 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 #ifndef TARGET_DEFAULT
26 #define TARGET_DEFAULT MASK_FLOAT64|MASK_64BIT
27 #endif
28
29 #ifndef MIPS_ISA_DEFAULT
30 #define MIPS_ISA_DEFAULT 3
31 #endif
32
33 /* This should change to n32 when it is supported in gas.  */
34 #ifndef MIPS_ABI_DEFAULT
35 #define MIPS_ABI_DEFAULT ABI_O64
36 #endif
37
38 /* Until we figure out what MIPS ELF targets normally use, just do
39    stabs in ELF.  */
40 #ifndef PREFERRED_DEBUGGING_TYPE
41 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
42 #endif
43
44 /* US Software GOFAST library support.  */
45 #include "gofast.h"
46 #define INIT_SUBTARGET_OPTABS INIT_GOFAST_OPTABS
47
48 #include "mips/mips.h"
49
50 #undef CPP_PREDEFINES
51 #define CPP_PREDEFINES "-Dmips -DMIPSEB -DR4000 -D_mips -D_MIPSEB -D_R4000"
52
53 /* I would rather put this in CPP_PREDEFINES, but the gcc driver
54    doesn't handle -U options in CPP_PREDEFINES.  */
55 #undef SUBTARGET_CPP_SPEC
56 #define SUBTARGET_CPP_SPEC "\
57 %{!mips1:%{!mips2:-U__mips -D__mips=3 -D__mips64}}"
58
59 /* Use memcpy, et. al., rather than bcopy.  */
60 #define TARGET_MEM_FUNCTIONS
61
62 /* Biggest alignment supported by the object file format of this
63    machine.  Use this macro to limit the alignment which can be
64    specified using the `__attribute__ ((aligned (N)))' construct.  If
65    not defined, the default value is `BIGGEST_ALIGNMENT'.  */
66
67 #undef MAX_OFILE_ALIGNMENT
68 #define MAX_OFILE_ALIGNMENT (32768*8)
69
70 /* We need to use .esize and .etype instead of .size and .type to
71    avoid conflicting with ELF directives.  */
72 #undef PUT_SDB_SIZE
73 #define PUT_SDB_SIZE(a)                                 \
74 do {                                                    \
75   extern FILE *asm_out_text_file;                       \
76   fprintf (asm_out_text_file, "\t.esize\t");            \
77   fprintf (asm_out_text_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) (a)); \
78   fprintf (asm_out_text_file, ";");                     \
79 } while (0)
80
81 #undef PUT_SDB_TYPE
82 #define PUT_SDB_TYPE(a)                                 \
83 do {                                                    \
84   extern FILE *asm_out_text_file;                       \
85   fprintf (asm_out_text_file, "\t.etype\t0x%x;", (a));  \
86 } while (0)
87
88 /* Switch into a generic section.  */
89 #undef TARGET_ASM_NAMED_SECTION
90 #define TARGET_ASM_NAMED_SECTION  default_elf_asm_named_section
91
92 /* Given that Irix has it's own headers, not having TARGET_GAS here
93    seems a mistake.  If we actually need to be prepared for file
94    switching, then we need a custom TARGET_ASM_NAMED_SECTION too.  */
95
96 #undef TEXT_SECTION
97 #define TEXT_SECTION()                          \
98 do {                                            \
99   if (TARGET_FILE_SWITCHING)                    \
100     abort ();                                   \
101   fputs (TEXT_SECTION_ASM_OP, asm_out_file);    \
102   fputc ('\n', asm_out_file);                   \
103 } while (0)
104
105 /* The following macro defines the format used to output the second
106    operand of the .type assembler directive.  Different svr4 assemblers
107    expect various different forms for this operand.  The one given here
108    is just a default.  You may need to override it in your machine-
109    specific tm.h file (depending upon the particulars of your assembler).  */
110
111 #define TYPE_OPERAND_FMT        "@%s"
112
113 /* Define the strings used for the special svr4 .type and .size directives.
114    These strings generally do not vary from one system running svr4 to
115    another, but if a given system (e.g. m88k running svr) needs to use
116    different pseudo-op names for these, they may be overridden in the
117    file which includes this one.  */
118
119 #undef TYPE_ASM_OP
120 #undef SIZE_ASM_OP
121 #define TYPE_ASM_OP     "\t.type\t"
122 #define SIZE_ASM_OP     "\t.size\t"
123
124 /* These macros generate the special .type and .size directives which
125    are used to set the corresponding fields of the linker symbol table
126    entries in an ELF object file under SVR4.  These macros also output
127    the starting labels for the relevant functions/objects.  */
128
129 /* Write the extra assembler code needed to declare an object properly.  */
130
131 #undef ASM_DECLARE_OBJECT_NAME
132 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                       \
133   do {                                                                  \
134     fprintf (FILE, "%s", TYPE_ASM_OP);                                  \
135     assemble_name (FILE, NAME);                                         \
136     putc (',', FILE);                                                   \
137     fprintf (FILE, TYPE_OPERAND_FMT, "object");                         \
138     putc ('\n', FILE);                                                  \
139     size_directive_output = 0;                                          \
140     if (!flag_inhibit_size_directive && DECL_SIZE (DECL))               \
141       {                                                                 \
142         size_directive_output = 1;                                      \
143         fprintf (FILE, "%s", SIZE_ASM_OP);                              \
144         assemble_name (FILE, NAME);                                     \
145         fprintf (FILE, ",");                                            \
146         fprintf (FILE, HOST_WIDE_INT_PRINT_DEC,                         \
147           int_size_in_bytes (TREE_TYPE (DECL)));                        \
148         fprintf (FILE, "\n");                                           \
149       }                                                                 \
150     mips_declare_object (FILE, NAME, "", ":\n", 0);                     \
151   } while (0)
152
153 /* Output the size directive for a decl in rest_of_decl_compilation
154    in the case where we did not do so before the initializer.
155    Once we find the error_mark_node, we know that the value of
156    size_directive_output was set
157    by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
158
159 #undef ASM_FINISH_DECLARE_OBJECT
160 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)         \
161 do {                                                                     \
162      const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);             \
163      if (!flag_inhibit_size_directive && DECL_SIZE (DECL)                \
164          && ! AT_END && TOP_LEVEL                                        \
165          && DECL_INITIAL (DECL) == error_mark_node                       \
166          && !size_directive_output)                                      \
167        {                                                                 \
168          size_directive_output = 1;                                      \
169          fprintf (FILE, "%s", SIZE_ASM_OP);                              \
170          assemble_name (FILE, name);                                     \
171          fprintf (FILE, ",");                                            \
172          fprintf (FILE, HOST_WIDE_INT_PRINT_DEC,                         \
173                   int_size_in_bytes (TREE_TYPE (DECL)));                 \
174          fprintf (FILE, "\n");                                           \
175        }                                                                 \
176    } while (0)
177
178 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                            \
179  do { fputc ( '\t', FILE);                                            \
180       assemble_name (FILE, LABEL1);                                   \
181       fputs ( " = ", FILE);                                           \
182       assemble_name (FILE, LABEL2);                                   \
183       fputc ( '\n', FILE);                                            \
184  } while (0)
185
186 /* Note about .weak vs. .weakext
187    The mips native assemblers support .weakext, but not .weak.
188    mips-elf gas supports .weak, but not .weakext.
189    mips-elf gas has been changed to support both .weak and .weakext,
190    but until that support is generally available, the 'if' below
191    should serve.  */
192
193 #undef ASM_WEAKEN_LABEL
194 #define ASM_WEAKEN_LABEL(FILE,NAME) ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,0)
195 #define ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,VALUE)  \
196  do {                                           \
197   if (TARGET_GAS)                               \
198       fputs ("\t.weak\t", FILE);                \
199   else                                          \
200       fputs ("\t.weakext\t", FILE);             \
201   assemble_name (FILE, NAME);                   \
202   if (VALUE)                                    \
203     {                                           \
204       fputc (' ', FILE);                        \
205       assemble_name (FILE, VALUE);              \
206     }                                           \
207   fputc ('\n', FILE);                           \
208  } while (0)
209
210 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
211 #undef UNIQUE_SECTION
212 #define UNIQUE_SECTION(DECL,RELOC) \
213   mips_unique_section ((DECL), (RELOC))
214
215 /* A list of other sections which the compiler might be "in" at any
216    given time.  */
217 #undef EXTRA_SECTIONS
218 #define EXTRA_SECTIONS in_sdata, in_rdata
219
220 #undef EXTRA_SECTION_FUNCTIONS
221 #define EXTRA_SECTION_FUNCTIONS                                         \
222   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
223   SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
224
225 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP)                               \
226 void FN ()                                                            \
227 {                                                                     \
228   if (in_section != ENUM)                                             \
229     {                                                                 \
230       fprintf (asm_out_file, "%s\n", OP);                             \
231       in_section = ENUM;                                              \
232     }                                                                 \
233 }
234
235 /* On elf, we *do* have support for the .init and .fini sections, and we
236    can put stuff in there to be executed before and after `main'.  We let
237    crtstuff.c and other files know this by defining the following symbols.
238    The definitions say how to change sections to the .init and .fini
239    sections.  This is the same for all known elf assemblers.  */
240
241 #undef  INIT_SECTION_ASM_OP
242 #define INIT_SECTION_ASM_OP     "\t.section\t.init"
243 #undef  FINI_SECTION_ASM_OP
244 #define FINI_SECTION_ASM_OP     "\t.section\t.fini"
245
246 /* Don't set the target flags, this is done by the linker script */
247 #undef LIB_SPEC
248 #define LIB_SPEC ""
249
250 #undef  STARTFILE_SPEC
251 #define STARTFILE_SPEC "crti%O%s crtbegin%O%s %{!mno-crt0:crt0%O%s}"
252
253 #undef  ENDFILE_SPEC
254 #define ENDFILE_SPEC "crtend%O%s crtn%O%s"