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