Merge changes from merged-arm-thumb-backend-branch onto trunk.
[official-gcc.git] / gcc / config / arm / unknown-elf.h
blobba5d1edbb4beac977720672f3534d8e0f6f92065
1 /* Definitions for non-Linux based ARM systems using ELF
2 Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
3 Contributed by Catherine Moore <clm@cygnus.com>
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 this program; 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 /* Run-time Target Specification. */
23 #ifndef TARGET_VERSION
24 #define TARGET_VERSION fputs (" (ARM/ELF non-Linux)", stderr);
25 #endif
27 /* If you don't define HAVE_ATEXIT, and the object file format/OS/whatever
28 does not support constructors/destructors, then gcc implements destructors
29 by defining its own exit function, which calls the destructors. This gcc
30 exit function overrides the C library's exit function, and this can cause
31 all kinds of havoc if the C library has a non-trivial exit function. You
32 really don't want to use the exit function in libgcc2.c. */
33 #define HAVE_ATEXIT
35 /* Default to using APCS-32 and software floating point. */
36 #ifndef TARGET_DEFAULT
37 #define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME)
38 #endif
40 /* Now we define the strings used to build the spec file. */
41 #define STARTFILE_SPEC "crtbegin%O%s crt0%O%s"
43 #define ENDFILE_SPEC "crtend%O%s"
45 #define USER_LABEL_PREFIX ""
46 #define LOCAL_LABEL_PREFIX "."
48 #define TEXT_SECTION " .text"
50 #define INVOKE__main
52 /* Debugging */
53 #define DWARF_DEBUGGING_INFO
54 #define DWARF2_DEBUGGING_INFO
55 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
57 /* Support for Constructors and Destrcutors . */
58 #define READONLY_DATA_SECTION rdata_section
60 /* A list of other sections which the compiler might be "in" at any
61 given time. */
62 #define SUBTARGET_EXTRA_SECTIONS in_rdata,
64 /* A list of extra section function definitions. */
65 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS RDATA_SECTION_FUNCTION
67 #define RDATA_SECTION_ASM_OP "\t.section .rodata"
69 #define RDATA_SECTION_FUNCTION \
70 void \
71 rdata_section () \
72 { \
73 if (in_section != in_rdata) \
74 { \
75 fprintf (asm_out_file, "%s\n", RDATA_SECTION_ASM_OP); \
76 in_section = in_rdata; \
77 } \
80 #define CTOR_LIST_BEGIN \
81 asm (CTORS_SECTION_ASM_OP); \
82 func_ptr __CTOR_LIST__[1] = { (func_ptr) (-1) }
84 #define CTOR_LIST_END \
85 asm (CTORS_SECTION_ASM_OP); \
86 func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
88 #define DTOR_LIST_BEGIN \
89 asm (DTORS_SECTION_ASM_OP); \
90 func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) }
92 #define DTOR_LIST_END \
93 asm (DTORS_SECTION_ASM_OP); \
94 func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
96 /* A C statement to output something to the assembler file to switch to section
97 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
98 NULL_TREE. Some target formats do not support arbitrary sections. Do not
99 define this macro in such cases. */
100 #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
101 do \
103 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
104 fprintf (STREAM, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
105 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
106 fprintf (STREAM, "\t.section %s,\"a\"\n", (NAME)); \
107 else if (! strncmp (NAME, ".bss", 4)) \
108 fprintf (STREAM, "\t.section %s,\"aw\",@nobits\n", (NAME)); \
109 else \
110 fprintf (STREAM, "\t.section %s,\"aw\"\n", (NAME)); \
112 while (0)
114 /* Don't know how to order these. UNALIGNED_WORD_ASM_OP is in
115 dwarf2.out. */
116 #define UNALIGNED_WORD_ASM_OP ".4byte"
118 #define ASM_OUTPUT_DWARF2_ADDR_CONST(FILE,ADDR) \
119 fprintf ((FILE), "\t%s\t%s", UNALIGNED_WORD_ASM_OP, ADDR)
121 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \
122 do \
124 fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP); \
125 output_addr_const ((FILE), (RTX)); \
126 fputc ('\n', (FILE)); \
128 while (0)
131 /* The ARM development system defines __main. */
132 #define NAME__MAIN "__gccmain"
133 #define SYMBOL__MAIN __gccmain
135 /* Return a non-zero value if DECL has a section attribute. */
136 #define IN_NAMED_SECTION(DECL) \
137 ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
138 && DECL_SECTION_NAME (DECL) != NULL_TREE)
140 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
142 #define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL) || flag_data_sections)
144 #define UNIQUE_SECTION(DECL, RELOC) \
145 do \
147 int len; \
148 int sec; \
149 const char * name; \
150 char * string; \
151 char * prefix; \
152 static char * prefixes[4][2] = \
154 { ".text.", ".gnu.linkonce.t." }, \
155 { ".rodata.", ".gnu.linkonce.r." }, \
156 { ".data.", ".gnu.linkonce.d." }, \
157 { ".bss.", ".gnu.linkonce.b." } \
158 }; \
160 if (TREE_CODE (DECL) == FUNCTION_DECL) \
161 sec = 0; \
162 else if (DECL_INITIAL (DECL) == 0 \
163 || DECL_INITIAL (DECL) == error_mark_node) \
164 sec = 3; \
165 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
166 sec = 1; \
167 else \
168 sec = 2; \
170 prefix = prefixes[sec][DECL_ONE_ONLY(DECL)]; \
171 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
173 /* Strip off any encoding in name. */ \
174 STRIP_NAME_ENCODING (name, name); \
176 len = strlen (name) + strlen (prefix); \
177 string = alloca (len + 1); \
179 sprintf (string, "%s%s", prefix, name); \
181 DECL_SECTION_NAME (DECL) = build_string (len, string); \
183 while (0)
185 #undef ASM_OUTPUT_ALIGNED_BSS
186 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
187 do \
189 if (IN_NAMED_SECTION (DECL)) \
190 named_section (DECL, NULL, 0); \
191 else \
192 bss_section (); \
194 ASM_GLOBALIZE_LABEL (FILE, NAME); \
196 ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT)); \
198 last_assemble_variable_decl = DECL; \
199 ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL); \
200 ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1); \
202 while (0)
204 #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
205 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
206 do \
208 if (IN_NAMED_SECTION (DECL)) \
209 named_section (DECL, NULL, 0); \
210 else \
211 bss_section (); \
213 ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT)); \
214 ASM_OUTPUT_LABEL (FILE, NAME); \
215 fprintf (FILE, "\t.space\t%d\n", SIZE); \
217 while (0)
219 #ifndef CPP_APCS_PC_DEFAULT_SPEC
220 #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
221 #endif
223 #ifndef SUBTARGET_CPU_DEFAULT
224 #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm7tdmi
225 #endif
227 /* Now get the routine arm-elf definitions. */
228 #include "elf.h"