Apply Philip Blundell's patch to fix typos in SUBTARGET_EXTRA_LINK_SPEC
[official-gcc.git] / gcc / config / arm / linux-elf.h
blob598d1c93a0639c1318b8c71f6f908dd8fc174f8c
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 { "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 { "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 #define ASM_SPEC "%{mbig-endian:-EB} \
107 %{mcpu=*:-m%*} %{march=*:-m%*} \
108 %{mthumb-interwork:-mthumb-interwork} \
109 %{msoft-float:-mno-fpu} \
110 %{mapcs-float:-mfloat}" \
111 SUBTARGET_EXTRA_ASM_SPEC
113 #undef CPP_PREDEFINES
114 #define CPP_PREDEFINES \
115 "-Dunix -D__arm__ -Dlinux -D__ELF__ \
116 -Asystem(unix) -Asystem(posix) -Acpu(arm) -Amachine(arm)"
118 /* Allow #sccs in preprocessor. */
119 #define SCCS_DIRECTIVE
121 #define USER_LABEL_PREFIX "" /* For ELF the default is no underscores */
122 #define LOCAL_LABEL_PREFIX "."
124 /* Attach a special .ident directive to the end of the file to identify
125 the version of GCC which compiled this code. */
126 #define IDENT_ASM_OP ".ident"
128 /* Output #ident as a .ident. */
129 #define ASM_OUTPUT_IDENT(FILE, NAME) \
130 fprintf (FILE, "\t%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
132 #ifdef IDENTIFY_WITH_IDENT
133 #define ASM_IDENTIFY_GCC(FILE) /* nothing */
134 #define ASM_IDENTIFY_LANGUAGE(FILE) \
135 fprintf (FILE, "\t%s \"GCC (%s) %s\"\n", IDENT_ASM_OP, \
136 lang_identify (), version_string)
137 #else
138 #define ASM_FILE_END(FILE) \
139 do { \
140 if (!flag_no_ident) \
141 fprintf ((FILE), "\t%s\t\"GCC: (GNU) %s\"\n", \
142 IDENT_ASM_OP, version_string); \
143 } while (0)
144 #endif
146 /* Support const sections and the ctors and dtors sections for g++.
147 Note that there appears to be two different ways to support const
148 sections at the moment. You can either #define the symbol
149 READONLY_DATA_SECTION (giving it some code which switches to the
150 readonly data section) or else you can #define the symbols
151 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
152 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
153 #define USE_CONST_SECTION 1
155 /* Support for Constructors and Destructors. */
156 #define READONLY_DATA_SECTION() const_section ()
158 /* A default list of other sections which we might be "in" at any given
159 time. For targets that use additional sections (e.g. .tdesc) you
160 should override this definition in the target-specific file which
161 includes this file. */
162 #define SUBTARGET_EXTRA_SECTIONS in_const,
164 /* A default list of extra section function definitions. For targets
165 that use additional sections (e.g. .tdesc) you should override this
166 definition in the target-specific file which includes this file. */
167 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS CONST_SECTION_FUNCTION
169 #define CONST_SECTION_ASM_OP ".section\t.rodata"
171 #define CONST_SECTION_FUNCTION \
172 void \
173 const_section () \
175 if (!USE_CONST_SECTION) \
176 text_section (); \
177 else if (in_section != in_const) \
179 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
180 in_section = in_const; \
184 /* Switch into a generic section.
185 This is currently only used to support section attributes.
187 We make the section read-only and executable for a function decl,
188 read-only for a const data decl, and writable for a non-const data decl. */
189 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
190 fprintf (FILE, ".section\t%s,\"%s\",%%progbits\n", NAME, \
191 (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
192 (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
194 /* A C statement or statements to switch to the appropriate
195 section for output of DECL. DECL is either a `VAR_DECL' node
196 or a constant of some sort. RELOC indicates whether forming
197 the initial value of DECL requires link-time relocations. */
198 #define SELECT_SECTION(DECL,RELOC) \
200 if (TREE_CODE (DECL) == STRING_CST) \
202 if (! flag_writable_strings) \
203 const_section (); \
204 else \
205 data_section (); \
207 else if (TREE_CODE (DECL) == VAR_DECL) \
209 if ((flag_pic && RELOC) \
210 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
211 || !DECL_INITIAL (DECL) \
212 || (DECL_INITIAL (DECL) != error_mark_node \
213 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
214 data_section (); \
215 else \
216 const_section (); \
218 else \
219 const_section (); \
222 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
223 #define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
225 #define UNIQUE_SECTION(DECL, RELOC) \
226 do \
228 int len; \
229 char * name; \
230 char * string; \
231 char * prefix; \
233 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
235 if (! DECL_ONE_ONLY (DECL)) \
237 prefix = "."; \
238 if (TREE_CODE (DECL) == FUNCTION_DECL) \
239 prefix = ".text."; \
240 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
241 prefix = ".rodata."; \
242 else \
243 prefix = ".data."; \
245 else if (TREE_CODE (DECL) == FUNCTION_DECL) \
246 prefix = ".gnu.linkonce.t."; \
247 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
248 prefix = ".gnu.linkonce.r."; \
249 else \
250 prefix = ".gnu.linkonce.d."; \
252 len = strlen (name) + strlen (prefix); \
253 string = alloca (len + 1); \
254 sprintf (string, "%s%s", prefix, name); \
256 DECL_SECTION_NAME (DECL) = build_string (len, string); \
258 while (0)
260 /* A C statement or statements to switch to the appropriate
261 section for output of RTX in mode MODE. RTX is some kind
262 of constant in RTL. The argument MODE is redundant except
263 in the case of a `const_int' rtx. Currently, these always
264 go into the const section. */
265 #define SELECT_RTX_SECTION(MODE,RTX) const_section ()
267 /* On svr4, we *do* have support for the .init and .fini sections, and we
268 can put stuff in there to be executed before and after `main'. We let
269 crtstuff.c and other files know this by defining the following symbols.
270 The definitions say how to change sections to the .init and .fini
271 sections. This is the same for all known svr4 assemblers. */
272 #define INIT_SECTION_ASM_OP ".section\t.init"
273 #define FINI_SECTION_ASM_OP ".section\t.fini"
276 /* This is how we tell the assembler that a symbol is weak. */
277 #define ASM_WEAKEN_LABEL(FILE,NAME) \
278 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
279 fputc ('\n', FILE); } while (0)
281 /* This is how we tell the assembler that two symbols have the same value. */
283 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
284 do { assemble_name (FILE, NAME1); \
285 fputs (" = ", FILE); \
286 assemble_name (FILE, NAME2); \
287 fputc ('\n', FILE); } while (0)
289 /* Make DWARF2 an option, but keep DBX as the default for now.
290 Use -gdwarf-2 to turn on DWARF2. */
291 #define DWARF2_DEBUGGING_INFO
292 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
294 /* Get the standard ELF stabs definitions. */
295 #include "dbxelf.h"
297 #include "arm/elf.h"
298 #include "arm/linux-gas.h"
300 /* NWFPE always understands FPA instructions. */
301 #undef FP_DEFAULT
302 #define FP_DEFAULT FP_SOFT3
304 /* Call the function profiler with a given profile label. */
305 #undef FUNCTION_PROFILER
306 #define FUNCTION_PROFILER(STREAM, LABELNO) \
308 fprintf (STREAM, "\tbl\tmcount%s\n", NEED_PLT_RELOC ? "(PLT)" : ""); \
311 #undef CC1_SPEC
312 #define CC1_SPEC "%{profile:-p}"