Apply ARM/Linux patches.
[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 /* Add the compiler's crtend, and the library's crtn. */
53 #define ENDFILE_SPEC "%{!shared:crtend.o%s} %{shared:crtendS.o%s} \
54 %{pg:gcrtn.o%s}%{!pg:crtn.o%s}"
55
56 #define STARTFILE_SPEC "%{!shared:crt1.o%s} \
57 crti.o%s \
58 %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
59
60 #define LINK_SPEC "%{h*} %{version:-v} \
61 %{b} %{Wl,*:%*} \
62 %{static:-Bstatic} \
63 %{shared:-shared} \
64 %{symbolic:-Bsymbolic} \
65 %{rdynamic:-export-dynamic} \
66 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
67 -X \
68 %{mbig-endian:-EB}" \
69 SUBTARGET_EXTRA_LINK_SPEC
70
71 #undef CPP_PREDEFINES
72 #define CPP_PREDEFINES \
73 "-Dunix -Darm -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(arm) \
74 -Amachine(arm) -D__ELF__ -Darm_elf"
75
76 #ifndef SUBTARGET_DEFAULT_APCS26
77 #undef CPP_APCS_PC_DEFAULT_SPEC
78 #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
79 /* On 32-bit machine it is always safe to assume we have the "new"
80 floating point system. */
81 #undef FP_DEFAULT
82 #define FP_DEFAULT FP_SOFT3
83 #endif
84
85 /* Allow #sccs in preprocessor. */
86 #define SCCS_DIRECTIVE
87
88 #define USER_LABEL_PREFIX "" /* For ELF the default is no underscores */
89 #define LOCAL_LABEL_PREFIX "."
90
91 /* Attach a special .ident directive to the end of the file to identify
92 the version of GCC which compiled this code. */
93 #define IDENT_ASM_OP ".ident"
94
95 /* Output #ident as a .ident. */
96 #define ASM_OUTPUT_IDENT(FILE, NAME) \
97 fprintf (FILE, "\t%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
98
99 #ifdef IDENTIFY_WITH_IDENT
100 #define ASM_IDENTIFY_GCC(FILE) /* nothing */
101 #define ASM_IDENTIFY_LANGUAGE(FILE) \
102 fprintf (FILE, "\t%s \"GCC (%s) %s\"\n", IDENT_ASM_OP, \
103 lang_identify (), version_string)
104 #else
105 #define ASM_FILE_END(FILE) \
106 do { \
107 if (!flag_no_ident) \
108 fprintf ((FILE), "\t%s\t\"GCC: (GNU) %s\"\n", \
109 IDENT_ASM_OP, version_string); \
110 } while (0)
111 #endif
112
113 /* Support const sections and the ctors and dtors sections for g++.
114 Note that there appears to be two different ways to support const
115 sections at the moment. You can either #define the symbol
116 READONLY_DATA_SECTION (giving it some code which switches to the
117 readonly data section) or else you can #define the symbols
118 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
119 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
120 #define USE_CONST_SECTION 1
121
122 /* Support for Constructors and Destructors. */
123 #define READONLY_DATA_SECTION() const_section ()
124
125 /* A default list of other sections which we might be "in" at any given
126 time. For targets that use additional sections (e.g. .tdesc) you
127 should override this definition in the target-specific file which
128 includes this file. */
129 #define SUBTARGET_EXTRA_SECTIONS in_const,
130
131 /* A default list of extra section function definitions. For targets
132 that use additional sections (e.g. .tdesc) you should override this
133 definition in the target-specific file which includes this file. */
134 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS CONST_SECTION_FUNCTION
135
136 extern void text_section ();
137
138 #define CONST_SECTION_ASM_OP ".section\t.rodata"
139
140 #define CONST_SECTION_FUNCTION \
141 void \
142 const_section () \
143 { \
144 if (!USE_CONST_SECTION) \
145 text_section (); \
146 else if (in_section != in_const) \
147 { \
148 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
149 in_section = in_const; \
150 } \
151 }
152
153 /* Switch into a generic section.
154 This is currently only used to support section attributes.
155
156 We make the section read-only and executable for a function decl,
157 read-only for a const data decl, and writable for a non-const data decl. */
158 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
159 fprintf (FILE, ".section\t%s,\"%s\",%%progbits\n", NAME, \
160 (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
161 (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
162
163 /* A C statement or statements to switch to the appropriate
164 section for output of DECL. DECL is either a `VAR_DECL' node
165 or a constant of some sort. RELOC indicates whether forming
166 the initial value of DECL requires link-time relocations. */
167 #define SELECT_SECTION(DECL,RELOC) \
168 { \
169 if (TREE_CODE (DECL) == STRING_CST) \
170 { \
171 if (! flag_writable_strings) \
172 const_section (); \
173 else \
174 data_section (); \
175 } \
176 else if (TREE_CODE (DECL) == VAR_DECL) \
177 { \
178 if ((flag_pic && RELOC) \
179 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
180 || !DECL_INITIAL (DECL) \
181 || (DECL_INITIAL (DECL) != error_mark_node \
182 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
183 data_section (); \
184 else \
185 const_section (); \
186 } \
187 else \
188 const_section (); \
189 }
190
191 /* A C statement or statements to switch to the appropriate
192 section for output of RTX in mode MODE. RTX is some kind
193 of constant in RTL. The argument MODE is redundant except
194 in the case of a `const_int' rtx. Currently, these always
195 go into the const section. */
196 #define SELECT_RTX_SECTION(MODE,RTX) const_section ()
197
198 /* On svr4, we *do* have support for the .init and .fini sections, and we
199 can put stuff in there to be executed before and after `main'. We let
200 crtstuff.c and other files know this by defining the following symbols.
201 The definitions say how to change sections to the .init and .fini
202 sections. This is the same for all known svr4 assemblers. */
203 #define INIT_SECTION_ASM_OP ".section\t.init"
204 #define FINI_SECTION_ASM_OP ".section\t.fini"
205
206
207 /* This is how we tell the assembler that a symbol is weak. */
208 #define ASM_WEAKEN_LABEL(FILE,NAME) \
209 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
210 fputc ('\n', FILE); } while (0)
211
212 /* This is how we tell the assembler that two symbols have the same value. */
213
214 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
215 do { assemble_name (FILE, NAME1); \
216 fputs (" = ", FILE); \
217 assemble_name (FILE, NAME2); \
218 fputc ('\n', FILE); } while (0)
219
220 /* Make DWARF2 an option, but keep DBX as the default for now.
221 Use -gdwarf2 to turn on DWARF2. */
222 #define DWARF2_DEBUGGING_INFO
223 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
224
225 #include "arm/elf.h"
226 #include "arm/linux-gas.h"