Daily bump.
[official-gcc.git] / gcc / config / arm / telf.h
blobe1a5cb1be66e32ce04c23f15ba52662f042df6ef
1 /* Definitions of target machine for GNU compiler,
2 for Thumb with ELF obj format.
3 Copyright (C) 1995, 1996, 1999, 2000 Free Software Foundation, Inc.
5 This file is part of GNU CC.
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.
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.
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. */
22 #define OBJECT_FORMAT_ELF
24 #ifndef CPP_PREDEFINES
25 #define CPP_PREDEFINES "-Dthumb -Dthumbelf -D__thumb -Acpu(arm) -Amachine(arm)"
26 #endif
28 #include "arm/thumb.h"
30 /* Run-time Target Specification. */
31 #undef TARGET_VERSION
32 #define TARGET_VERSION fputs (" (Thumb/elf)", stderr)
34 #define MULTILIB_DEFAULTS { "mlittle-endian" }
36 /* Setting this to 32 produces more efficient code, but the value set in previous
37 versions of this toolchain was 8, which produces more compact structures. The
38 command line option -mstructure_size_boundary=<n> can be used to change this
39 value. */
40 #undef STRUCTURE_SIZE_BOUNDARY
41 #define STRUCTURE_SIZE_BOUNDARY arm_structure_size_boundary
43 extern int arm_structure_size_boundary;
45 /* Debug */
46 #define DWARF_DEBUGGING_INFO
47 #define DWARF2_DEBUGGING_INFO
48 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
50 /* Get the standard ELF stabs definitions. */
51 #include "dbxelf.h"
53 /* Note - it is important that these definitions match those in semi.h for the ARM port. */
54 #undef LOCAL_LABEL_PREFIX
55 #define LOCAL_LABEL_PREFIX "."
58 /* A C statement to output assembler commands which will identify the
59 object file as having been compiled with GNU CC (or another GNU
60 compiler). */
61 #ifndef ASM_IDENTIFY_GCC
62 #define ASM_IDENTIFY_GCC(STREAM) \
63 fprintf (STREAM, "%sgcc2_compiled.:\n", LOCAL_LABEL_PREFIX )
64 #endif
66 #undef ASM_FILE_START
67 #define ASM_FILE_START(STREAM) \
68 do \
69 { \
70 fprintf ((STREAM), "%s Generated by gcc %s for Thumb/elf\n", \
71 ASM_COMMENT_START, version_string); \
72 fprintf ((STREAM), ASM_APP_OFF); \
73 } \
74 while (0)
76 /* A C statement to output something to the assembler file to switch to section
77 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
78 NULL_TREE. Some target formats do not support arbitrary sections. Do not
79 define this macro in such cases. */
80 #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
81 do \
82 { \
83 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
84 fprintf (STREAM, "\t.section %s,\"ax\",%%progbits\n", NAME); \
85 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
86 fprintf (STREAM, "\t.section %s,\"a\"\n", NAME); \
87 else if (! strncmp (NAME, ".bss", 4)) \
88 fprintf (STREAM, "\t.section %s,\"aw\",%%nobits\n", NAME); \
89 else \
90 fprintf (STREAM, "\t.section %s,\"aw\"\n", NAME); \
91 } \
92 while (0)
94 /* Support the ctors/dtors and other sections. */
96 #undef INIT_SECTION_ASM_OP
98 /* Define this macro if jump tables (for `tablejump' insns) should be
99 output in the text section, along with the assembler instructions.
100 Otherwise, the readonly data section is used. */
101 #define JUMP_TABLES_IN_TEXT_SECTION 1
103 #undef READONLY_DATA_SECTION
104 #define READONLY_DATA_SECTION rdata_section
105 #undef RDATA_SECTION_ASM_OP
106 #define RDATA_SECTION_ASM_OP "\t.section .rodata"
108 #undef CTORS_SECTION_ASM_OP
109 #define CTORS_SECTION_ASM_OP "\t.section .ctors,\"aw\""
110 #undef DTORS_SECTION_ASM_OP
111 #define DTORS_SECTION_ASM_OP "\t.section .dtors,\"aw\""
113 #define USER_LABEL_PREFIX ""
115 /* If defined, a C expression whose value is a string containing the
116 assembler operation to identify the following data as
117 uninitialized global data. If not defined, and neither
118 `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
119 uninitialized global data will be output in the data section if
120 `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
121 used. */
122 #ifndef BSS_SECTION_ASM_OP
123 #define BSS_SECTION_ASM_OP ".section\t.bss"
124 #endif
126 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
127 separate, explicit argument. If you define this macro, it is used
128 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
129 handling the required alignment of the variable. The alignment is
130 specified as the number of bits.
132 Try to use function `asm_output_aligned_bss' defined in file
133 `varasm.c' when defining this macro. */
134 #ifndef ASM_OUTPUT_ALIGNED_BSS
135 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
136 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
137 #endif
139 /* Don't know how to order these. UNALIGNED_WORD_ASM_OP is in
140 dwarf2.out. */
141 #define UNALIGNED_WORD_ASM_OP ".4byte"
143 #define ASM_OUTPUT_DWARF2_ADDR_CONST(FILE,ADDR) \
144 if (((ADDR)[0] == '.') && ((ADDR)[1] == 'L')) \
145 fprintf ((FILE), "\t%s\t%s", UNALIGNED_WORD_ASM_OP, (ADDR)); \
146 else \
147 fprintf ((FILE), "\t%s\t%s", \
148 UNALIGNED_WORD_ASM_OP, (ADDR))
150 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \
151 do \
153 fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP); \
154 output_addr_const ((FILE), (RTX)); \
155 fputc ('\n', (FILE)); \
157 while (0)
159 /* This is how to equate one symbol to another symbol. The syntax used is
160 `SYM1=SYM2'. Note that this is different from the way equates are done
161 with most svr4 assemblers, where the syntax is `.set SYM1,SYM2'. */
163 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
164 do \
166 fprintf ((FILE), "\t"); \
167 assemble_name (FILE, LABEL1); \
168 fprintf (FILE, " = "); \
169 assemble_name (FILE, LABEL2); \
170 fprintf (FILE, "\n"); \
172 while (0)
174 /* For aliases of functions we use .thumb_set instead. */
175 #define ASM_OUTPUT_DEF_FROM_DECLS(FILE,DECL1,DECL2) \
176 do \
178 const char * LABEL1 = XSTR (XEXP (DECL_RTL (decl), 0), 0);\
179 const char * LABEL2 = IDENTIFIER_POINTER (DECL2); \
181 if (TREE_CODE (DECL1) == FUNCTION_DECL) \
183 fprintf (FILE, "\t.thumb_set "); \
184 assemble_name (FILE, LABEL1); \
185 fprintf (FILE, ","); \
186 assemble_name (FILE, LABEL2); \
187 fprintf (FILE, "\n"); \
189 else \
190 ASM_OUTPUT_DEF (FILE, LABEL1, LABEL2); \
192 while (0)
194 /* A list of other sections which the compiler might be "in" at any
195 given time. */
196 #undef EXTRA_SECTIONS
197 #define EXTRA_SECTIONS SUBTARGET_EXTRA_SECTIONS in_rdata, in_ctors, in_dtors
199 #ifndef SUBTARGET_EXTRA_SECTIONS
200 #define SUBTARGET_EXTRA_SECTIONS
201 #endif
203 /* A list of extra section function definitions. */
205 #undef EXTRA_SECTION_FUNCTIONS
206 #define EXTRA_SECTION_FUNCTIONS \
207 RDATA_SECTION_FUNCTION \
208 CTORS_SECTION_FUNCTION \
209 DTORS_SECTION_FUNCTION \
210 SUBTARGET_EXTRA_SECTION_FUNCTIONS
212 #ifndef SUBTARGET_EXTRA_SECTION_FUNCTIONS
213 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS
214 #endif
216 #define RDATA_SECTION_FUNCTION \
217 void \
218 rdata_section () \
220 if (in_section != in_rdata) \
222 fprintf (asm_out_file, "%s\n", RDATA_SECTION_ASM_OP); \
223 in_section = in_rdata; \
227 #define CTOR_LIST_BEGIN \
228 asm (CTORS_SECTION_ASM_OP); \
229 func_ptr __CTOR_LIST__[1] = { (func_ptr) (-1) }
231 #define CTOR_LIST_END \
232 asm (CTORS_SECTION_ASM_OP); \
233 func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
235 #define DTOR_LIST_BEGIN \
236 asm (DTORS_SECTION_ASM_OP); \
237 func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) }
239 #define DTOR_LIST_END \
240 asm (DTORS_SECTION_ASM_OP); \
241 func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
243 #define CTORS_SECTION_FUNCTION \
244 void \
245 ctors_section () \
247 if (in_section != in_ctors) \
249 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
250 in_section = in_ctors; \
254 #define DTORS_SECTION_FUNCTION \
255 void \
256 dtors_section () \
258 if (in_section != in_dtors) \
260 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
261 in_section = in_dtors; \
265 /* Support the ctors/dtors sections for g++. */
267 #define INT_ASM_OP ".word"
269 #define INVOKE__main
271 #undef STARTFILE_SPEC
272 #define STARTFILE_SPEC "crtbegin%O%s crt0%O%s"
274 #undef ENDFILE_SPEC
275 #define ENDFILE_SPEC "crtend%O%s"
277 /* A C statement (sans semicolon) to output an element in the table of
278 global constructors. */
279 #undef ASM_OUTPUT_CONSTRUCTOR
280 #define ASM_OUTPUT_CONSTRUCTOR(STREAM,NAME) \
281 do \
283 ctors_section (); \
284 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \
285 assemble_name (STREAM, NAME); \
286 fprintf (STREAM, "\n"); \
288 while (0)
290 /* A C statement (sans semicolon) to output an element in the table of
291 global destructors. */
292 #undef ASM_OUTPUT_DESTRUCTOR
293 #define ASM_OUTPUT_DESTRUCTOR(STREAM,NAME) \
294 do \
296 dtors_section (); \
297 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \
298 assemble_name (STREAM, NAME); \
299 fprintf (STREAM, "\n"); \
301 while (0)
303 /* The ARM development system defines __main. */
304 #define NAME__MAIN "__gccmain"
305 #define SYMBOL__MAIN __gccmain
307 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
308 #define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
309 #define UNIQUE_SECTION(DECL,RELOC) \
310 do \
312 int len; \
313 char * name, * string, * prefix; \
315 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
317 if (! DECL_ONE_ONLY (DECL)) \
319 prefix = "."; \
320 if (TREE_CODE (DECL) == FUNCTION_DECL) \
321 prefix = ".text."; \
322 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
323 prefix = ".rodata."; \
324 else \
325 prefix = ".data."; \
327 else if (TREE_CODE (DECL) == FUNCTION_DECL) \
328 prefix = ".gnu.linkonce.t."; \
329 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
330 prefix = ".gnu.linkonce.r."; \
331 else \
332 prefix = ".gnu.linkonce.d."; \
334 len = strlen (name) + strlen (prefix); \
335 string = alloca (len + 1); \
336 sprintf (string, "%s%s", prefix, name); \
338 DECL_SECTION_NAME (DECL) = build_string (len, string); \
340 while (0)
342 /* This is how we tell the assembler that a symbol is weak. */
343 #ifndef ASM_WEAKEN_LABEL
344 #define ASM_WEAKEN_LABEL(FILE, NAME) \
345 do \
347 fputs ("\t.weak\t", FILE); \
348 assemble_name (FILE, NAME); \
349 fputc ('\n', FILE); \
351 while (0)
352 #endif
354 #ifndef TYPE_ASM_OP
356 /* These macros generate the special .type and .size directives which
357 are used to set the corresponding fields of the linker symbol table
358 entries in an ELF object file under SVR4. These macros also output
359 the starting labels for the relevant functions/objects. */
360 #define TYPE_ASM_OP ".type"
361 #define SIZE_ASM_OP ".size"
363 /* The following macro defines the format used to output the second
364 operand of the .type assembler directive. Different svr4 assemblers
365 expect various different forms for this operand. The one given here
366 is just a default. You may need to override it in your machine-
367 specific tm.h file (depending upon the particulars of your assembler). */
368 #define TYPE_OPERAND_FMT "%s"
370 /* Write the extra assembler code needed to declare a function's result.
371 Most svr4 assemblers don't require any special declaration of the
372 result value, but there are exceptions. */
373 #ifndef ASM_DECLARE_RESULT
374 #define ASM_DECLARE_RESULT(FILE, RESULT)
375 #endif
377 /* Write the extra assembler code needed to declare a function properly.
378 Some svr4 assemblers need to also have something extra said about the
379 function's return value. We allow for that here. */
380 #undef ASM_DECLARE_FUNCTION_NAME
381 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
382 do \
384 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
385 assemble_name (FILE, NAME); \
386 putc (',', FILE); \
387 fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
388 putc ('\n', FILE); \
389 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
390 if (! is_called_in_ARM_mode (decl)) \
391 fprintf (FILE, "\t.thumb_func\n") ; \
392 else \
393 fprintf (FILE, "\t.code\t32\n") ; \
394 ASM_OUTPUT_LABEL(FILE, NAME); \
396 while (0)
398 /* Write the extra assembler code needed to declare an object properly. */
399 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
400 do \
402 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
403 assemble_name (FILE, NAME); \
404 putc (',', FILE); \
405 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
406 putc ('\n', FILE); \
407 size_directive_output = 0; \
408 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
410 size_directive_output = 1; \
411 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
412 assemble_name (FILE, NAME); \
413 putc (',', FILE); \
414 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
415 int_size_in_bytes (TREE_TYPE (DECL))); \
416 fputc ('\n', FILE); \
418 ASM_OUTPUT_LABEL(FILE, NAME); \
420 while (0)
422 /* Output the size directive for a decl in rest_of_decl_compilation
423 in the case where we did not do so before the initializer.
424 Once we find the error_mark_node, we know that the value of
425 size_directive_output was set
426 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
427 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)\
428 do \
430 const char * name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
431 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
432 && ! AT_END && TOP_LEVEL \
433 && DECL_INITIAL (DECL) == error_mark_node \
434 && !size_directive_output) \
436 size_directive_output = 1; \
437 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
438 assemble_name (FILE, name); \
439 putc (',', FILE); \
440 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
441 int_size_in_bytes (TREE_TYPE (DECL))); \
442 fputc ('\n', FILE); \
445 while (0)
447 /* This is how to declare the size of a function. */
448 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
449 do \
451 if (!flag_inhibit_size_directive) \
453 char label[256]; \
454 static int labelno; \
455 labelno ++; \
456 ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
457 ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
458 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
459 assemble_name (FILE, (FNAME)); \
460 fprintf (FILE, ","); \
461 assemble_name (FILE, label); \
462 fprintf (FILE, "-"); \
463 assemble_name (FILE, (FNAME)); \
464 putc ('\n', FILE); \
467 while (0)
469 #endif /* TYPE_ASM_OP */