OSDN Git Service

* mips/elf.h (ASM_OUTPUT_ALIGNED_BSS): Fix warning.
[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, 2003
4    Free Software Foundation, Inc.
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23 /* Use ELF.  */
24 #undef  OBJECT_FORMAT_COFF
25 #undef  EXTENDED_COFF
26
27 /* ??? Move all SDB stuff into separate header file.  */
28 #undef  SDB_DEBUGGING_INFO
29
30 #define DBX_DEBUGGING_INFO 1
31 #define DWARF2_DEBUGGING_INFO 1
32
33 #undef  PREFERRED_DEBUGGING_TYPE
34 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
35
36 #undef  SUBTARGET_ASM_DEBUGGING_SPEC
37 #define SUBTARGET_ASM_DEBUGGING_SPEC "-g0"
38
39 /* Biggest alignment supported by the object file format of this
40    machine.  Use this macro to limit the alignment which can be
41    specified using the `__attribute__ ((aligned (N)))' construct.  If
42    not defined, the default value is `BIGGEST_ALIGNMENT'.  */
43
44 #undef  MAX_OFILE_ALIGNMENT
45 #define MAX_OFILE_ALIGNMENT (32768*8)
46
47 /* Switch into a generic section.  */
48 #undef  TARGET_ASM_NAMED_SECTION
49 #define TARGET_ASM_NAMED_SECTION  default_elf_asm_named_section
50
51 /* Given that Irix has it's own headers, not having TARGET_GAS here
52    seems a mistake.  If we actually need to be prepared for file
53    switching, then we need a custom TARGET_ASM_NAMED_SECTION too.  */
54
55 #undef  TEXT_SECTION
56 #define TEXT_SECTION()                          \
57 do {                                            \
58   if (TARGET_FILE_SWITCHING)                    \
59     abort ();                                   \
60   fputs (TEXT_SECTION_ASM_OP, asm_out_file);    \
61   fputc ('\n', asm_out_file);                   \
62 } while (0)
63
64 /* The following macro defines the format used to output the second
65    operand of the .type assembler directive.  Different svr4 assemblers
66    expect various different forms for this operand.  The one given here
67    is just a default.  You may need to override it in your machine-
68    specific tm.h file (depending upon the particulars of your assembler).  */
69
70 #define TYPE_OPERAND_FMT        "@%s"
71
72 /* Define the strings used for the special svr4 .type and .size directives.
73    These strings generally do not vary from one system running svr4 to
74    another, but if a given system (e.g. m88k running svr) needs to use
75    different pseudo-op names for these, they may be overridden in the
76    file which includes this one.  */
77
78 #undef TYPE_ASM_OP
79 #undef SIZE_ASM_OP
80 #define TYPE_ASM_OP     "\t.type\t"
81 #define SIZE_ASM_OP     "\t.size\t"
82
83 /* If defined, a C expression whose value is a string containing the
84    assembler operation to identify the following data as
85    uninitialized global data.  If not defined, and neither
86    `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
87    uninitialized global data will be output in the data section if
88    `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
89    used.  */
90
91 #ifndef BSS_SECTION_ASM_OP
92 #define BSS_SECTION_ASM_OP      "\t.section\t.bss"
93 #endif
94
95 #undef  SBSS_SECTION_ASM_OP
96 #define SBSS_SECTION_ASM_OP     "\t.section .sbss"
97
98 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
99    separate, explicit argument.  If you define this macro, it is used
100    in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
101    handling the required alignment of the variable.  The alignment is
102    specified as the number of bits.
103
104    Try to use function `asm_output_aligned_bss' defined in file
105    `varasm.c' when defining this macro.  */
106 #ifndef ASM_OUTPUT_ALIGNED_BSS
107 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
108 do {                                                                    \
109   if (SIZE > 0 && SIZE <= (unsigned HOST_WIDE_INT)mips_section_threshold)\
110     sbss_section ();                                                    \
111   else                                                                  \
112     bss_section ();                                                     \
113   ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT));          \
114   last_assemble_variable_decl = DECL;                                   \
115   ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL);                           \
116   ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1);                              \
117 } while (0)
118 #endif
119
120 /* These macros generate the special .type and .size directives which
121    are used to set the corresponding fields of the linker symbol table
122    entries in an ELF object file under SVR4.  These macros also output
123    the starting labels for the relevant functions/objects.  */
124
125 /* Write the extra assembler code needed to declare an object properly.  */
126
127 #undef  ASM_DECLARE_OBJECT_NAME
128 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                       \
129   do {                                                                  \
130     HOST_WIDE_INT size;                                                 \
131     ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");                   \
132     size_directive_output = 0;                                          \
133     if (!flag_inhibit_size_directive && DECL_SIZE (DECL))               \
134       {                                                                 \
135         size_directive_output = 1;                                      \
136         size = int_size_in_bytes (TREE_TYPE (DECL));                    \
137         ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);                   \
138       }                                                                 \
139     mips_declare_object (FILE, NAME, "", ":\n", 0);                     \
140   } while (0)
141
142 /* Output the size directive for a decl in rest_of_decl_compilation
143    in the case where we did not do so before the initializer.
144    Once we find the error_mark_node, we know that the value of
145    size_directive_output was set
146    by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
147
148 #undef  ASM_FINISH_DECLARE_OBJECT
149 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)         \
150 do {                                                                     \
151      const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);             \
152      HOST_WIDE_INT size;                                                 \
153                                                                          \
154      if (!flag_inhibit_size_directive && DECL_SIZE (DECL)                \
155          && ! AT_END && TOP_LEVEL                                        \
156          && DECL_INITIAL (DECL) == error_mark_node                       \
157          && !size_directive_output)                                      \
158        {                                                                 \
159          size_directive_output = 1;                                      \
160          size = int_size_in_bytes (TREE_TYPE (DECL));                    \
161          ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size);                   \
162        }                                                                 \
163    } while (0)
164
165 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                            \
166  do { fputc ( '\t', FILE);                                            \
167       assemble_name (FILE, LABEL1);                                   \
168       fputs ( " = ", FILE);                                           \
169       assemble_name (FILE, LABEL2);                                   \
170       fputc ( '\n', FILE);                                            \
171  } while (0)
172
173 /* Note about .weak vs. .weakext
174    The mips native assemblers support .weakext, but not .weak.
175    mips-elf gas supports .weak, but not .weakext.
176    mips-elf gas has been changed to support both .weak and .weakext,
177    but until that support is generally available, the 'if' below
178    should serve.  */
179
180 #undef  ASM_WEAKEN_LABEL
181 #define ASM_WEAKEN_LABEL(FILE,NAME) ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,0)
182 #define ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,VALUE)  \
183  do {                                           \
184   if (TARGET_GAS)                               \
185       fputs ("\t.weak\t", FILE);                \
186   else                                          \
187       fputs ("\t.weakext\t", FILE);             \
188   assemble_name (FILE, NAME);                   \
189   if (VALUE)                                    \
190     {                                           \
191       fputc (' ', FILE);                        \
192       assemble_name (FILE, VALUE);              \
193     }                                           \
194   fputc ('\n', FILE);                           \
195  } while (0)
196
197 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
198
199 #define TARGET_ASM_UNIQUE_SECTION  mips_unique_section
200
201 /* A list of other sections which the compiler might be "in" at any
202    given time.  */
203 #undef  EXTRA_SECTIONS
204 #define EXTRA_SECTIONS in_sdata, in_sbss
205
206 #undef  EXTRA_SECTION_FUNCTIONS
207 #define EXTRA_SECTION_FUNCTIONS                                         \
208   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
209   SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP)
210
211 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP)                               \
212 void FN ()                                                            \
213 {                                                                     \
214   if (in_section != ENUM)                                             \
215     {                                                                 \
216       fprintf (asm_out_file, "%s\n", OP);                             \
217       in_section = ENUM;                                              \
218     }                                                                 \
219 }
220
221 /* On elf, we *do* have support for the .init and .fini sections, and we
222    can put stuff in there to be executed before and after `main'.  We let
223    crtstuff.c and other files know this by defining the following symbols.
224    The definitions say how to change sections to the .init and .fini
225    sections.  This is the same for all known elf assemblers.  */
226
227 #undef  INIT_SECTION_ASM_OP
228 #define INIT_SECTION_ASM_OP     "\t.section\t.init"
229 #undef  FINI_SECTION_ASM_OP
230 #define FINI_SECTION_ASM_OP     "\t.section\t.fini"
231
232 /* Don't set the target flags, this is done by the linker script */
233 #undef  LIB_SPEC
234 #define LIB_SPEC ""
235
236 #undef  STARTFILE_SPEC
237 #define STARTFILE_SPEC "crti%O%s crtbegin%O%s"
238
239 #undef  ENDFILE_SPEC
240 #define ENDFILE_SPEC "crtend%O%s crtn%O%s"
241
242 /* We support #pragma.  */
243 #define HANDLE_SYSV_PRAGMA 1