Initial revision
[gcc.git] / gcc / config / sparc / linux.h
1 /* Definitions for SPARC running Linux with ELF
2 Copyright (C) 1996 Free Software Foundation, Inc.
3 Contributed by Eddie C. Dost (ecd@skynet.be)
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 GNU CC; 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 #define LINUX_DEFAULT_ELF
23
24 /* Don't assume anything about the header files. */
25 #define NO_IMPLICIT_EXTERN_C
26
27 #undef HAVE_ATEXIT
28 #define HAVE_ATEXIT
29
30 /* Linux uses ctype from glibc.a. I am not sure how complete it is.
31 For now, we play safe. It may change later. */
32
33 #if 0
34 #undef MULTIBYTE_CHARS
35 #define MULTIBYTE_CHARS 1
36 #endif
37
38 /* There are conflicting reports about whether this system uses
39 a different assembler syntax. wilson@cygnus.com says # is right. */
40 #undef COMMENT_BEGIN
41 #define COMMENT_BEGIN "#"
42
43 /* Use stabs instead of DWARF debug format. */
44 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
45 #include <sparc/sysv4.h>
46
47 #undef MD_EXEC_PREFIX
48 #undef MD_STARTFILE_PREFIX
49
50 /* Output at beginning of assembler file. */
51 /* The .file command should always begin the output. */
52 #undef ASM_FILE_START
53 #define ASM_FILE_START(FILE) \
54 do { \
55 output_file_directive (FILE, main_input_filename); \
56 fprintf (FILE, "\t.version\t\"01.01\"\n"); \
57 } while (0)
58
59 #undef LIBGCC_SPEC
60 #define LIBGCC_SPEC \
61 "%{!shared:-lgcc}"
62
63 /* Provide a STARTFILE_SPEC appropriate for Linux. Here we add
64 the Linux magical crtbegin.o file (see crtstuff.c) which
65 provides part of the support for getting C++ file-scope static
66 object constructed before entering `main'. */
67
68 #undef STARTFILE_SPEC
69 #define STARTFILE_SPEC \
70 "%{!shared: \
71 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
72 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
73
74 /* Provide a ENDFILE_SPEC appropriate for Linux. Here we tack on
75 the Linux magical crtend.o file (see crtstuff.c) which
76 provides part of the support for getting C++ file-scope static
77 object constructed before entering `main', followed by a normal
78 Linux "finalizer" file, `crtn.o'. */
79
80 #undef ENDFILE_SPEC
81 #define ENDFILE_SPEC \
82 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
83
84 #undef TARGET_VERSION
85 #define TARGET_VERSION fprintf (stderr, " (sparc Linux/ELF)");
86
87 #undef SIZE_TYPE
88 #define SIZE_TYPE "unsigned int"
89
90 #undef PTRDIFF_TYPE
91 #define PTRDIFF_TYPE "int"
92
93 #undef WCHAR_TYPE
94 #define WCHAR_TYPE "long int"
95
96 #undef WCHAR_TYPE_SIZE
97 #define WCHAR_TYPE_SIZE BITS_PER_WORD
98
99 #undef CPP_PREDEFINES
100 #define CPP_PREDEFINES "-D__ELF__ -Dunix -Dsparc -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(sparc) -Amachine(sparc)"
101
102 #undef CPP_SPEC
103 #define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{msparclite:-D__sparclite__} %{mv8:-D__sparc_v8__} %{msupersparc:-D__supersparc__ -D__sparc_v8__} %{posix:-D_POSIX_SOURCE}"
104
105 #undef LIB_SPEC
106 #if 1
107 /* We no longer link with libc_p.a or libg.a by default. If you
108 * want to profile or debug the Linux C library, please add
109 * -lc_p or -ggdb to LDFLAGS at the link time, respectively.
110 */
111 #define LIB_SPEC \
112 "%{!shared: %{mieee-fp:-lieee} %{p:-lgmon} %{pg:-lgmon} \
113 %{!ggdb:-lc} %{ggdb:-lg}}"
114 #else
115 #define LIB_SPEC \
116 "%{!shared: \
117 %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
118 %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}"
119 #endif
120
121 /* Provide a LINK_SPEC appropriate for Linux. Here we provide support
122 for the special GCC options -static and -shared, which allow us to
123 link things in one of these three modes by applying the appropriate
124 combinations of options at link-time. We like to support here for
125 as many of the other GNU linker options as possible. But I don't
126 have the time to search for those flags. I am sure how to add
127 support for -soname shared_object_name. H.J.
128
129 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
130 -Wl,-V.
131
132 When the -shared link option is used a final link is not being
133 done. */
134
135 /* If ELF is the default format, we should not use /lib/elf. */
136
137 #undef LINK_SPEC
138 #ifndef LINUX_DEFAULT_ELF
139 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
140 %{!shared: \
141 %{!ibcs: \
142 %{!static: \
143 %{rdynamic:-export-dynamic} \
144 %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \
145 %{!rpath:-rpath /lib/elf/}} %{static:-static}}}"
146 #else
147 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
148 %{!shared: \
149 %{!ibcs: \
150 %{!static: \
151 %{rdynamic:-export-dynamic} \
152 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
153 %{static:-static}}}"
154 #endif
155
156 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
157 It's safe to pass -s always, even if -g is not used. */
158 #undef ASM_SPEC
159 #define ASM_SPEC \
160 "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s %{fpic:-K PIC} %{fPIC:-K PIC}"
161
162 /* Same as sparc.h */
163 #undef DBX_REGISTER_NUMBER
164 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
165
166 /* We use stabs-in-elf for debugging, because that is what the native
167 toolchain uses. XXX */
168 #undef PREFERRED_DEBUGGING_TYPE
169 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
170
171 #undef ASM_OUTPUT_ALIGNED_LOCAL
172 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
173 do { \
174 fputs ("\t.local\t", (FILE)); \
175 assemble_name ((FILE), (NAME)); \
176 putc ('\n', (FILE)); \
177 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
178 } while (0)
179
180 #undef COMMON_ASM_OP
181 #define COMMON_ASM_OP "\t.common"
182
183 /* This is how to output a definition of an internal numbered label where
184 PREFIX is the class of label and NUM is the number within the class. */
185
186 #undef ASM_OUTPUT_INTERNAL_LABEL
187 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
188 fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
189
190 /* This is how to output a reference to an internal numbered label where
191 PREFIX is the class of label and NUM is the number within the class. */
192
193 #undef ASM_OUTPUT_INTERNAL_LABELREF
194 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
195 fprintf (FILE, ".L%s%d", PREFIX, NUM)
196
197 /* This is how to store into the string LABEL
198 the symbol_ref name of an internal numbered label where
199 PREFIX is the class of label and NUM is the number within the class.
200 This is suitable for output with `assemble_name'. */
201
202 #undef ASM_GENERATE_INTERNAL_LABEL
203 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
204 sprintf (LABEL, "*.L%s%d", PREFIX, NUM)
205
206 \f
207 #if 0
208 /* Define for support of TFmode long double and REAL_ARITHMETIC.
209 Sparc ABI says that long double is 4 words. Linux does not support
210 long double yet. */
211 #define LONG_DOUBLE_TYPE_SIZE 128
212 #endif