OSDN Git Service

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