OSDN Git Service

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