OSDN Git Service

Apply Philip Blundell's patch to fix typos in SUBTARGET_EXTRA_LINK_SPEC
[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_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         { "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         { "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 #define CONST_SECTION_ASM_OP    ".section\t.rodata"
170
171 #define CONST_SECTION_FUNCTION                                          \
172 void                                                                    \
173 const_section ()                                                        \
174 {                                                                       \
175   if (!USE_CONST_SECTION)                                               \
176     text_section ();                                                    \
177   else if (in_section != in_const)                                      \
178     {                                                                   \
179       fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);             \
180       in_section = in_const;                                            \
181     }                                                                   \
182 }
183
184 /* Switch into a generic section.
185    This is currently only used to support section attributes.
186
187    We make the section read-only and executable for a function decl,
188    read-only for a const data decl, and writable for a non-const data decl.  */
189 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
190   fprintf (FILE, ".section\t%s,\"%s\",%%progbits\n", NAME, \
191            (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
192            (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
193
194 /* A C statement or statements to switch to the appropriate
195    section for output of DECL.  DECL is either a `VAR_DECL' node
196    or a constant of some sort.  RELOC indicates whether forming
197    the initial value of DECL requires link-time relocations.  */
198 #define SELECT_SECTION(DECL,RELOC)                                      \
199 {                                                                       \
200   if (TREE_CODE (DECL) == STRING_CST)                                   \
201     {                                                                   \
202       if (! flag_writable_strings)                                      \
203         const_section ();                                               \
204       else                                                              \
205         data_section ();                                                \
206     }                                                                   \
207   else if (TREE_CODE (DECL) == VAR_DECL)                                \
208     {                                                                   \
209       if ((flag_pic && RELOC)                                           \
210           || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)          \
211           || !DECL_INITIAL (DECL)                                       \
212           || (DECL_INITIAL (DECL) != error_mark_node                    \
213               && !TREE_CONSTANT (DECL_INITIAL (DECL))))                 \
214         data_section ();                                                \
215       else                                                              \
216         const_section ();                                               \
217     }                                                                   \
218   else                                                                  \
219     const_section ();                                                   \
220 }
221
222 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
223 #define UNIQUE_SECTION_P(DECL)   (DECL_ONE_ONLY (DECL))
224
225 #define UNIQUE_SECTION(DECL, RELOC)                             \
226   do                                                            \
227     {                                                           \
228       int len;                                                  \
229       char * name;                                              \
230       char * string;                                            \
231       char * prefix;                                            \
232                                                                 \
233       name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));   \
234                                                                 \
235       if (! DECL_ONE_ONLY (DECL))                               \
236         {                                                       \
237           prefix = ".";                                         \
238           if (TREE_CODE (DECL) == FUNCTION_DECL)                \
239             prefix = ".text.";                                  \
240           else if (DECL_READONLY_SECTION (DECL, RELOC))         \
241             prefix = ".rodata.";                                \
242           else                                                  \
243             prefix = ".data.";                                  \
244         }                                                       \
245       else if (TREE_CODE (DECL) == FUNCTION_DECL)               \
246         prefix = ".gnu.linkonce.t.";                            \
247       else if (DECL_READONLY_SECTION (DECL, RELOC))             \
248         prefix = ".gnu.linkonce.r.";                            \
249       else                                                      \
250         prefix = ".gnu.linkonce.d.";                            \
251                                                                 \
252       len = strlen (name) + strlen (prefix);                    \
253       string = alloca (len + 1);                                \
254       sprintf (string, "%s%s", prefix, name);                   \
255                                                                 \
256       DECL_SECTION_NAME (DECL) = build_string (len, string);    \
257     }                                                           \
258   while (0)
259
260 /* A C statement or statements to switch to the appropriate
261    section for output of RTX in mode MODE.  RTX is some kind
262    of constant in RTL.  The argument MODE is redundant except
263    in the case of a `const_int' rtx.  Currently, these always
264    go into the const section.  */
265 #define SELECT_RTX_SECTION(MODE,RTX) const_section ()
266
267 /* On svr4, we *do* have support for the .init and .fini sections, and we
268    can put stuff in there to be executed before and after `main'.  We let
269    crtstuff.c and other files know this by defining the following symbols.
270    The definitions say how to change sections to the .init and .fini
271    sections.  This is the same for all known svr4 assemblers.  */
272 #define INIT_SECTION_ASM_OP     ".section\t.init"
273 #define FINI_SECTION_ASM_OP     ".section\t.fini"
274
275
276 /* This is how we tell the assembler that a symbol is weak.  */
277 #define ASM_WEAKEN_LABEL(FILE,NAME) \
278   do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
279        fputc ('\n', FILE); } while (0)
280
281 /* This is how we tell the assembler that two symbols have the same value.  */
282
283 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
284   do { assemble_name (FILE, NAME1);      \
285        fputs (" = ", FILE);              \
286        assemble_name (FILE, NAME2);      \
287        fputc ('\n', FILE); } while (0)
288
289 /* Make DWARF2 an option, but keep DBX as the default for now.
290    Use -gdwarf-2 to turn on DWARF2.  */
291 #define DWARF2_DEBUGGING_INFO
292 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
293
294 /* Get the standard ELF stabs definitions.  */
295 #include "dbxelf.h"
296
297 #include "arm/elf.h"
298 #include "arm/linux-gas.h"
299
300 /* NWFPE always understands FPA instructions.  */
301 #undef  FP_DEFAULT
302 #define FP_DEFAULT FP_SOFT3
303
304 /* Call the function profiler with a given profile label.  */
305 #undef  FUNCTION_PROFILER
306 #define FUNCTION_PROFILER(STREAM, LABELNO)                              \
307 {                                                                       \
308   fprintf (STREAM, "\tbl\tmcount%s\n", NEED_PLT_RELOC ? "(PLT)" : "");  \
309 }
310
311 #undef  CC1_SPEC
312 #define CC1_SPEC "%{profile:-p}"