xref: /openbsd-src/gnu/gcc/gcc/config/sparc/netbsd-elf.h (revision 404b540a9034ac75a6199ad1a32d1bbc7a0d4210)
1*404b540aSrobert /* Definitions of target machine for GCC, for ELF on NetBSD/sparc
2*404b540aSrobert    and NetBSD/sparc64.
3*404b540aSrobert    Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4*404b540aSrobert    Contributed by Matthew Green (mrg@eterna.com.au).
5*404b540aSrobert 
6*404b540aSrobert This file is part of GCC.
7*404b540aSrobert 
8*404b540aSrobert GCC is free software; you can redistribute it and/or modify
9*404b540aSrobert it under the terms of the GNU General Public License as published by
10*404b540aSrobert the Free Software Foundation; either version 2, or (at your option)
11*404b540aSrobert any later version.
12*404b540aSrobert 
13*404b540aSrobert GCC is distributed in the hope that it will be useful,
14*404b540aSrobert but WITHOUT ANY WARRANTY; without even the implied warranty of
15*404b540aSrobert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*404b540aSrobert GNU General Public License for more details.
17*404b540aSrobert 
18*404b540aSrobert You should have received a copy of the GNU General Public License
19*404b540aSrobert along with GCC; see the file COPYING.  If not, write to
20*404b540aSrobert the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21*404b540aSrobert Boston, MA 02110-1301, USA.  */
22*404b540aSrobert 
23*404b540aSrobert #define TARGET_OS_CPP_BUILTINS()			\
24*404b540aSrobert   do							\
25*404b540aSrobert     {							\
26*404b540aSrobert       NETBSD_OS_CPP_BUILTINS_ELF();			\
27*404b540aSrobert       if (TARGET_ARCH64)				\
28*404b540aSrobert 	{						\
29*404b540aSrobert 	  builtin_define ("__sparc64__");		\
30*404b540aSrobert 	  builtin_define ("__sparc_v9__");		\
31*404b540aSrobert 	  builtin_define ("__sparcv9");			\
32*404b540aSrobert 	}						\
33*404b540aSrobert       else						\
34*404b540aSrobert 	builtin_define ("__sparc");			\
35*404b540aSrobert       builtin_define ("__sparc__");			\
36*404b540aSrobert     }							\
37*404b540aSrobert   while (0)
38*404b540aSrobert 
39*404b540aSrobert /* Make sure these are undefined.  */
40*404b540aSrobert #undef MD_EXEC_PREFIX
41*404b540aSrobert #undef MD_STARTFILE_PREFIX
42*404b540aSrobert 
43*404b540aSrobert /* CPP defines used by all NetBSD targets.  */
44*404b540aSrobert #undef CPP_SUBTARGET_SPEC
45*404b540aSrobert #define CPP_SUBTARGET_SPEC "%(netbsd_cpp_spec)"
46*404b540aSrobert 
47*404b540aSrobert /* SIZE_TYPE and PTRDIFF_TYPE are wrong from sparc/sparc.h.  */
48*404b540aSrobert #undef SIZE_TYPE
49*404b540aSrobert #define SIZE_TYPE "long unsigned int"
50*404b540aSrobert 
51*404b540aSrobert #undef PTRDIFF_TYPE
52*404b540aSrobert #define PTRDIFF_TYPE "long int"
53*404b540aSrobert 
54*404b540aSrobert /* This is the char to use for continuation (in case we need to turn
55*404b540aSrobert    continuation back on).  */
56*404b540aSrobert #undef DBX_CONTIN_CHAR
57*404b540aSrobert #define DBX_CONTIN_CHAR '?'
58*404b540aSrobert 
59*404b540aSrobert #undef  LOCAL_LABEL_PREFIX
60*404b540aSrobert #define LOCAL_LABEL_PREFIX  "."
61*404b540aSrobert 
62*404b540aSrobert /* This is how to store into the string LABEL
63*404b540aSrobert    the symbol_ref name of an internal numbered label where
64*404b540aSrobert    PREFIX is the class of label and NUM is the number within the class.
65*404b540aSrobert    This is suitable for output with `assemble_name'.  */
66*404b540aSrobert 
67*404b540aSrobert #undef  ASM_GENERATE_INTERNAL_LABEL
68*404b540aSrobert #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)	\
69*404b540aSrobert   sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
70*404b540aSrobert 
71*404b540aSrobert #undef USER_LABEL_PREFIX
72*404b540aSrobert #define USER_LABEL_PREFIX ""
73*404b540aSrobert 
74*404b540aSrobert #undef ASM_SPEC
75*404b540aSrobert #define ASM_SPEC "%{fpic|fPIC|fpie|fPIE:-K PIC} %{V} %{v:%{!V:-V}} \
76*404b540aSrobert %{mlittle-endian:-EL} \
77*404b540aSrobert %(asm_cpu) %(asm_arch) %(asm_relax)"
78*404b540aSrobert 
79*404b540aSrobert #undef STDC_0_IN_SYSTEM_HEADERS
80*404b540aSrobert 
81*404b540aSrobert /* Attempt to enable execute permissions on the stack.  */
82*404b540aSrobert #define ENABLE_EXECUTE_STACK NETBSD_ENABLE_EXECUTE_STACK
83*404b540aSrobert 
84*404b540aSrobert #undef TARGET_VERSION
85*404b540aSrobert #define TARGET_VERSION fprintf (stderr, " (%s)", TARGET_NAME);
86*404b540aSrobert 
87*404b540aSrobert /* Below here exists the merged NetBSD/sparc & NetBSD/sparc64 compiler
88*404b540aSrobert    description, allowing one to build 32 bit or 64 bit applications
89*404b540aSrobert    on either.  We define the sparc & sparc64 versions of things,
90*404b540aSrobert    occasionally a neutral version (should be the same as "netbsd-elf.h")
91*404b540aSrobert    and then based on SPARC_BI_ARCH, DEFAULT_ARCH32_P, and TARGET_CPU_DEFAULT,
92*404b540aSrobert    we choose the correct version.  */
93*404b540aSrobert 
94*404b540aSrobert /* We use the default NetBSD ELF STARTFILE_SPEC and ENDFILE_SPEC
95*404b540aSrobert    definitions, even for the SPARC_BI_ARCH compiler, because NetBSD does
96*404b540aSrobert    not have a default place to find these libraries..  */
97*404b540aSrobert 
98*404b540aSrobert /* Name the port(s).  */
99*404b540aSrobert #define TARGET_NAME64     "NetBSD/sparc64 ELF"
100*404b540aSrobert #define TARGET_NAME32     "NetBSD/sparc ELF"
101*404b540aSrobert 
102*404b540aSrobert /* TARGET_CPU_DEFAULT is set in Makefile.in.  We test for 64-bit default
103*404b540aSrobert    platform here.  */
104*404b540aSrobert 
105*404b540aSrobert #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
106*404b540aSrobert  || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
107*404b540aSrobert /* A 64 bit v9 compiler with stack-bias,
108*404b540aSrobert    in a Medium/Low code model environment.  */
109*404b540aSrobert 
110*404b540aSrobert #undef TARGET_DEFAULT
111*404b540aSrobert #define TARGET_DEFAULT \
112*404b540aSrobert   (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
113*404b540aSrobert    + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
114*404b540aSrobert 
115*404b540aSrobert #undef SPARC_DEFAULT_CMODEL
116*404b540aSrobert #define SPARC_DEFAULT_CMODEL CM_MEDANY
117*404b540aSrobert 
118*404b540aSrobert #endif
119*404b540aSrobert 
120*404b540aSrobert /* CC1_SPEC for NetBSD/sparc.  */
121*404b540aSrobert #define CC1_SPEC32 \
122*404b540aSrobert  "%{sun4:} %{target:} \
123*404b540aSrobert   %{mcypress:-mcpu=cypress} \
124*404b540aSrobert   %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
125*404b540aSrobert   %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
126*404b540aSrobert   %{m32:%{m64:%emay not use both -m32 and -m64}} \
127*404b540aSrobert   %{m64: \
128*404b540aSrobert     -mptr64 -mstack-bias -mno-v8plus -mlong-double-128 \
129*404b540aSrobert     %{!mcpu*: \
130*404b540aSrobert       %{!mcypress: \
131*404b540aSrobert         %{!msparclite: \
132*404b540aSrobert 	  %{!mf930: \
133*404b540aSrobert 	    %{!mf934: \
134*404b540aSrobert 	      %{!mv8*: \
135*404b540aSrobert 	        %{!msupersparc:-mcpu=ultrasparc}}}}}}} \
136*404b540aSrobert     %{!mno-vis:%{!mcpu=v9:-mvis}} \
137*404b540aSrobert     %{p:-mcmodel=medlow} \
138*404b540aSrobert     %{pg:-mcmodel=medlow}}"
139*404b540aSrobert 
140*404b540aSrobert #define CC1_SPEC64 \
141*404b540aSrobert  "%{sun4:} %{target:} \
142*404b540aSrobert   %{mcypress:-mcpu=cypress} \
143*404b540aSrobert   %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
144*404b540aSrobert   %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
145*404b540aSrobert   %{m32:%{m64:%emay not use both -m32 and -m64}} \
146*404b540aSrobert   %{m32: \
147*404b540aSrobert     -mptr32 -mno-stack-bias \
148*404b540aSrobert     %{!mlong-double-128:-mlong-double-64} \
149*404b540aSrobert     %{!mcpu*: \
150*404b540aSrobert       %{!mcypress: \
151*404b540aSrobert 	%{!msparclite: \
152*404b540aSrobert 	  %{!mf930: \
153*404b540aSrobert 	    %{!mf934: \
154*404b540aSrobert 	      %{!mv8*: \
155*404b540aSrobert 		%{!msupersparc:-mcpu=cypress}}}}}}}} \
156*404b540aSrobert   %{!m32: \
157*404b540aSrobert     %{p:-mcmodel=medlow} \
158*404b540aSrobert     %{pg:-mcmodel=medlow}}"
159*404b540aSrobert 
160*404b540aSrobert /* Make sure we use the right output format.  Pick a default and then
161*404b540aSrobert    make sure -m32/-m64 switch to the right one.  */
162*404b540aSrobert 
163*404b540aSrobert #define LINK_ARCH32_SPEC "-m elf32_sparc"
164*404b540aSrobert 
165*404b540aSrobert #define LINK_ARCH64_SPEC "-m elf64_sparc"
166*404b540aSrobert 
167*404b540aSrobert #define LINK_ARCH_SPEC \
168*404b540aSrobert  "%{m32:%(link_arch32)} \
169*404b540aSrobert   %{m64:%(link_arch64)} \
170*404b540aSrobert   %{!m32:%{!m64:%(link_arch_default)}}"
171*404b540aSrobert 
172*404b540aSrobert #undef LINK_SPEC
173*404b540aSrobert #define LINK_SPEC \
174*404b540aSrobert  "%(link_arch) \
175*404b540aSrobert   %{!mno-relax:%{!r:-relax}} \
176*404b540aSrobert   %(netbsd_link_spec)"
177*404b540aSrobert 
178*404b540aSrobert #define NETBSD_ENTRY_POINT "__start"
179*404b540aSrobert 
180*404b540aSrobert #if DEFAULT_ARCH32_P
181*404b540aSrobert #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH32_SPEC
182*404b540aSrobert #else
183*404b540aSrobert #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH64_SPEC
184*404b540aSrobert #endif
185*404b540aSrobert 
186*404b540aSrobert /* What extra spec entries do we need?  */
187*404b540aSrobert #undef SUBTARGET_EXTRA_SPECS
188*404b540aSrobert #define SUBTARGET_EXTRA_SPECS \
189*404b540aSrobert   { "link_arch32",		LINK_ARCH32_SPEC }, \
190*404b540aSrobert   { "link_arch64",		LINK_ARCH64_SPEC }, \
191*404b540aSrobert   { "link_arch_default",	LINK_ARCH_DEFAULT_SPEC }, \
192*404b540aSrobert   { "link_arch",		LINK_ARCH_SPEC }, \
193*404b540aSrobert   { "netbsd_cpp_spec",		NETBSD_CPP_SPEC }, \
194*404b540aSrobert   { "netbsd_link_spec",		NETBSD_LINK_SPEC_ELF }, \
195*404b540aSrobert   { "netbsd_entry_point",	NETBSD_ENTRY_POINT },
196*404b540aSrobert 
197*404b540aSrobert 
198*404b540aSrobert /* Build a compiler that supports -m32 and -m64?  */
199*404b540aSrobert 
200*404b540aSrobert #ifdef SPARC_BI_ARCH
201*404b540aSrobert 
202*404b540aSrobert #undef LONG_DOUBLE_TYPE_SIZE
203*404b540aSrobert #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
204*404b540aSrobert 
205*404b540aSrobert #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
206*404b540aSrobert #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
207*404b540aSrobert #else
208*404b540aSrobert #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
209*404b540aSrobert #endif
210*404b540aSrobert 
211*404b540aSrobert #undef  CC1_SPEC
212*404b540aSrobert #if DEFAULT_ARCH32_P
213*404b540aSrobert #define CC1_SPEC CC1_SPEC32
214*404b540aSrobert #else
215*404b540aSrobert #define CC1_SPEC CC1_SPEC64
216*404b540aSrobert #endif
217*404b540aSrobert 
218*404b540aSrobert #if DEFAULT_ARCH32_P
219*404b540aSrobert #define MULTILIB_DEFAULTS { "m32" }
220*404b540aSrobert #else
221*404b540aSrobert #define MULTILIB_DEFAULTS { "m64" }
222*404b540aSrobert #endif
223*404b540aSrobert 
224*404b540aSrobert /* Name the port.  */
225*404b540aSrobert #undef TARGET_NAME
226*404b540aSrobert #define TARGET_NAME     (DEFAULT_ARCH32_P ? TARGET_NAME32 : TARGET_NAME64)
227*404b540aSrobert 
228*404b540aSrobert #else	/* SPARC_BI_ARCH */
229*404b540aSrobert 
230*404b540aSrobert #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
231*404b540aSrobert  || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
232*404b540aSrobert 
233*404b540aSrobert #undef LONG_DOUBLE_TYPE_SIZE
234*404b540aSrobert #define LONG_DOUBLE_TYPE_SIZE 128
235*404b540aSrobert 
236*404b540aSrobert #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
237*404b540aSrobert #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
238*404b540aSrobert 
239*404b540aSrobert #undef  CC1_SPEC
240*404b540aSrobert #define CC1_SPEC CC1_SPEC64
241*404b540aSrobert 
242*404b540aSrobert #undef TARGET_NAME
243*404b540aSrobert #define TARGET_NAME     TARGET_NAME64
244*404b540aSrobert 
245*404b540aSrobert #else	/* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
246*404b540aSrobert 	|| TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
247*404b540aSrobert 
248*404b540aSrobert /* A 32-bit only compiler.  NetBSD don't support 128 bit `long double'
249*404b540aSrobert    for 32-bit code, unlike Solaris.  */
250*404b540aSrobert 
251*404b540aSrobert #undef LONG_DOUBLE_TYPE_SIZE
252*404b540aSrobert #define LONG_DOUBLE_TYPE_SIZE 64
253*404b540aSrobert 
254*404b540aSrobert #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
255*404b540aSrobert #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
256*404b540aSrobert 
257*404b540aSrobert #undef  CC1_SPEC
258*404b540aSrobert #define CC1_SPEC CC1_SPEC32
259*404b540aSrobert 
260*404b540aSrobert #undef TARGET_NAME
261*404b540aSrobert #define TARGET_NAME     TARGET_NAME32
262*404b540aSrobert 
263*404b540aSrobert #endif	/* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
264*404b540aSrobert 	|| TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
265*404b540aSrobert 
266*404b540aSrobert #endif	/* SPARC_BI_ARCH */
267*404b540aSrobert 
268*404b540aSrobert /* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
269*404b540aSrobert #undef CTORS_SECTION_ASM_OP
270*404b540aSrobert #undef DTORS_SECTION_ASM_OP
271