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)
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 "."
31 #ifndef USER_LABEL_PREFIX
32 #define USER_LABEL_PREFIX ""
35 #ifndef CPP_PREDEFINES
36 #define CPP_PREDEFINES "-Darm -Darm_elf -Acpu(arm) -Amachine(arm) -D__ELF__"
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)
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) \
66 if (TARGET_POKE_FUNCTION_NAME) \
67 arm_poke_function_name (FILE, NAME); \
68 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
69 assemble_name (FILE, NAME); \
71 fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
73 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
74 ASM_OUTPUT_LABEL(FILE, NAME); \
78 /* Write the extra assembler code needed to declare an object properly. */
79 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
81 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
82 assemble_name (FILE, NAME); \
84 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
86 size_directive_output = 0; \
87 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
89 size_directive_output = 1; \
90 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
91 assemble_name (FILE, NAME); \
93 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
94 int_size_in_bytes (TREE_TYPE (DECL))); \
97 ASM_OUTPUT_LABEL(FILE, NAME); \
100 /* Output the size directive for a decl in rest_of_decl_compilation
101 in the case where we did not do so before the initializer.
102 Once we find the error_mark_node, we know that the value of
103 size_directive_output was set
104 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
105 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
107 char * name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
108 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
109 && ! AT_END && TOP_LEVEL \
110 && DECL_INITIAL (DECL) == error_mark_node \
111 && !size_directive_output) \
113 size_directive_output = 1; \
114 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
115 assemble_name (FILE, name); \
117 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
118 int_size_in_bytes (TREE_TYPE (DECL))); \
119 fputc ('\n', FILE); \
123 /* This is how to declare the size of a function. */
124 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
126 if (!flag_inhibit_size_directive) \
129 static int labelno; \
131 ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
132 ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
133 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
134 assemble_name (FILE, (FNAME)); \
135 fprintf (FILE, ","); \
136 assemble_name (FILE, label); \
137 fprintf (FILE, "-"); \
138 assemble_name (FILE, (FNAME)); \
143 /* Define this macro if jump tables (for `tablejump' insns) should be
144 output in the text section, along with the assembler instructions.
145 Otherwise, the readonly data section is used. */
146 #define JUMP_TABLES_IN_TEXT_SECTION 1
149 #define ASM_SPEC "%{mbig-endian:-EB} %{mcpu=*:-m%*} %{march=*:-m%*} \
150 %{mapcs-*:-mapcs-%*} %{mthumb-interwork:-mthumb-interwork} %{mapcs-float:mfloat}"
154 #define LINK_SPEC "%{mbig-endian:-EB} -X"
157 /* Run-time Target Specification. */
158 #ifndef TARGET_VERSION
159 #define TARGET_VERSION fputs (" (ARM/elf)", stderr)
162 #ifndef TARGET_DEFAULT
163 #define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32)
166 #ifndef MULTILIB_DEFAULTS
167 #define MULTILIB_DEFAULTS { "mlittle-endian", "msoft-float", "mapcs-32", "mno-thumb-interwork" }
170 /* Setting this to 32 produces more efficient code, but the value set in previous
171 versions of this toolchain was 8, which produces more compact structures. The
172 command line option -mstructure_size_boundary=<n> can be used to change this
174 #undef STRUCTURE_SIZE_BOUNDARY
175 #define STRUCTURE_SIZE_BOUNDARY arm_structure_size_boundary
177 extern int arm_structure_size_boundary;
179 /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS
180 is a valid machine specific attribute for DECL.
181 The attributes in ATTRIBUTES have previously been assigned to DECL. */
182 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \
183 arm_valid_machine_decl_attribute (DECL, IDENTIFIER, ARGS)
186 /* A C statement to output assembler commands which will identify the
187 object file as having been compiled with GNU CC (or another GNU
189 /* Define this to NULL so we don't get anything.
190 We have ASM_IDENTIFY_LANGUAGE.
191 Also, when using stabs, gcc2_compiled must be a stabs entry, not an
192 ordinary symbol, or gdb won't see it. The stabs entry must be
193 before the N_SO in order for gdb to find it. */
194 #ifndef ASM_IDENTIFY_GCC
195 #define ASM_IDENTIFY_GCC(STREAM) \
196 fprintf (STREAM, "%sgcc2_compiled.:\n", LOCAL_LABEL_PREFIX )
199 /* This outputs a lot of .req's to define alias for various registers.
200 Let's try to avoid this. */
201 #ifndef ASM_FILE_START
202 #define ASM_FILE_START(STREAM) \
204 extern char * version_string; \
205 fprintf (STREAM, "%s Generated by gcc %s for ARM/elf\n", \
206 ASM_COMMENT_START, version_string); \
207 output_file_directive ((STREAM), main_input_filename); \
211 /* Output an internal label definition. */
212 #ifndef ASM_OUTPUT_INTERNAL_LABEL
213 #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, PREFIX, NUM) \
216 char * s = (char *) alloca (40 + strlen (PREFIX)); \
217 extern int arm_target_label, arm_ccfsm_state; \
218 extern rtx arm_target_insn; \
220 if (arm_ccfsm_state == 3 && arm_target_label == (NUM) \
221 && !strcmp (PREFIX, "L")) \
223 arm_ccfsm_state = 0; \
224 arm_target_insn = NULL; \
226 ASM_GENERATE_INTERNAL_LABEL (s, (PREFIX), (NUM)); \
227 ASM_OUTPUT_LABEL (STREAM, s); \
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\""
251 #ifndef DTORS_SECTION_ASM_OP
252 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
255 /* A list of other sections which the compiler might be "in" at any
257 #ifndef SUBTARGET_EXTRA_SECTIONS
258 #define SUBTARGET_EXTRA_SECTIONS
261 #ifndef EXTRA_SECTIONS
262 #define EXTRA_SECTIONS SUBTARGET_EXTRA_SECTIONS in_ctors, in_dtors
265 /* A list of extra section function definitions. */
266 #ifndef SUBTARGET_EXTRA_SECTION_FUNCTIONS
267 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS
270 #ifndef EXTRA_SECTION_FUNCTIONS
271 #define EXTRA_SECTION_FUNCTIONS \
272 SUBTARGET_EXTRA_SECTION_FUNCTIONS \
273 CTORS_SECTION_FUNCTION \
274 DTORS_SECTION_FUNCTION
277 #ifndef CTORS_SECTION_FUNCTION
278 #define CTORS_SECTION_FUNCTION \
282 if (in_section != in_ctors) \
284 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
285 in_section = in_ctors; \
290 #ifndef DTORS_SECTION_FUNCTION
291 #define DTORS_SECTION_FUNCTION \
295 if (in_section != in_dtors) \
297 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
298 in_section = in_dtors; \
303 /* Support the ctors/dtors sections for g++. */
305 #define INT_ASM_OP ".word"
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) \
314 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \
315 assemble_name (STREAM, NAME); \
316 fprintf (STREAM, "\n"); \
320 /* A C statement (sans semicolon) to output an element in the table of
321 global destructors. */
322 #ifndef ASM_OUTPUT_DESTRUCTOR
323 #define ASM_OUTPUT_DESTRUCTOR(STREAM,NAME) \
326 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \
327 assemble_name (STREAM, NAME); \
328 fprintf (STREAM, "\n"); \
332 /* This is how we tell the assembler that a symbol is weak. */
334 #define ASM_WEAKEN_LABEL(FILE,NAME) \
335 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
336 fputc ('\n', FILE); } while (0)
338 /* For PIC code we need to explicitly specify (PLT) and (GOT) relocs. */
339 #define NEED_PLT_GOT flag_pic
341 #include "arm/aout.h"