Apply patch from Philip Blundel to fix a few ARM/Linux nits.
[gcc.git] / gcc / config / arm / linux-elf.h
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>
4
5 This file is part of GNU CC.
6
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.
11
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.
16
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. */
21
22 /* Run-time Target Specification. */
23 #define TARGET_VERSION fputs (" (ARM GNU/Linux with ELF)", stderr);
24
25 /* We have libgcc2. */
26 #define HAVE_ATEXIT
27
28 /* Default is to use APCS-32 mode. */
29 #ifndef SUBTARGET_DEFAULT_APCS26
30 #define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_SHORT_BYTE)
31 #define SUBTARGET_EXTRA_LINK_SPEC \
32 " %{mapcs-26:-m elf32arm26} %{!mapcs-26:-m elf32arm}"
33 #define SUBTARGET_EXTRA_ASM_SPEC \
34 " %{mapcs-26:-mapcs-26} %(!mapcs-26:-mapcs-32}"
35 #endif
36
37 /* This was defined in linux.h. Define it here also. */
38 #undef DEFAULT_VTABLE_THUNKS
39 #define DEFAULT_VTABLE_THUNKS 1
40
41 /* Handle #pragma weak and #pragma pack. */
42 #define HANDLE_SYSV_PRAGMA
43
44 /* Now we define the strings used to build the spec file. */
45 #define LIB_SPEC \
46 "%{shared: -lc} \
47 %{!shared: %{pthread:-lpthread} \
48 %{profile:-lc_p} %{!profile: -lc}}"
49
50 #define LIBGCC_SPEC "%{msoft-float:-lfloat} -lgcc"
51
52 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
53 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
54 provides part of the support for getting C++ file-scope static
55 object constructed before entering `main'. */
56
57 #define STARTFILE_SPEC \
58 "%{!shared: \
59 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
60 %{!p:%{profile:gcrt1.o%s} \
61 %{!profile:crt1.o%s}}}} \
62 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
63
64 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
65 the GNU/Linux magical crtend.o file (see crtstuff.c) which
66 provides part of the support for getting C++ file-scope static
67 object constructed before entering `main', followed by a normal
68 GNU/Linux "finalizer" file, `crtn.o'. */
69
70 #define ENDFILE_SPEC \
71 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
72
73 #define LINK_SPEC "%{h*} %{version:-v} \
74 %{b} %{Wl,*:%*} \
75 %{static:-Bstatic} \
76 %{shared:-shared} \
77 %{symbolic:-Bsymbolic} \
78 %{rdynamic:-export-dynamic} \
79 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
80 -X \
81 %{mbig-endian:-EB}" \
82 SUBTARGET_EXTRA_LINK_SPEC
83
84 #undef CPP_PREDEFINES
85 #define CPP_PREDEFINES \
86 "-Dunix -Darm -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(arm) \
87 -Amachine(arm) -D__ELF__ -Darm_elf"
88
89 #ifndef SUBTARGET_DEFAULT_APCS26
90 #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
91 #endif
92
93 /* Allow #sccs in preprocessor. */
94 #define SCCS_DIRECTIVE
95
96 #define USER_LABEL_PREFIX "" /* For ELF the default is no underscores */
97 #define LOCAL_LABEL_PREFIX "."
98
99 /* Attach a special .ident directive to the end of the file to identify
100 the version of GCC which compiled this code. */
101 #define IDENT_ASM_OP ".ident"
102
103 /* Output #ident as a .ident. */
104 #define ASM_OUTPUT_IDENT(FILE, NAME) \
105 fprintf (FILE, "\t%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
106
107 #ifdef IDENTIFY_WITH_IDENT
108 #define ASM_IDENTIFY_GCC(FILE) /* nothing */
109 #define ASM_IDENTIFY_LANGUAGE(FILE) \
110 fprintf (FILE, "\t%s \"GCC (%s) %s\"\n", IDENT_ASM_OP, \
111 lang_identify (), version_string)
112 #else
113 #define ASM_FILE_END(FILE) \
114 do { \
115 if (!flag_no_ident) \
116 fprintf ((FILE), "\t%s\t\"GCC: (GNU) %s\"\n", \
117 IDENT_ASM_OP, version_string); \
118 } while (0)
119 #endif
120
121 /* Support const sections and the ctors and dtors sections for g++.
122 Note that there appears to be two different ways to support const
123 sections at the moment. You can either #define the symbol
124 READONLY_DATA_SECTION (giving it some code which switches to the
125 readonly data section) or else you can #define the symbols
126 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
127 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
128 #define USE_CONST_SECTION 1
129
130 /* Support for Constructors and Destructors. */
131 #define READONLY_DATA_SECTION() const_section ()
132
133 /* A default list of other sections which we might be "in" at any given
134 time. For targets that use additional sections (e.g. .tdesc) you
135 should override this definition in the target-specific file which
136 includes this file. */
137 #define SUBTARGET_EXTRA_SECTIONS in_const,
138
139 /* A default list of extra section function definitions. For targets
140 that use additional sections (e.g. .tdesc) you should override this
141 definition in the target-specific file which includes this file. */
142 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS CONST_SECTION_FUNCTION
143
144 extern void text_section ();
145
146 #define CONST_SECTION_ASM_OP ".section\t.rodata"
147
148 #define CONST_SECTION_FUNCTION \
149 void \
150 const_section () \
151 { \
152 if (!USE_CONST_SECTION) \
153 text_section (); \
154 else if (in_section != in_const) \
155 { \
156 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
157 in_section = in_const; \
158 } \
159 }
160
161 /* Switch into a generic section.
162 This is currently only used to support section attributes.
163
164 We make the section read-only and executable for a function decl,
165 read-only for a const data decl, and writable for a non-const data decl. */
166 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
167 fprintf (FILE, ".section\t%s,\"%s\",%%progbits\n", NAME, \
168 (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
169 (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
170
171 /* A C statement or statements to switch to the appropriate
172 section for output of DECL. DECL is either a `VAR_DECL' node
173 or a constant of some sort. RELOC indicates whether forming
174 the initial value of DECL requires link-time relocations. */
175 #define SELECT_SECTION(DECL,RELOC) \
176 { \
177 if (TREE_CODE (DECL) == STRING_CST) \
178 { \
179 if (! flag_writable_strings) \
180 const_section (); \
181 else \
182 data_section (); \
183 } \
184 else if (TREE_CODE (DECL) == VAR_DECL) \
185 { \
186 if ((flag_pic && RELOC) \
187 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
188 || !DECL_INITIAL (DECL) \
189 || (DECL_INITIAL (DECL) != error_mark_node \
190 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
191 data_section (); \
192 else \
193 const_section (); \
194 } \
195 else \
196 const_section (); \
197 }
198
199 /* A C statement or statements to switch to the appropriate
200 section for output of RTX in mode MODE. RTX is some kind
201 of constant in RTL. The argument MODE is redundant except
202 in the case of a `const_int' rtx. Currently, these always
203 go into the const section. */
204 #define SELECT_RTX_SECTION(MODE,RTX) const_section ()
205
206 /* On svr4, we *do* have support for the .init and .fini sections, and we
207 can put stuff in there to be executed before and after `main'. We let
208 crtstuff.c and other files know this by defining the following symbols.
209 The definitions say how to change sections to the .init and .fini
210 sections. This is the same for all known svr4 assemblers. */
211 #define INIT_SECTION_ASM_OP ".section\t.init"
212 #define FINI_SECTION_ASM_OP ".section\t.fini"
213
214
215 /* This is how we tell the assembler that a symbol is weak. */
216 #define ASM_WEAKEN_LABEL(FILE,NAME) \
217 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
218 fputc ('\n', FILE); } while (0)
219
220 /* This is how we tell the assembler that two symbols have the same value. */
221
222 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
223 do { assemble_name (FILE, NAME1); \
224 fputs (" = ", FILE); \
225 assemble_name (FILE, NAME2); \
226 fputc ('\n', FILE); } while (0)
227
228 /* Make DWARF2 an option, but keep DBX as the default for now.
229 Use -gdwarf-2 to turn on DWARF2. */
230 #define DWARF2_DEBUGGING_INFO
231 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
232
233 /* Get the standard ELF stabs definitions. */
234 #include "dbxelf.h"
235
236 #include "arm/elf.h"
237 #include "arm/linux-gas.h"
238
239 #ifndef SUBTARGET_DEFAULT_APCS26
240 /* On 32-bit machine it is always safe to assume we have the "new"
241 floating point system.
242 ?? Make this happen for all targets when NWFPE is better established. */
243 #undef FP_DEFAULT
244 #define FP_DEFAULT FP_SOFT3
245 #endif