OSDN Git Service

Skip -mthumb as well as -mthumb-interwork when -mcpu=arm7 is specified.
[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, 2001 
3    Free Software Foundation, Inc.
4    Contributed by Philip Blundell <philb@gnu.org>
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23 /* Run-time Target Specification.  */
24 #define TARGET_VERSION  fputs (" (ARM GNU/Linux with ELF)", stderr);
25
26 /* Do not assume anything about header files.  */
27 #define NO_IMPLICIT_EXTERN_C
28
29 /* Default is to use APCS-32 mode.  */
30 #define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_MMU_TRAPS)
31 #define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
32 #define MULTILIB_DEFAULTS \
33         { "marm", "mlittle-endian", "mhard-float", "mapcs-32", "mno-thumb-interwork" }
34 #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
35
36 /* Handle #pragma weak and #pragma pack.  */
37 #define HANDLE_SYSV_PRAGMA
38
39 /* Now we define the strings used to build the spec file.  */
40 #define LIB_SPEC \
41   "%{shared: -lc} \
42    %{!shared: %{pthread:-lpthread} \
43    %{profile:-lc_p} %{!profile: -lc}}"
44
45
46 #define LIBGCC_SPEC "%{msoft-float:-lfloat} -lgcc"
47
48 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux.  Here we add
49    the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
50    provides part of the support for getting C++ file-scope static
51    object constructed before entering `main'. */
52    
53 #define STARTFILE_SPEC \
54   "%{!shared: \
55      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
56                        %{!p:%{profile:gcrt1.o%s} \
57                          %{!profile:crt1.o%s}}}} \
58    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
59
60 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
61    the GNU/Linux magical crtend.o file (see crtstuff.c) which
62    provides part of the support for getting C++ file-scope static
63    object constructed before entering `main', followed by a normal
64    GNU/Linux "finalizer" file, `crtn.o'.  */
65
66 #define ENDFILE_SPEC \
67   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
68
69 #define LINK_SPEC "%{h*} %{version:-v} \
70    %{b} %{Wl,*:%*} \
71    %{static:-Bstatic} \
72    %{shared:-shared} \
73    %{symbolic:-Bsymbolic} \
74    %{rdynamic:-export-dynamic} \
75    %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
76    -X \
77    %{mbig-endian:-EB}" \
78    SUBTARGET_EXTRA_LINK_SPEC
79
80 #undef  CPP_PREDEFINES
81 #define CPP_PREDEFINES \
82 "-Dunix -Dlinux -D__ELF__ \
83 -Asystem=unix -Asystem=posix -Acpu=arm -Amachine=arm"
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 #define IDENT_ASM_OP    "\t.ident\t"
92
93 /* Output #ident as a .ident.  */
94 #define ASM_OUTPUT_IDENT(FILE, NAME) \
95   fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
96
97 /* Support const sections and the ctors and dtors sections for g++.
98    Note that there appears to be two different ways to support const
99    sections at the moment.  You can either #define the symbol
100    READONLY_DATA_SECTION (giving it some code which switches to the
101    readonly data section) or else you can #define the symbols
102    EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
103    SELECT_RTX_SECTION.  We do both here just to be on the safe side.  */
104 #define USE_CONST_SECTION       1
105
106 /* Support for Constructors and Destructors.  */
107 #define READONLY_DATA_SECTION() const_section ()
108
109 /* A default list of other sections which we might be "in" at any given
110    time.  For targets that use additional sections (e.g. .tdesc) you
111    should override this definition in the target-specific file which
112    includes this file.  */
113 #define SUBTARGET_EXTRA_SECTIONS in_const,
114
115 /* A default list of extra section function definitions.  For targets
116    that use additional sections (e.g. .tdesc) you should override this
117    definition in the target-specific file which includes this file.  */
118 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS       CONST_SECTION_FUNCTION
119
120 #define CONST_SECTION_ASM_OP    "\t.section\t.rodata"
121
122 #define CONST_SECTION_FUNCTION                                          \
123 void                                                                    \
124 const_section ()                                                        \
125 {                                                                       \
126   if (!USE_CONST_SECTION)                                               \
127     text_section ();                                                    \
128   else if (in_section != in_const)                                      \
129     {                                                                   \
130       fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);             \
131       in_section = in_const;                                            \
132     }                                                                   \
133 }
134
135 /* Switch into a generic section.
136    This is currently only used to support section attributes.
137
138    We make the section read-only and executable for a function decl,
139    read-only for a const data decl, and writable for a non-const data decl.  */
140 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
141   fprintf (FILE, ".section\t%s,\"%s\",%%progbits\n", NAME, \
142            (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
143            (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
144
145 /* A C statement or statements to switch to the appropriate
146    section for output of DECL.  DECL is either a `VAR_DECL' node
147    or a constant of some sort.  RELOC indicates whether forming
148    the initial value of DECL requires link-time relocations.  */
149 #define SELECT_SECTION(DECL,RELOC)                                      \
150 {                                                                       \
151   if (TREE_CODE (DECL) == STRING_CST)                                   \
152     {                                                                   \
153       if (! flag_writable_strings)                                      \
154         const_section ();                                               \
155       else                                                              \
156         data_section ();                                                \
157     }                                                                   \
158   else if (TREE_CODE (DECL) == VAR_DECL)                                \
159     {                                                                   \
160       if ((flag_pic && RELOC)                                           \
161           || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)          \
162           || !DECL_INITIAL (DECL)                                       \
163           || (DECL_INITIAL (DECL) != error_mark_node                    \
164               && !TREE_CONSTANT (DECL_INITIAL (DECL))))                 \
165         data_section ();                                                \
166       else                                                              \
167         const_section ();                                               \
168     }                                                                   \
169   else                                                                  \
170     const_section ();                                                   \
171 }
172
173 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
174 #define UNIQUE_SECTION_P(DECL)   (DECL_ONE_ONLY (DECL))
175
176 #define UNIQUE_SECTION(DECL, RELOC)                             \
177   do                                                            \
178     {                                                           \
179       int len;                                                  \
180       char * name;                                              \
181       char * string;                                            \
182       char * prefix;                                            \
183                                                                 \
184       name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));   \
185                                                                 \
186       if (! DECL_ONE_ONLY (DECL))                               \
187         {                                                       \
188           prefix = ".";                                         \
189           if (TREE_CODE (DECL) == FUNCTION_DECL)                \
190             prefix = ".text.";                                  \
191           else if (DECL_READONLY_SECTION (DECL, RELOC))         \
192             prefix = ".rodata.";                                \
193           else                                                  \
194             prefix = ".data.";                                  \
195         }                                                       \
196       else if (TREE_CODE (DECL) == FUNCTION_DECL)               \
197         prefix = ".gnu.linkonce.t.";                            \
198       else if (DECL_READONLY_SECTION (DECL, RELOC))             \
199         prefix = ".gnu.linkonce.r.";                            \
200       else                                                      \
201         prefix = ".gnu.linkonce.d.";                            \
202                                                                 \
203       len = strlen (name) + strlen (prefix);                    \
204       string = alloca (len + 1);                                \
205       sprintf (string, "%s%s", prefix, name);                   \
206                                                                 \
207       DECL_SECTION_NAME (DECL) = build_string (len, string);    \
208     }                                                           \
209   while (0)
210
211 /* A C statement or statements to switch to the appropriate
212    section for output of RTX in mode MODE.  RTX is some kind
213    of constant in RTL.  The argument MODE is redundant except
214    in the case of a `const_int' rtx.  Currently, these always
215    go into the const section.  */
216 #define SELECT_RTX_SECTION(MODE,RTX) const_section ()
217
218 /* On svr4, we *do* have support for the .init and .fini sections, and we
219    can put stuff in there to be executed before and after `main'.  We let
220    crtstuff.c and other files know this by defining the following symbols.
221    The definitions say how to change sections to the .init and .fini
222    sections.  This is the same for all known svr4 assemblers.  */
223 #define INIT_SECTION_ASM_OP     "\t.section\t.init"
224 #define FINI_SECTION_ASM_OP     "\t.section\t.fini"
225
226
227 /* This is how we tell the assembler that a symbol is weak.  */
228 #define ASM_WEAKEN_LABEL(FILE,NAME) \
229   do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
230        fputc ('\n', FILE); } while (0)
231
232 /* This is how we tell the assembler that two symbols have the same value.  */
233
234 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
235   do { assemble_name (FILE, NAME1);      \
236        fputs (" = ", FILE);              \
237        assemble_name (FILE, NAME2);      \
238        fputc ('\n', FILE); } while (0)
239
240 /* Make DWARF2 an option, but keep DBX as the default for now.
241    Use -gdwarf-2 to turn on DWARF2.  */
242 #define DWARF2_DEBUGGING_INFO
243 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
244
245 /* Get the standard ELF stabs definitions.  */
246 #include "dbxelf.h"
247
248 #include "arm/elf.h"
249 #include "arm/linux-gas.h"
250
251 /* NWFPE always understands FPA instructions.  */
252 #undef  FP_DEFAULT
253 #define FP_DEFAULT FP_SOFT3
254
255 /* Call the function profiler with a given profile label.  */
256 #undef  ARM_FUNCTION_PROFILER
257 #define ARM_FUNCTION_PROFILER(STREAM, LABELNO)                          \
258 {                                                                       \
259   fprintf (STREAM, "\tbl\tmcount%s\n", NEED_PLT_RELOC ? "(PLT)" : "");  \
260 }
261
262 #undef  CC1_SPEC
263 #define CC1_SPEC "%{profile:-p}"