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)
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 /* We have libgcc2. */
31 #ifndef SUBTARGET_DEFAULT_APCS26
32 /* Default is to use APCS-32 mode. */
33 # define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_SHORT_BYTE)
34 # ifdef SUBTARGET_OLD_LINKER
35 # define SUBTARGET_EXTRA_LINK_SPEC \
36 " %{mapcs-26:-m elf32arm26} %{!mapcs-26:-m elf32arm}"
37 # else /* new linker */
38 # define SUBTARGET_EXTRA_LINK_SPEC \
39 " %{mapcs-26:-m armelf_linux26} %{!mapcs-26:-m armelf_linux} -p"
41 # define SUBTARGET_EXTRA_ASM_SPEC \
42 " %{mapcs-26:-mapcs-26} %(!mapcs-26:-mapcs-32}"
43 # define MULTILIB_DEFAULTS \
44 { "mlittle-endian", "mhard-float", "mapcs-32", "mno-thumb-interwork" }
45 # define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
46 #else /* default is APCS-26 */
47 # define TARGET_DEFAULT (ARM_FLAG_SHORT_BYTE)
48 # ifdef SUBTARGET_OLD_LINKER
49 # define SUBTARGET_LINK_SPEC \
50 " %{mapcs-32:-m elf32arm} %{!mapcs-32:-m elf32arm26}"
51 # else /* new linker */
52 # define SUBTARGET_LINK_SPEC \
53 " %{mapcs-32:-m armelf_linux} %{!mapcs-32:-m armelf_linux26} -p"
55 # define SUBTARGET_EXTRA_ASM_SPEC \
56 " %{mapcs-32:-mapcs-32} %(!mapcs-32:-mapcs-26}"
57 # define MULTILIB_DEFAULTS \
58 { "mlittle-endian", "mhard-float", "mapcs-26", "mno-thumb-interwork" }
61 /* This was defined in linux.h. Define it here also. */
62 #undef DEFAULT_VTABLE_THUNKS
63 #define DEFAULT_VTABLE_THUNKS 1
65 /* Handle #pragma weak and #pragma pack. */
66 #define HANDLE_SYSV_PRAGMA
68 /* Now we define the strings used to build the spec file. */
71 %{!shared: %{pthread:-lpthread} \
72 %{profile:-lc_p} %{!profile: -lc}}"
75 #define LIBGCC_SPEC "%{msoft-float:-lfloat} -lgcc"
77 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
78 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
79 provides part of the support for getting C++ file-scope static
80 object constructed before entering `main'. */
82 #define STARTFILE_SPEC \
84 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
85 %{!p:%{profile:gcrt1.o%s} \
86 %{!profile:crt1.o%s}}}} \
87 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
89 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
90 the GNU/Linux magical crtend.o file (see crtstuff.c) which
91 provides part of the support for getting C++ file-scope static
92 object constructed before entering `main', followed by a normal
93 GNU/Linux "finalizer" file, `crtn.o'. */
95 #define ENDFILE_SPEC \
96 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
98 #define LINK_SPEC "%{h*} %{version:-v} \
102 %{symbolic:-Bsymbolic} \
103 %{rdynamic:-export-dynamic} \
104 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
106 %{mbig-endian:-EB}" \
107 SUBTARGET_EXTRA_LINK_SPEC
109 #define ASM_SPEC "%{mbig-endian:-EB} \
110 %{mcpu=*:-m%*} %{march=*:-m%*} \
111 %{mthumb-interwork:-mthumb-interwork} \
112 %{msoft-float:-mno-fpu} \
113 %{mapcs-float:-mfloat}" \
114 SUBTARGET_EXTRA_ASM_SPEC
116 #undef CPP_PREDEFINES
117 #define CPP_PREDEFINES \
118 "-Dunix -D__arm__ -Dlinux -D__ELF__ \
119 -Asystem(unix) -Asystem(posix) -Acpu(arm) -Amachine(arm)"
121 /* Allow #sccs in preprocessor. */
122 #define SCCS_DIRECTIVE
124 #define USER_LABEL_PREFIX "" /* For ELF the default is no underscores */
125 #define LOCAL_LABEL_PREFIX "."
127 /* Attach a special .ident directive to the end of the file to identify
128 the version of GCC which compiled this code. */
129 #define IDENT_ASM_OP ".ident"
131 /* Output #ident as a .ident. */
132 #define ASM_OUTPUT_IDENT(FILE, NAME) \
133 fprintf (FILE, "\t%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
135 #ifdef IDENTIFY_WITH_IDENT
136 #define ASM_IDENTIFY_GCC(FILE) /* nothing */
137 #define ASM_IDENTIFY_LANGUAGE(FILE) \
138 fprintf (FILE, "\t%s \"GCC (%s) %s\"\n", IDENT_ASM_OP, \
139 lang_identify (), version_string)
141 #define ASM_FILE_END(FILE) \
143 if (!flag_no_ident) \
144 fprintf ((FILE), "\t%s\t\"GCC: (GNU) %s\"\n", \
145 IDENT_ASM_OP, version_string); \
149 /* Support const sections and the ctors and dtors sections for g++.
150 Note that there appears to be two different ways to support const
151 sections at the moment. You can either #define the symbol
152 READONLY_DATA_SECTION (giving it some code which switches to the
153 readonly data section) or else you can #define the symbols
154 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
155 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
156 #define USE_CONST_SECTION 1
158 /* Support for Constructors and Destructors. */
159 #define READONLY_DATA_SECTION() const_section ()
161 /* A default list of other sections which we might be "in" at any given
162 time. For targets that use additional sections (e.g. .tdesc) you
163 should override this definition in the target-specific file which
164 includes this file. */
165 #define SUBTARGET_EXTRA_SECTIONS in_const,
167 /* A default list of extra section function definitions. For targets
168 that use additional sections (e.g. .tdesc) you should override this
169 definition in the target-specific file which includes this file. */
170 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS CONST_SECTION_FUNCTION
172 extern void text_section ();
174 #define CONST_SECTION_ASM_OP ".section\t.rodata"
176 #define CONST_SECTION_FUNCTION \
180 if (!USE_CONST_SECTION) \
182 else if (in_section != in_const) \
184 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
185 in_section = in_const; \
189 /* Switch into a generic section.
190 This is currently only used to support section attributes.
192 We make the section read-only and executable for a function decl,
193 read-only for a const data decl, and writable for a non-const data decl. */
194 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
195 fprintf (FILE, ".section\t%s,\"%s\",%%progbits\n", NAME, \
196 (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
197 (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
199 /* A C statement or statements to switch to the appropriate
200 section for output of DECL. DECL is either a `VAR_DECL' node
201 or a constant of some sort. RELOC indicates whether forming
202 the initial value of DECL requires link-time relocations. */
203 #define SELECT_SECTION(DECL,RELOC) \
205 if (TREE_CODE (DECL) == STRING_CST) \
207 if (! flag_writable_strings) \
212 else if (TREE_CODE (DECL) == VAR_DECL) \
214 if ((flag_pic && RELOC) \
215 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
216 || !DECL_INITIAL (DECL) \
217 || (DECL_INITIAL (DECL) != error_mark_node \
218 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
227 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
228 #define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
230 #define UNIQUE_SECTION(DECL, RELOC) \
238 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
240 if (! DECL_ONE_ONLY (DECL)) \
243 if (TREE_CODE (DECL) == FUNCTION_DECL) \
245 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
246 prefix = ".rodata."; \
250 else if (TREE_CODE (DECL) == FUNCTION_DECL) \
251 prefix = ".gnu.linkonce.t."; \
252 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
253 prefix = ".gnu.linkonce.r."; \
255 prefix = ".gnu.linkonce.d."; \
257 len = strlen (name) + strlen (prefix); \
258 string = alloca (len + 1); \
259 sprintf (string, "%s%s", prefix, name); \
261 DECL_SECTION_NAME (DECL) = build_string (len, string); \
265 /* A C statement or statements to switch to the appropriate
266 section for output of RTX in mode MODE. RTX is some kind
267 of constant in RTL. The argument MODE is redundant except
268 in the case of a `const_int' rtx. Currently, these always
269 go into the const section. */
270 #define SELECT_RTX_SECTION(MODE,RTX) const_section ()
272 /* On svr4, we *do* have support for the .init and .fini sections, and we
273 can put stuff in there to be executed before and after `main'. We let
274 crtstuff.c and other files know this by defining the following symbols.
275 The definitions say how to change sections to the .init and .fini
276 sections. This is the same for all known svr4 assemblers. */
277 #define INIT_SECTION_ASM_OP ".section\t.init"
278 #define FINI_SECTION_ASM_OP ".section\t.fini"
281 /* This is how we tell the assembler that a symbol is weak. */
282 #define ASM_WEAKEN_LABEL(FILE,NAME) \
283 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
284 fputc ('\n', FILE); } while (0)
286 /* This is how we tell the assembler that two symbols have the same value. */
288 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
289 do { assemble_name (FILE, NAME1); \
290 fputs (" = ", FILE); \
291 assemble_name (FILE, NAME2); \
292 fputc ('\n', FILE); } while (0)
294 /* Make DWARF2 an option, but keep DBX as the default for now.
295 Use -gdwarf-2 to turn on DWARF2. */
296 #define DWARF2_DEBUGGING_INFO
297 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
299 /* Get the standard ELF stabs definitions. */
303 #include "arm/linux-gas.h"
305 /* NWFPE always understands FPA instructions. */
307 #define FP_DEFAULT FP_SOFT3
309 /* Call the function profiler with a given profile label. */
310 #undef FUNCTION_PROFILER
311 #define FUNCTION_PROFILER(STREAM, LABELNO) \
313 fprintf (STREAM, "\tbl\tmcount%s\n", NEED_PLT_RELOC ? "(PLT)" : ""); \
317 #define CC1_SPEC "%{profile:-p}"