xref: /openbsd-src/gnu/usr.bin/gcc/gcc/config/sparc/linux.h (revision 4e43c760ad4cd5f644ec700462679d05749498d8)
1 /* Definitions for SPARC running Linux-based GNU systems with ELF.
2    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002 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 /* GNU/Linux uses ctype from glibc.a. I am not sure how complete it is.
28    For now, we play safe. It may change later.  */
29 
30 #if 0
31 #undef MULTIBYTE_CHARS
32 #define MULTIBYTE_CHARS 1
33 #endif
34 
35 #undef MD_EXEC_PREFIX
36 #undef MD_STARTFILE_PREFIX
37 
38 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux.  Here we add
39    the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
40    provides part of the support for getting C++ file-scope static
41    object constructed before entering `main'.  */
42 
43 #undef  STARTFILE_SPEC
44 #ifdef USE_GNULIBC_1
45 #define STARTFILE_SPEC \
46   "%{!shared: \
47      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
48    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
49 #else
50 #define STARTFILE_SPEC \
51   "%{!shared: \
52      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
53    crti.o%s %{static:crtbeginT.o%s}\
54    %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
55 #endif
56 
57 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
58    the GNU/Linux magical crtend.o file (see crtstuff.c) which
59    provides part of the support for getting C++ file-scope static
60    object constructed before entering `main', followed by a normal
61    GNU/Linux "finalizer" file, `crtn.o'.  */
62 
63 #undef  ENDFILE_SPEC
64 #define ENDFILE_SPEC \
65   "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
66    %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
67 
68 /* This is for -profile to use -lc_p instead of -lc.  */
69 #undef	CC1_SPEC
70 #define	CC1_SPEC "%{profile:-p} \
71 %{sun4:} %{target:} \
72 %{mcypress:-mcpu=cypress} \
73 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
74 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
75 "
76 
77 /* The GNU C++ standard library requires that these macros be defined.  */
78 #undef CPLUSPLUS_CPP_SPEC
79 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
80 
81 #undef TARGET_VERSION
82 #define TARGET_VERSION fprintf (stderr, " (sparc GNU/Linux with ELF)");
83 
84 #undef SUBTARGET_SWITCHES
85 #define SUBTARGET_SWITCHES \
86 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
87 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
88 
89 #undef SIZE_TYPE
90 #define SIZE_TYPE "unsigned int"
91 
92 #undef PTRDIFF_TYPE
93 #define PTRDIFF_TYPE "int"
94 
95 #undef WCHAR_TYPE
96 #define WCHAR_TYPE "int"
97 
98 #undef WCHAR_TYPE_SIZE
99 #define WCHAR_TYPE_SIZE 32
100 
101 #undef CPP_PREDEFINES
102 #define CPP_PREDEFINES "-D__ELF__ -Dunix -D__sparc__ -D__gnu_linux__ -Dlinux -Asystem=unix -Asystem=posix"
103 
104 #undef CPP_SUBTARGET_SPEC
105 #ifdef USE_GNULIBC_1
106 #define CPP_SUBTARGET_SPEC \
107 "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
108 %{mlong-double-128:-D__LONG_DOUBLE_128__}"
109 #else
110 #define CPP_SUBTARGET_SPEC \
111 "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
112 %{pthread:-D_REENTRANT} %{mlong-double-128:-D__LONG_DOUBLE_128__}"
113 #endif
114 
115 #undef LIB_SPEC
116 /* We no longer link with libc_p.a or libg.a by default. If you
117    want to profile or debug the GNU/Linux C library, please add
118    -lc_p or -ggdb to LDFLAGS at the link time, respectively.  */
119 #if 1
120 #ifdef USE_GNULIBC_1
121 #define LIB_SPEC \
122   "%{!shared: %{p:-lgmon} %{pg:-lgmon} %{profile:-lgmon -lc_p} \
123      %{!profile:%{!ggdb:-lc} %{ggdb:-lg}}}"
124 #else
125 #define LIB_SPEC \
126   "%{pthread:-lpthread} \
127    %{shared:-lc} \
128    %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
129 #endif
130 #else
131 #define LIB_SPEC \
132   "%{!shared: \
133      %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
134        %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}"
135 #endif
136 
137 /* Provide a LINK_SPEC appropriate for GNU/Linux.  Here we provide support
138    for the special GCC options -static and -shared, which allow us to
139    link things in one of these three modes by applying the appropriate
140    combinations of options at link-time. We like to support here for
141    as many of the other GNU linker options as possible. But I don't
142    have the time to search for those flags. I am sure how to add
143    support for -soname shared_object_name. H.J.
144 
145    I took out %{v:%{!V:-V}}. It is too much :-(. They can use
146    -Wl,-V.
147 
148    When the -shared link option is used a final link is not being
149    done.  */
150 
151 /* If ELF is the default format, we should not use /lib/elf.  */
152 
153 #undef  LINK_SPEC
154 #ifdef USE_GNULIBC_1
155 #ifndef LINUX_DEFAULT_ELF
156 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
157   %{!shared: \
158     %{!ibcs: \
159       %{!static: \
160         %{rdynamic:-export-dynamic} \
161         %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \
162         %{!rpath:-rpath /lib/elf/}} %{static:-static}}}"
163 #else
164 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
165   %{!shared: \
166     %{!ibcs: \
167       %{!static: \
168         %{rdynamic:-export-dynamic} \
169         %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
170         %{static:-static}}}"
171 #endif
172 #else
173 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
174   %{!mno-relax:%{!r:-relax}} \
175   %{!shared: \
176     %{!ibcs: \
177       %{!static: \
178         %{rdynamic:-export-dynamic} \
179         %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
180         %{static:-static}}}"
181 #endif
182 
183 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
184    It's safe to pass -s always, even if -g is not used.  */
185 #undef ASM_SPEC
186 #define ASM_SPEC \
187   "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s %{fpic:-K PIC} \
188    %{fPIC:-K PIC} %(asm_cpu) %(asm_relax)"
189 
190 /* Same as sparc.h */
191 #undef DBX_REGISTER_NUMBER
192 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
193 
194 #undef ASM_OUTPUT_ALIGNED_LOCAL
195 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)		\
196 do {									\
197   fputs ("\t.local\t", (FILE));		\
198   assemble_name ((FILE), (NAME));					\
199   putc ('\n', (FILE));							\
200   ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);			\
201 } while (0)
202 
203 #undef COMMON_ASM_OP
204 #define COMMON_ASM_OP "\t.common\t"
205 
206 #undef  LOCAL_LABEL_PREFIX
207 #define LOCAL_LABEL_PREFIX  "."
208 
209 /* This is how to output a definition of an internal numbered label where
210    PREFIX is the class of label and NUM is the number within the class.  */
211 
212 #undef  ASM_OUTPUT_INTERNAL_LABEL
213 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)	\
214   fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
215 
216 /* This is how to output a reference to an internal numbered label where
217    PREFIX is the class of label and NUM is the number within the class.  */
218 
219 #undef  ASM_OUTPUT_INTERNAL_LABELREF
220 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)	\
221   fprintf (FILE, ".L%s%d", PREFIX, NUM)
222 
223 /* This is how to store into the string LABEL
224    the symbol_ref name of an internal numbered label where
225    PREFIX is the class of label and NUM is the number within the class.
226    This is suitable for output with `assemble_name'.  */
227 
228 #undef  ASM_GENERATE_INTERNAL_LABEL
229 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)	\
230   sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
231 
232 
233 /* Define for support of TFmode long double.
234    SPARC ABI says that long double is 4 words.  */
235 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
236 
237 /* Constant which presents upper bound of the above value.  */
238 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
239 
240 /* Define this to set long double type size to use in libgcc2.c, which can
241    not depend on target_flags.  */
242 #ifdef __LONG_DOUBLE_128__
243 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
244 #else
245 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
246 #endif
247 
248 #undef DITF_CONVERSION_LIBFUNCS
249 #define DITF_CONVERSION_LIBFUNCS       1
250 
251 #if !defined(USE_GNULIBC_1) && defined(HAVE_LD_EH_FRAME_HDR)
252 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
253 #endif
254 
255 /* Don't be different from other Linux platforms in this regard.  */
256 #define HANDLE_PRAGMA_PACK_PUSH_POP
257 
258 /* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
259 #undef CTORS_SECTION_ASM_OP
260 #undef DTORS_SECTION_ASM_OP
261 
262 #undef LINK_GCC_C_SEQUENCE_SPEC
263 #define LINK_GCC_C_SEQUENCE_SPEC \
264   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
265 
266 #define ASM_FILE_END(FILE) \
267   do {									\
268     named_section_flags (".note.GNU-stack",				\
269 			 SECTION_DEBUG					\
270 			 | (trampolines_created ? SECTION_CODE : 0));	\
271   } while (0)
272 
273 /* Do code reading to identify a signal frame, and set the frame
274    state data appropriately.  See unwind-dw2.c for the structs.  */
275 
276 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)		\
277   do {									\
278     unsigned int *pc_ = (CONTEXT)->ra;					\
279     int new_cfa_, i_, oldstyle_;					\
280     int regs_off_, fpu_save_off_;					\
281     int fpu_save_, this_cfa_;						\
282 									\
283     if (pc_[1] != 0x91d02010)		/* ta 0x10 */			\
284       break;								\
285     if (pc_[0] == 0x821020d8)		/* mov NR_sigreturn, %g1 */	\
286       oldstyle_ = 1;							\
287     else if (pc_[0] == 0x82102065)	/* mov NR_rt_sigreturn, %g1 */	\
288       oldstyle_ = 0;							\
289     else								\
290       break;								\
291     if (oldstyle_)							\
292       {									\
293         regs_off_ = 96;							\
294         fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4);			\
295       }									\
296     else								\
297       {									\
298         regs_off_ = 96 + 128;						\
299         fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4);	\
300       }									\
301     this_cfa_ = (int) (CONTEXT)->cfa;					\
302     new_cfa_ = *(int *)(((CONTEXT)->cfa) + (regs_off_+(4*4)+(14 * 4)));	\
303     fpu_save_ = *(int *)((this_cfa_) + (fpu_save_off_));		\
304     (FS)->cfa_how = CFA_REG_OFFSET;					\
305     (FS)->cfa_reg = 14;							\
306     (FS)->cfa_offset = new_cfa_ - (int) (CONTEXT)->cfa;			\
307     for (i_ = 1; i_ < 16; ++i_)						\
308       {									\
309         if (i_ == 14)							\
310           continue;							\
311 	(FS)->regs.reg[i_].how = REG_SAVED_OFFSET;			\
312 	(FS)->regs.reg[i_].loc.offset =					\
313 	   this_cfa_ + (regs_off_+(4 * 4)+(i_ * 4)) - new_cfa_;		\
314       }									\
315     for (i_ = 0; i_ < 16; ++i_)						\
316       {									\
317 	(FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET;			\
318 	(FS)->regs.reg[i_ + 16].loc.offset =				\
319 	  this_cfa_ + (i_ * 4) - new_cfa_;				\
320       }									\
321     if (fpu_save_)							\
322       {									\
323 	for (i_ = 0; i_ < 32; ++i_)					\
324 	  {								\
325 	    (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET;		\
326 	    (FS)->regs.reg[i_ + 32].loc.offset =			\
327 	      (fpu_save_ + (i_ * 4)) - new_cfa_;			\
328 	  }								\
329       }									\
330     /* Stick return address into %g0, same trick Alpha uses.  */	\
331     (FS)->regs.reg[0].how = REG_SAVED_OFFSET;				\
332     (FS)->regs.reg[0].loc.offset = this_cfa_+(regs_off_+4)-new_cfa_;	\
333     (FS)->retaddr_column = 0;						\
334     goto SUCCESS;							\
335   } while (0)
336