Apply Dimitri Makarov's patch to import attribute short_call and #pragma
[official-gcc.git] / gcc / config / arm / elf.h
blobb95c7fbecc0f0260cd96f7e63c8e1fb2436f3d2a
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 SUBTARGET_CPP_SPEC
36 #define SUBTARGET_CPP_SPEC "-Darm_elf -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 { \
66 ARM_DECLARE_FUNCTION_NAME (FILE, NAME, DECL); \
67 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
68 assemble_name (FILE, NAME); \
69 putc (',', FILE); \
70 fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
71 putc ('\n', FILE); \
72 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
73 ASM_OUTPUT_LABEL(FILE, NAME); \
74 } \
75 while (0)
77 /* Write the extra assembler code needed to declare an object properly. */
78 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
79 do \
80 { \
81 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
82 assemble_name (FILE, NAME); \
83 putc (',', FILE); \
84 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
85 putc ('\n', FILE); \
86 size_directive_output = 0; \
87 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
88 { \
89 size_directive_output = 1; \
90 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
91 assemble_name (FILE, NAME); \
92 putc (',', FILE); \
93 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
94 int_size_in_bytes (TREE_TYPE (DECL))); \
95 fputc ('\n', FILE); \
96 } \
97 ASM_OUTPUT_LABEL(FILE, NAME); \
98 } \
99 while (0)
101 /* Output the size directive for a decl in rest_of_decl_compilation
102 in the case where we did not do so before the initializer.
103 Once we find the error_mark_node, we know that the value of
104 size_directive_output was set
105 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
106 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
107 do \
109 char * name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
110 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
111 && ! AT_END && TOP_LEVEL \
112 && DECL_INITIAL (DECL) == error_mark_node \
113 && !size_directive_output) \
115 size_directive_output = 1; \
116 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
117 assemble_name (FILE, name); \
118 putc (',', FILE); \
119 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
120 int_size_in_bytes (TREE_TYPE (DECL))); \
121 fputc ('\n', FILE); \
124 while (0)
126 /* This is how to declare the size of a function. */
127 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
128 do \
130 ARM_DECLARE_FUNCTION_SIZE (FILE, FNAME, DECL); \
131 if (!flag_inhibit_size_directive) \
133 char label[256]; \
134 static int labelno; \
135 labelno ++; \
136 ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
137 ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
138 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
139 assemble_name (FILE, (FNAME)); \
140 fprintf (FILE, ","); \
141 assemble_name (FILE, label); \
142 fprintf (FILE, "-"); \
143 assemble_name (FILE, (FNAME)); \
144 putc ('\n', FILE); \
147 while (0)
149 /* Define this macro if jump tables (for `tablejump' insns) should be
150 output in the text section, along with the assembler instructions.
151 Otherwise, the readonly data section is used. */
152 #define JUMP_TABLES_IN_TEXT_SECTION 1
154 #ifndef ASM_SPEC
155 #define ASM_SPEC "%{mbig-endian:-EB} %{mcpu=*:-m%*} %{march=*:-m%*} \
156 %{mapcs-*:-mapcs-%*} %{mthumb-interwork:-mthumb-interwork} %{mapcs-float:mfloat}"
157 #endif
159 #ifndef LINK_SPEC
160 #define LINK_SPEC "%{mbig-endian:-EB} -X"
161 #endif
163 /* Run-time Target Specification. */
164 #ifndef TARGET_VERSION
165 #define TARGET_VERSION fputs (" (ARM/elf)", stderr)
166 #endif
168 #ifndef TARGET_DEFAULT
169 #define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32)
170 #endif
172 #ifndef MULTILIB_DEFAULTS
173 #define MULTILIB_DEFAULTS { "mlittle-endian", "msoft-float", "mapcs-32", "mno-thumb-interwork" }
174 #endif
176 /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS
177 is a valid machine specific attribute for DECL.
178 The attributes in ATTRIBUTES have previously been assigned to DECL. */
179 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \
180 arm_valid_machine_decl_attribute (DECL, 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 \
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 fprintf (STREAM, ASM_APP_OFF); \
207 while (0)
208 #endif
210 /* Output an internal label definition. */
211 #ifndef ASM_OUTPUT_INTERNAL_LABEL
212 #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, PREFIX, NUM) \
213 do \
215 char * s = (char *) alloca (40 + strlen (PREFIX)); \
216 extern int arm_target_label, arm_ccfsm_state; \
217 extern rtx arm_target_insn; \
219 if (arm_ccfsm_state == 3 && arm_target_label == (NUM) \
220 && !strcmp (PREFIX, "L")) \
222 arm_ccfsm_state = 0; \
223 arm_target_insn = NULL; \
225 ASM_GENERATE_INTERNAL_LABEL (s, (PREFIX), (NUM)); \
226 ASM_OUTPUT_LABEL (STREAM, s); \
228 while (0)
229 #endif
231 /* Support the ctors/dtors and other sections. */
233 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
235 Note that we want to give these sections the SHF_WRITE attribute
236 because these sections will actually contain data (i.e. tables of
237 addresses of functions in the current root executable or shared library
238 file) and, in the case of a shared library, the relocatable addresses
239 will have to be properly resolved/relocated (and then written into) by
240 the dynamic linker when it actually attaches the given shared library
241 to the executing process. (Note that on SVR4, you may wish to use the
242 `-z text' option to the ELF linker, when building a shared library, as
243 an additional check that you are doing everything right. But if you do
244 use the `-z text' option when building a shared library, you will get
245 errors unless the .ctors and .dtors sections are marked as writable
246 via the SHF_WRITE attribute.) */
247 #ifndef CTORS_SECTION_ASM_OP
248 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
249 #endif
251 #ifndef DTORS_SECTION_ASM_OP
252 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
253 #endif
255 /* A list of other sections which the compiler might be "in" at any
256 given time. */
257 #ifndef SUBTARGET_EXTRA_SECTIONS
258 #define SUBTARGET_EXTRA_SECTIONS
259 #endif
261 #ifndef EXTRA_SECTIONS
262 #define EXTRA_SECTIONS SUBTARGET_EXTRA_SECTIONS in_ctors, in_dtors
263 #endif
265 /* A list of extra section function definitions. */
266 #ifndef SUBTARGET_EXTRA_SECTION_FUNCTIONS
267 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS
268 #endif
270 #ifndef EXTRA_SECTION_FUNCTIONS
271 #define EXTRA_SECTION_FUNCTIONS \
272 SUBTARGET_EXTRA_SECTION_FUNCTIONS \
273 CTORS_SECTION_FUNCTION \
274 DTORS_SECTION_FUNCTION
275 #endif
277 #ifndef CTORS_SECTION_FUNCTION
278 #define CTORS_SECTION_FUNCTION \
279 void \
280 ctors_section () \
282 if (in_section != in_ctors) \
284 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
285 in_section = in_ctors; \
288 #endif
290 #ifndef DTORS_SECTION_FUNCTION
291 #define DTORS_SECTION_FUNCTION \
292 void \
293 dtors_section () \
295 if (in_section != in_dtors) \
297 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
298 in_section = in_dtors; \
301 #endif
303 /* Support the ctors/dtors sections for g++. */
304 #ifndef INT_ASM_OP
305 #define INT_ASM_OP ".word"
306 #endif
308 /* A C statement (sans semicolon) to output an element in the table of
309 global constructors. */
310 #ifndef ASM_OUTPUT_CONSTRUCTOR
311 #define ASM_OUTPUT_CONSTRUCTOR(STREAM, NAME) \
312 do \
314 ctors_section (); \
315 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \
316 assemble_name (STREAM, NAME); \
317 fprintf (STREAM, "\n"); \
319 while (0)
320 #endif
322 /* A C statement (sans semicolon) to output an element in the table of
323 global destructors. */
324 #ifndef ASM_OUTPUT_DESTRUCTOR
325 #define ASM_OUTPUT_DESTRUCTOR(STREAM, NAME) \
326 do \
328 dtors_section (); \
329 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \
330 assemble_name (STREAM, NAME); \
331 fprintf (STREAM, "\n"); \
333 while (0)
334 #endif
336 /* This is how we tell the assembler that a symbol is weak. */
338 #define ASM_WEAKEN_LABEL(FILE, NAME) \
339 do \
341 fputs ("\t.weak\t", FILE); \
342 assemble_name (FILE, NAME); \
343 fputc ('\n', FILE); \
345 while (0)
347 /* For PIC code we need to explicitly specify (PLT) and (GOT) relocs. */
348 #define NEED_PLT_RELOC flag_pic
349 #define NEED_GOT_RELOC flag_pic
351 /* The ELF assembler handles GOT addressing differently to NetBSD. */
352 #define GOT_PCREL 0
354 /* Biggest alignment supported by the object file format of this
355 machine. Use this macro to limit the alignment which can be
356 specified using the `__attribute__ ((aligned (N)))' construct. If
357 not defined, the default value is `BIGGEST_ALIGNMENT'. */
358 #define MAX_OFILE_ALIGNMENT (32768 * 8)
360 /* Align output to a power of two. Note ".align 0" is redundant,
361 and also GAS will treat it as ".align 2" which we do not want. */
362 #define ASM_OUTPUT_ALIGN(STREAM, POWER) \
363 do \
365 if ((POWER) > 0) \
366 fprintf (STREAM, "\t.align\t%d\n", POWER); \
368 while (0)
370 #include "arm/aout.h"