Merge changes from merged-arm-thumb-backend-branch onto trunk.
[official-gcc.git] / gcc / config / arm / linux-elf.h
blobf357d67e4d113b31b591a0db5ea2dbc296b1b0e8
1 /* Definitions for ARM running Linux-based GNU systems using ELF
2 Copyright (C) 1993, 1994, 1997, 1998, 1999 Free Software Foundation, Inc.
3 Contributed by Philip Blundell <philb@gnu.org>
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 #define TARGET_VERSION fputs (" (ARM GNU/Linux with ELF)", stderr);
25 /* Do not assume anything about header files. */
26 #define NO_IMPLICIT_EXTERN_C
28 #ifndef SUBTARGET_DEFAULT_APCS26
29 /* Default is to use APCS-32 mode. */
30 # define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_MMU_TRAPS)
31 # ifdef SUBTARGET_OLD_LINKER
32 # define SUBTARGET_EXTRA_LINK_SPEC \
33 " %{mapcs-26:-m elf32arm26} %{!mapcs-26:-m elf32arm}"
34 # else /* new linker */
35 # define SUBTARGET_EXTRA_LINK_SPEC \
36 " %{mapcs-26:-m armelf_linux26} %{!mapcs-26:-m armelf_linux} -p"
37 # endif
38 # define SUBTARGET_EXTRA_ASM_SPEC \
39 " %{mapcs-26:-mapcs-26} %{!mapcs-26:-mapcs-32}"
40 # define MULTILIB_DEFAULTS \
41 { "marm", "mlittle-endian", "mhard-float", "mapcs-32", "mno-thumb-interwork" }
42 # define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
43 #else /* default is APCS-26 */
44 # define TARGET_DEFAULT (ARM_FLAG_MMU_TRAPS)
45 # ifdef SUBTARGET_OLD_LINKER
46 # define SUBTARGET_EXTRA_LINK_SPEC \
47 " %{mapcs-32:-m elf32arm} %{!mapcs-32:-m elf32arm26}"
48 # else /* new linker */
49 # define SUBTARGET_EXTRA_LINK_SPEC \
50 " %{mapcs-32:-m armelf_linux} %{!mapcs-32:-m armelf_linux26} -p"
51 # endif
52 # define SUBTARGET_EXTRA_ASM_SPEC \
53 " %{mapcs-32:-mapcs-32} %{!mapcs-32:-mapcs-26}"
54 # define MULTILIB_DEFAULTS \
55 { "marm", "mlittle-endian", "mhard-float", "mapcs-26", "mno-thumb-interwork" }
56 #endif
58 /* This was defined in linux.h. Define it here also. */
59 #undef DEFAULT_VTABLE_THUNKS
60 #define DEFAULT_VTABLE_THUNKS 1
62 /* Handle #pragma weak and #pragma pack. */
63 #define HANDLE_SYSV_PRAGMA
65 /* Now we define the strings used to build the spec file. */
66 #define LIB_SPEC \
67 "%{shared: -lc} \
68 %{!shared: %{pthread:-lpthread} \
69 %{profile:-lc_p} %{!profile: -lc}}"
72 #define LIBGCC_SPEC "%{msoft-float:-lfloat} -lgcc"
74 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
75 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
76 provides part of the support for getting C++ file-scope static
77 object constructed before entering `main'. */
79 #define STARTFILE_SPEC \
80 "%{!shared: \
81 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
82 %{!p:%{profile:gcrt1.o%s} \
83 %{!profile:crt1.o%s}}}} \
84 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
86 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
87 the GNU/Linux magical crtend.o file (see crtstuff.c) which
88 provides part of the support for getting C++ file-scope static
89 object constructed before entering `main', followed by a normal
90 GNU/Linux "finalizer" file, `crtn.o'. */
92 #define ENDFILE_SPEC \
93 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
95 #define LINK_SPEC "%{h*} %{version:-v} \
96 %{b} %{Wl,*:%*} \
97 %{static:-Bstatic} \
98 %{shared:-shared} \
99 %{symbolic:-Bsymbolic} \
100 %{rdynamic:-export-dynamic} \
101 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
102 -X \
103 %{mbig-endian:-EB}" \
104 SUBTARGET_EXTRA_LINK_SPEC
106 #undef CPP_PREDEFINES
107 #define CPP_PREDEFINES \
108 "-Dunix -D__arm__ -Dlinux -D__ELF__ \
109 -Asystem(unix) -Asystem(posix) -Acpu(arm) -Amachine(arm)"
111 /* Allow #sccs in preprocessor. */
112 #define SCCS_DIRECTIVE
114 #define USER_LABEL_PREFIX "" /* For ELF the default is no underscores */
115 #define LOCAL_LABEL_PREFIX "."
117 /* Attach a special .ident directive to the end of the file to identify
118 the version of GCC which compiled this code. */
119 #define IDENT_ASM_OP ".ident"
121 /* Output #ident as a .ident. */
122 #define ASM_OUTPUT_IDENT(FILE, NAME) \
123 fprintf (FILE, "\t%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
125 #ifdef IDENTIFY_WITH_IDENT
126 #define ASM_IDENTIFY_GCC(FILE) /* nothing */
127 #define ASM_IDENTIFY_LANGUAGE(FILE) \
128 fprintf (FILE, "\t%s \"GCC (%s) %s\"\n", IDENT_ASM_OP, \
129 lang_identify (), version_string)
130 #else
131 #define ASM_FILE_END(FILE) \
132 do { \
133 if (!flag_no_ident) \
134 fprintf ((FILE), "\t%s\t\"GCC: (GNU) %s\"\n", \
135 IDENT_ASM_OP, version_string); \
136 } while (0)
137 #endif
139 /* Support const sections and the ctors and dtors sections for g++.
140 Note that there appears to be two different ways to support const
141 sections at the moment. You can either #define the symbol
142 READONLY_DATA_SECTION (giving it some code which switches to the
143 readonly data section) or else you can #define the symbols
144 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
145 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
146 #define USE_CONST_SECTION 1
148 /* Support for Constructors and Destructors. */
149 #define READONLY_DATA_SECTION() const_section ()
151 /* A default list of other sections which we might be "in" at any given
152 time. For targets that use additional sections (e.g. .tdesc) you
153 should override this definition in the target-specific file which
154 includes this file. */
155 #define SUBTARGET_EXTRA_SECTIONS in_const,
157 /* A default list of extra section function definitions. For targets
158 that use additional sections (e.g. .tdesc) you should override this
159 definition in the target-specific file which includes this file. */
160 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS CONST_SECTION_FUNCTION
162 extern void text_section ();
164 #define CONST_SECTION_ASM_OP ".section\t.rodata"
166 #define CONST_SECTION_FUNCTION \
167 void \
168 const_section () \
170 if (!USE_CONST_SECTION) \
171 text_section (); \
172 else if (in_section != in_const) \
174 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
175 in_section = in_const; \
179 /* Switch into a generic section.
180 This is currently only used to support section attributes.
182 We make the section read-only and executable for a function decl,
183 read-only for a const data decl, and writable for a non-const data decl. */
184 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
185 fprintf (FILE, ".section\t%s,\"%s\",%%progbits\n", NAME, \
186 (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
187 (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
189 /* A C statement or statements to switch to the appropriate
190 section for output of DECL. DECL is either a `VAR_DECL' node
191 or a constant of some sort. RELOC indicates whether forming
192 the initial value of DECL requires link-time relocations. */
193 #define SELECT_SECTION(DECL,RELOC) \
195 if (TREE_CODE (DECL) == STRING_CST) \
197 if (! flag_writable_strings) \
198 const_section (); \
199 else \
200 data_section (); \
202 else if (TREE_CODE (DECL) == VAR_DECL) \
204 if ((flag_pic && RELOC) \
205 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
206 || !DECL_INITIAL (DECL) \
207 || (DECL_INITIAL (DECL) != error_mark_node \
208 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
209 data_section (); \
210 else \
211 const_section (); \
213 else \
214 const_section (); \
217 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
218 #define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
220 #define UNIQUE_SECTION(DECL, RELOC) \
221 do \
223 int len; \
224 char * name; \
225 char * string; \
226 char * prefix; \
228 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
230 if (! DECL_ONE_ONLY (DECL)) \
232 prefix = "."; \
233 if (TREE_CODE (DECL) == FUNCTION_DECL) \
234 prefix = ".text."; \
235 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
236 prefix = ".rodata."; \
237 else \
238 prefix = ".data."; \
240 else if (TREE_CODE (DECL) == FUNCTION_DECL) \
241 prefix = ".gnu.linkonce.t."; \
242 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
243 prefix = ".gnu.linkonce.r."; \
244 else \
245 prefix = ".gnu.linkonce.d."; \
247 len = strlen (name) + strlen (prefix); \
248 string = alloca (len + 1); \
249 sprintf (string, "%s%s", prefix, name); \
251 DECL_SECTION_NAME (DECL) = build_string (len, string); \
253 while (0)
255 /* A C statement or statements to switch to the appropriate
256 section for output of RTX in mode MODE. RTX is some kind
257 of constant in RTL. The argument MODE is redundant except
258 in the case of a `const_int' rtx. Currently, these always
259 go into the const section. */
260 #define SELECT_RTX_SECTION(MODE,RTX) const_section ()
262 /* On svr4, we *do* have support for the .init and .fini sections, and we
263 can put stuff in there to be executed before and after `main'. We let
264 crtstuff.c and other files know this by defining the following symbols.
265 The definitions say how to change sections to the .init and .fini
266 sections. This is the same for all known svr4 assemblers. */
267 #define INIT_SECTION_ASM_OP ".section\t.init"
268 #define FINI_SECTION_ASM_OP ".section\t.fini"
271 /* This is how we tell the assembler that a symbol is weak. */
272 #define ASM_WEAKEN_LABEL(FILE,NAME) \
273 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
274 fputc ('\n', FILE); } while (0)
276 /* This is how we tell the assembler that two symbols have the same value. */
278 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
279 do { assemble_name (FILE, NAME1); \
280 fputs (" = ", FILE); \
281 assemble_name (FILE, NAME2); \
282 fputc ('\n', FILE); } while (0)
284 /* Make DWARF2 an option, but keep DBX as the default for now.
285 Use -gdwarf-2 to turn on DWARF2. */
286 #define DWARF2_DEBUGGING_INFO
287 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
289 /* Get the standard ELF stabs definitions. */
290 #include "dbxelf.h"
292 #include "arm/elf.h"
293 #include "arm/linux-gas.h"
295 /* NWFPE always understands FPA instructions. */
296 #undef FP_DEFAULT
297 #define FP_DEFAULT FP_SOFT3
299 /* Call the function profiler with a given profile label. */
300 #undef ARM_FUNCTION_PROFILER
301 #define ARM_FUNCTION_PROFILER(STREAM, LABELNO) \
303 fprintf (STREAM, "\tbl\tmcount%s\n", NEED_PLT_RELOC ? "(PLT)" : ""); \
306 #undef CC1_SPEC
307 #define CC1_SPEC "%{profile:-p}"