OSDN Git Service

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