OSDN Git Service

* gbl-ctors.h: Lose HAVE_ATEXIT. Don't define ON_EXIT.
[pf3gnuchains/gcc-fork.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 /* Do not assume anything about header files.  */
26 #define NO_IMPLICIT_EXTERN_C
27
28 #ifndef SUBTARGET_DEFAULT_APCS26
29 /* Default is to use APCS-32 mode.  */
30 # define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_SHORT_BYTE)
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_SHORT_BYTE)
45 # ifdef SUBTARGET_OLD_LINKER
46 #  define SUBTARGET_LINK_SPEC   \
47         " %{mapcs-32:-m elf32arm} %{!mapcs-32:-m elf32arm26}"
48 # else  /* new linker */
49 #  define SUBTARGET_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
57
58 /* This was defined in linux.h.  Define it here also. */
59 #undef  DEFAULT_VTABLE_THUNKS
60 #define DEFAULT_VTABLE_THUNKS   1
61
62 /* Handle #pragma weak and #pragma pack.  */
63 #define HANDLE_SYSV_PRAGMA
64
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}}"
70
71
72 #define LIBGCC_SPEC "%{msoft-float:-lfloat} -lgcc"
73
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'. */
78    
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}"
85
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'.  */
91
92 #define ENDFILE_SPEC \
93   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
94
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
105
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
112
113 #undef  CPP_PREDEFINES
114 #define CPP_PREDEFINES \
115 "-Dunix -D__arm__ -Dlinux -D__ELF__ \
116 -Asystem(unix) -Asystem(posix) -Acpu(arm) -Amachine(arm)"
117
118 /* Allow #sccs in preprocessor.  */
119 #define SCCS_DIRECTIVE
120
121 #define USER_LABEL_PREFIX       ""      /* For ELF the default is no underscores */
122 #define LOCAL_LABEL_PREFIX      "."
123
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"
127
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);
131   
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
145
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
154
155 /* Support for Constructors and Destructors.  */
156 #define READONLY_DATA_SECTION() const_section ()
157
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,
163
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
168
169 extern void text_section ();
170
171 #define CONST_SECTION_ASM_OP    ".section\t.rodata"
172
173 #define CONST_SECTION_FUNCTION                                          \
174 void                                                                    \
175 const_section ()                                                        \
176 {                                                                       \
177   if (!USE_CONST_SECTION)                                               \
178     text_section ();                                                    \
179   else if (in_section != in_const)                                      \
180     {                                                                   \
181       fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);             \
182       in_section = in_const;                                            \
183     }                                                                   \
184 }
185
186 /* Switch into a generic section.
187    This is currently only used to support section attributes.
188
189    We make the section read-only and executable for a function decl,
190    read-only for a const data decl, and writable for a non-const data decl.  */
191 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
192   fprintf (FILE, ".section\t%s,\"%s\",%%progbits\n", NAME, \
193            (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
194            (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
195
196 /* A C statement or statements to switch to the appropriate
197    section for output of DECL.  DECL is either a `VAR_DECL' node
198    or a constant of some sort.  RELOC indicates whether forming
199    the initial value of DECL requires link-time relocations.  */
200 #define SELECT_SECTION(DECL,RELOC)                                      \
201 {                                                                       \
202   if (TREE_CODE (DECL) == STRING_CST)                                   \
203     {                                                                   \
204       if (! flag_writable_strings)                                      \
205         const_section ();                                               \
206       else                                                              \
207         data_section ();                                                \
208     }                                                                   \
209   else if (TREE_CODE (DECL) == VAR_DECL)                                \
210     {                                                                   \
211       if ((flag_pic && RELOC)                                           \
212           || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)          \
213           || !DECL_INITIAL (DECL)                                       \
214           || (DECL_INITIAL (DECL) != error_mark_node                    \
215               && !TREE_CONSTANT (DECL_INITIAL (DECL))))                 \
216         data_section ();                                                \
217       else                                                              \
218         const_section ();                                               \
219     }                                                                   \
220   else                                                                  \
221     const_section ();                                                   \
222 }
223
224 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
225 #define UNIQUE_SECTION_P(DECL)   (DECL_ONE_ONLY (DECL))
226
227 #define UNIQUE_SECTION(DECL, RELOC)                             \
228   do                                                            \
229     {                                                           \
230       int len;                                                  \
231       char * name;                                              \
232       char * string;                                            \
233       char * prefix;                                            \
234                                                                 \
235       name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));   \
236                                                                 \
237       if (! DECL_ONE_ONLY (DECL))                               \
238         {                                                       \
239           prefix = ".";                                         \
240           if (TREE_CODE (DECL) == FUNCTION_DECL)                \
241             prefix = ".text.";                                  \
242           else if (DECL_READONLY_SECTION (DECL, RELOC))         \
243             prefix = ".rodata.";                                \
244           else                                                  \
245             prefix = ".data.";                                  \
246         }                                                       \
247       else if (TREE_CODE (DECL) == FUNCTION_DECL)               \
248         prefix = ".gnu.linkonce.t.";                            \
249       else if (DECL_READONLY_SECTION (DECL, RELOC))             \
250         prefix = ".gnu.linkonce.r.";                            \
251       else                                                      \
252         prefix = ".gnu.linkonce.d.";                            \
253                                                                 \
254       len = strlen (name) + strlen (prefix);                    \
255       string = alloca (len + 1);                                \
256       sprintf (string, "%s%s", prefix, name);                   \
257                                                                 \
258       DECL_SECTION_NAME (DECL) = build_string (len, string);    \
259     }                                                           \
260   while (0)
261
262 /* A C statement or statements to switch to the appropriate
263    section for output of RTX in mode MODE.  RTX is some kind
264    of constant in RTL.  The argument MODE is redundant except
265    in the case of a `const_int' rtx.  Currently, these always
266    go into the const section.  */
267 #define SELECT_RTX_SECTION(MODE,RTX) const_section ()
268
269 /* On svr4, we *do* have support for the .init and .fini sections, and we
270    can put stuff in there to be executed before and after `main'.  We let
271    crtstuff.c and other files know this by defining the following symbols.
272    The definitions say how to change sections to the .init and .fini
273    sections.  This is the same for all known svr4 assemblers.  */
274 #define INIT_SECTION_ASM_OP     ".section\t.init"
275 #define FINI_SECTION_ASM_OP     ".section\t.fini"
276
277
278 /* This is how we tell the assembler that a symbol is weak.  */
279 #define ASM_WEAKEN_LABEL(FILE,NAME) \
280   do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
281        fputc ('\n', FILE); } while (0)
282
283 /* This is how we tell the assembler that two symbols have the same value.  */
284
285 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
286   do { assemble_name (FILE, NAME1);      \
287        fputs (" = ", FILE);              \
288        assemble_name (FILE, NAME2);      \
289        fputc ('\n', FILE); } while (0)
290
291 /* Make DWARF2 an option, but keep DBX as the default for now.
292    Use -gdwarf-2 to turn on DWARF2.  */
293 #define DWARF2_DEBUGGING_INFO
294 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
295
296 /* Get the standard ELF stabs definitions.  */
297 #include "dbxelf.h"
298
299 #include "arm/elf.h"
300 #include "arm/linux-gas.h"
301
302 /* NWFPE always understands FPA instructions.  */
303 #undef  FP_DEFAULT
304 #define FP_DEFAULT FP_SOFT3
305
306 /* Call the function profiler with a given profile label.  */
307 #undef  FUNCTION_PROFILER
308 #define FUNCTION_PROFILER(STREAM, LABELNO)                              \
309 {                                                                       \
310   fprintf (STREAM, "\tbl\tmcount%s\n", NEED_PLT_RELOC ? "(PLT)" : "");  \
311 }
312
313 #undef  CC1_SPEC
314 #define CC1_SPEC "%{profile:-p}"