Tidy up previous delta
[official-gcc.git] / gcc / config / arm / elf.h
blobc244b8cb23cbf959174ef9aa6b2dbed1014e72df
1 /* Definitions of target machine for GNU compiler,
2 for ARM with ELF obj format.
3 Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
4 Contributed by Philip Blundell <philb@gnu.org> and
5 Catherine Moore <clm@cygnus.com>
7 This file is part of GNU CC.
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING. If not, write to
21 the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
25 #define OBJECT_FORMAT_ELF
27 #ifndef LOCAL_LABEL_PREFIX
28 #define LOCAL_LABEL_PREFIX "."
29 #endif
31 #ifndef USER_LABEL_PREFIX
32 #define USER_LABEL_PREFIX ""
33 #endif
35 #ifndef CPP_PREDEFINES
36 #define CPP_PREDEFINES "-Darm -Darm_elf -Acpu(arm) -Amachine(arm) -D__ELF__"
37 #endif
39 /* The following macro defines the format used to output the second
40 operand of the .type assembler directive. Different svr4 assemblers
41 expect various different forms for this operand. The one given here
42 is just a default. You may need to override it in your machine-
43 specific tm.h file (depending upon the particulars of your assembler). */
44 #define TYPE_OPERAND_FMT "%s"
46 /* Write the extra assembler code needed to declare a function's result.
47 Most svr4 assemblers don't require any special declaration of the
48 result value, but there are exceptions. */
49 #ifndef ASM_DECLARE_RESULT
50 #define ASM_DECLARE_RESULT(FILE, RESULT)
51 #endif
53 /* These macros generate the special .type and .size directives which
54 are used to set the corresponding fields of the linker symbol table
55 entries in an ELF object file under SVR4. These macros also output
56 the starting labels for the relevant functions/objects. */
57 #define TYPE_ASM_OP ".type"
58 #define SIZE_ASM_OP ".size"
60 /* Write the extra assembler code needed to declare a function properly.
61 Some svr4 assemblers need to also have something extra said about the
62 function's return value. We allow for that here. */
63 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
64 do { \
65 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
66 assemble_name (FILE, NAME); \
67 putc (',', FILE); \
68 fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
69 putc ('\n', FILE); \
70 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
71 ASM_OUTPUT_LABEL(FILE, NAME); \
72 } while (0)
74 /* Write the extra assembler code needed to declare an object properly. */
75 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
76 do { \
77 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
78 assemble_name (FILE, NAME); \
79 putc (',', FILE); \
80 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
81 putc ('\n', FILE); \
82 size_directive_output = 0; \
83 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
84 { \
85 size_directive_output = 1; \
86 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
87 assemble_name (FILE, NAME); \
88 putc (',', FILE); \
89 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
90 int_size_in_bytes (TREE_TYPE (DECL))); \
91 fputc ('\n', FILE); \
92 } \
93 ASM_OUTPUT_LABEL(FILE, NAME); \
94 } while (0)
96 /* Output the size directive for a decl in rest_of_decl_compilation
97 in the case where we did not do so before the initializer.
98 Once we find the error_mark_node, we know that the value of
99 size_directive_output was set
100 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
101 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
102 do { \
103 char * name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
104 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
105 && ! AT_END && TOP_LEVEL \
106 && DECL_INITIAL (DECL) == error_mark_node \
107 && !size_directive_output) \
109 size_directive_output = 1; \
110 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
111 assemble_name (FILE, name); \
112 putc (',', FILE); \
113 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
114 int_size_in_bytes (TREE_TYPE (DECL))); \
115 fputc ('\n', FILE); \
117 } while (0)
119 /* This is how to declare the size of a function. */
120 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
121 do { \
122 if (!flag_inhibit_size_directive) \
124 char label[256]; \
125 static int labelno; \
126 labelno ++; \
127 ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
128 ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
129 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
130 assemble_name (FILE, (FNAME)); \
131 fprintf (FILE, ","); \
132 assemble_name (FILE, label); \
133 fprintf (FILE, "-"); \
134 assemble_name (FILE, (FNAME)); \
135 putc ('\n', FILE); \
137 } while (0)
139 /* Define this macro if jump tables (for `tablejump' insns) should be
140 output in the text section, along with the assembler instructions.
141 Otherwise, the readonly data section is used. */
142 #define JUMP_TABLES_IN_TEXT_SECTION 1
144 #ifndef ASM_SPEC
145 #define ASM_SPEC "%{mbig-endian:-EB} %{mcpu=*:-m%*} %{march=*:-m%*} \
146 %{mapcs-*:-mapcs-%*} %{mthumb-interwork:-mthumb-interwork} %{mapcs-float:mfloat}"
147 #endif
149 #ifndef LINK_SPEC
150 #define LINK_SPEC "%{mbig-endian:-EB} -X"
151 #endif
153 /* Run-time Target Specification. */
154 #ifndef TARGET_VERSION
155 #define TARGET_VERSION fputs (" (ARM/elf)", stderr)
156 #endif
158 #ifndef TARGET_DEFAULT
159 #define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32)
160 #endif
162 #ifndef MULTILIB_DEFAULTS
163 #define MULTILIB_DEFAULTS { "mlittle-endian", "msoft-float", "mapcs-32", "mno-thumb-interwork" }
164 #endif
166 /* Setting this to 32 produces more efficient code, but the value set in previous
167 versions of this toolchain was 8, which produces more compact structures. The
168 command line option -mstructure_size_boundary=<n> can be used to change this
169 value. */
170 #undef STRUCTURE_SIZE_BOUNDARY
171 #define STRUCTURE_SIZE_BOUNDARY arm_structure_size_boundary
173 extern int arm_structure_size_boundary;
175 /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS
176 is a valid machine specific attribute for DECL.
177 The attributes in ATTRIBUTES have previously been assigned to DECL. */
178 extern int arm_valid_machine_decl_attribute ();
179 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \
180 arm_valid_machine_decl_attribute (DECL, ATTRIBUTES, IDENTIFIER, ARGS)
183 /* A C statement to output assembler commands which will identify the
184 object file as having been compiled with GNU CC (or another GNU
185 compiler). */
186 /* Define this to NULL so we don't get anything.
187 We have ASM_IDENTIFY_LANGUAGE.
188 Also, when using stabs, gcc2_compiled must be a stabs entry, not an
189 ordinary symbol, or gdb won't see it. The stabs entry must be
190 before the N_SO in order for gdb to find it. */
191 #ifndef ASM_IDENTIFY_GCC
192 #define ASM_IDENTIFY_GCC(STREAM) \
193 fprintf (STREAM, "%sgcc2_compiled.:\n", LOCAL_LABEL_PREFIX )
194 #endif
196 /* This outputs a lot of .req's to define alias for various registers.
197 Let's try to avoid this. */
198 #ifndef ASM_FILE_START
199 #define ASM_FILE_START(STREAM) \
200 do { \
201 extern char * version_string; \
202 fprintf (STREAM, "%s Generated by gcc %s for ARM/elf\n", \
203 ASM_COMMENT_START, version_string); \
204 output_file_directive ((STREAM), main_input_filename); \
205 } while (0)
206 #endif
208 /* Output an internal label definition. */
209 #ifndef ASM_OUTPUT_INTERNAL_LABEL
210 #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, PREFIX, NUM) \
211 do \
213 char * s = (char *) alloca (40 + strlen (PREFIX)); \
214 extern int arm_target_label, arm_ccfsm_state; \
215 extern rtx arm_target_insn; \
217 if (arm_ccfsm_state == 3 && arm_target_label == (NUM) \
218 && !strcmp (PREFIX, "L")) \
220 arm_ccfsm_state = 0; \
221 arm_target_insn = NULL; \
223 ASM_GENERATE_INTERNAL_LABEL (s, (PREFIX), (NUM)); \
224 ASM_OUTPUT_LABEL (STREAM, s); \
225 } while (0)
226 #endif
228 /* Support the ctors/dtors and other sections. */
230 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
232 Note that we want to give these sections the SHF_WRITE attribute
233 because these sections will actually contain data (i.e. tables of
234 addresses of functions in the current root executable or shared library
235 file) and, in the case of a shared library, the relocatable addresses
236 will have to be properly resolved/relocated (and then written into) by
237 the dynamic linker when it actually attaches the given shared library
238 to the executing process. (Note that on SVR4, you may wish to use the
239 `-z text' option to the ELF linker, when building a shared library, as
240 an additional check that you are doing everything right. But if you do
241 use the `-z text' option when building a shared library, you will get
242 errors unless the .ctors and .dtors sections are marked as writable
243 via the SHF_WRITE attribute.) */
244 #ifndef CTORS_SECTION_ASM_OP
245 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
246 #endif
248 #ifndef DTORS_SECTION_ASM_OP
249 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
250 #endif
252 /* A list of other sections which the compiler might be "in" at any
253 given time. */
254 #ifndef SUBTARGET_EXTRA_SECTIONS
255 #define SUBTARGET_EXTRA_SECTIONS
256 #endif
258 #ifndef EXTRA_SECTIONS
259 #define EXTRA_SECTIONS SUBTARGET_EXTRA_SECTIONS in_ctors, in_dtors
260 #endif
262 /* A list of extra section function definitions. */
263 #ifndef SUBTARGET_EXTRA_SECTION_FUNCTIONS
264 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS
265 #endif
267 #ifndef EXTRA_SECTION_FUNCTIONS
268 #define EXTRA_SECTION_FUNCTIONS \
269 SUBTARGET_EXTRA_SECTION_FUNCTIONS \
270 CTORS_SECTION_FUNCTION \
271 DTORS_SECTION_FUNCTION
272 #endif
274 #ifndef CTORS_SECTION_FUNCTION
275 #define CTORS_SECTION_FUNCTION \
276 void \
277 ctors_section () \
279 if (in_section != in_ctors) \
281 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
282 in_section = in_ctors; \
285 #endif
287 #ifndef DTORS_SECTION_FUNCTION
288 #define DTORS_SECTION_FUNCTION \
289 void \
290 dtors_section () \
292 if (in_section != in_dtors) \
294 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
295 in_section = in_dtors; \
298 #endif
300 /* Support the ctors/dtors sections for g++. */
301 #ifndef INT_ASM_OP
302 #define INT_ASM_OP ".word"
303 #endif
305 /* A C statement (sans semicolon) to output an element in the table of
306 global constructors. */
307 #ifndef ASM_OUTPUT_CONSTRUCTOR
308 #define ASM_OUTPUT_CONSTRUCTOR(STREAM,NAME) \
309 do { \
310 ctors_section (); \
311 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \
312 assemble_name (STREAM, NAME); \
313 fprintf (STREAM, "\n"); \
314 } while (0)
315 #endif
317 /* A C statement (sans semicolon) to output an element in the table of
318 global destructors. */
319 #ifndef ASM_OUTPUT_DESTRUCTOR
320 #define ASM_OUTPUT_DESTRUCTOR(STREAM,NAME) \
321 do { \
322 dtors_section (); \
323 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \
324 assemble_name (STREAM, NAME); \
325 fprintf (STREAM, "\n"); \
326 } while (0)
327 #endif
329 /* This is how we tell the assembler that a symbol is weak. */
331 #define ASM_WEAKEN_LABEL(FILE,NAME) \
332 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
333 fputc ('\n', FILE); } while (0)
335 #include "arm/aout.h"