2015-05-05 Yvan Roux <yvan.roux@linaro.org>
[official-gcc.git] / gcc / config / sparc / netbsd-elf.h
blob165660ce532beb8d34c3a5e9e446ada8b1aa79ea
1 /* Definitions of target machine for GCC, for ELF on NetBSD/sparc
2 and NetBSD/sparc64.
3 Copyright (C) 2002-2015 Free Software Foundation, Inc.
4 Contributed by Matthew Green (mrg@eterna.com.au).
6 This file is part of GCC.
8 GCC 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 3, or (at your option)
11 any later version.
13 GCC 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.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #define TARGET_OS_CPP_BUILTINS() \
23 do \
24 { \
25 NETBSD_OS_CPP_BUILTINS_ELF(); \
26 if (TARGET_ARCH64) \
27 { \
28 builtin_define ("__sparc64__"); \
29 builtin_define ("__sparc_v9__"); \
30 builtin_define ("__sparcv9"); \
31 } \
32 else \
33 builtin_define ("__sparc"); \
34 builtin_define ("__sparc__"); \
35 } \
36 while (0)
38 /* CPP defines used by all NetBSD targets. */
39 #undef CPP_SUBTARGET_SPEC
40 #define CPP_SUBTARGET_SPEC "%(netbsd_cpp_spec)"
42 /* SIZE_TYPE and PTRDIFF_TYPE are wrong from sparc/sparc.h. */
43 #undef SIZE_TYPE
44 #define SIZE_TYPE "long unsigned int"
46 #undef PTRDIFF_TYPE
47 #define PTRDIFF_TYPE "long int"
49 /* This is the char to use for continuation (in case we need to turn
50 continuation back on). */
51 #undef DBX_CONTIN_CHAR
52 #define DBX_CONTIN_CHAR '?'
54 #undef LOCAL_LABEL_PREFIX
55 #define LOCAL_LABEL_PREFIX "."
57 /* This is how to store into the string LABEL
58 the symbol_ref name of an internal numbered label where
59 PREFIX is the class of label and NUM is the number within the class.
60 This is suitable for output with `assemble_name'. */
62 #undef ASM_GENERATE_INTERNAL_LABEL
63 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
64 sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
66 #undef USER_LABEL_PREFIX
67 #define USER_LABEL_PREFIX ""
69 #undef ASM_SPEC
70 #define ASM_SPEC "%{fpic|fPIC|fpie|fPIE:-K PIC} \
71 %(asm_cpu) %(asm_arch) %(asm_relax)"
73 #undef STDC_0_IN_SYSTEM_HEADERS
75 #define HAVE_ENABLE_EXECUTE_STACK
77 /* Below here exists the merged NetBSD/sparc & NetBSD/sparc64 compiler
78 description, allowing one to build 32-bit or 64-bit applications
79 on either. We define the sparc & sparc64 versions of things,
80 occasionally a neutral version (should be the same as "netbsd-elf.h")
81 and then based on SPARC_BI_ARCH, DEFAULT_ARCH32_P, and TARGET_CPU_DEFAULT,
82 we choose the correct version. */
84 /* We use the default NetBSD ELF STARTFILE_SPEC and ENDFILE_SPEC
85 definitions, even for the SPARC_BI_ARCH compiler, because NetBSD does
86 not have a default place to find these libraries.. */
88 /* TARGET_CPU_DEFAULT is set in Makefile.in. We test for 64-bit default
89 platform here. */
91 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
92 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
93 /* A 64 bit v9 compiler with stack-bias,
94 in a Medium/Low code model environment. */
96 #undef TARGET_DEFAULT
97 #define TARGET_DEFAULT \
98 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
99 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
101 #undef SPARC_DEFAULT_CMODEL
102 #define SPARC_DEFAULT_CMODEL CM_MEDANY
104 #endif
106 /* CC1_SPEC for NetBSD/sparc. */
107 #define CC1_SPEC32 \
108 "%{m32:%{m64:%emay not use both -m32 and -m64}} \
109 %{m64: \
110 -mptr64 -mstack-bias -mno-v8plus -mlong-double-128 \
111 %{!mcpu*:%{!mv8plus:-mcpu=ultrasparc}} \
112 %{!mno-vis:%{!mcpu=v9:-mvis}} \
113 %{p:-mcmodel=medlow} \
114 %{pg:-mcmodel=medlow}}"
116 #define CC1_SPEC64 \
117 "%{m32:%{m64:%emay not use both -m32 and -m64}} \
118 %{m32: \
119 -mptr32 -mno-stack-bias \
120 %{!mlong-double-128:-mlong-double-64} \
121 %{!mcpu*:%{!mv8plus:-mcpu=cypress}}} \
122 %{!m32: \
123 %{p:-mcmodel=medlow} \
124 %{pg:-mcmodel=medlow}}"
126 /* Make sure we use the right output format. Pick a default and then
127 make sure -m32/-m64 switch to the right one. */
129 #define LINK_ARCH32_SPEC "-m elf32_sparc"
131 #define LINK_ARCH64_SPEC "-m elf64_sparc"
133 #define LINK_ARCH_SPEC \
134 "%{m32:%(link_arch32)} \
135 %{m64:%(link_arch64)} \
136 %{!m32:%{!m64:%(link_arch_default)}}"
138 #undef LINK_SPEC
139 #define LINK_SPEC \
140 "%(link_arch) \
141 %{!mno-relax:%{!r:-relax}} \
142 %(netbsd_link_spec)"
144 #define NETBSD_ENTRY_POINT "__start"
146 #if DEFAULT_ARCH32_P
147 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH32_SPEC
148 #else
149 #define LINK_ARCH_DEFAULT_SPEC LINK_ARCH64_SPEC
150 #endif
152 /* What extra spec entries do we need? */
153 #undef SUBTARGET_EXTRA_SPECS
154 #define SUBTARGET_EXTRA_SPECS \
155 { "link_arch32", LINK_ARCH32_SPEC }, \
156 { "link_arch64", LINK_ARCH64_SPEC }, \
157 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
158 { "link_arch", LINK_ARCH_SPEC }, \
159 { "netbsd_cpp_spec", NETBSD_CPP_SPEC }, \
160 { "netbsd_link_spec", NETBSD_LINK_SPEC_ELF }, \
161 { "netbsd_entry_point", NETBSD_ENTRY_POINT },
164 /* Build a compiler that supports -m32 and -m64? */
166 #ifdef SPARC_BI_ARCH
168 #undef LONG_DOUBLE_TYPE_SIZE
169 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
171 #undef CC1_SPEC
172 #if DEFAULT_ARCH32_P
173 #define CC1_SPEC CC1_SPEC32
174 #else
175 #define CC1_SPEC CC1_SPEC64
176 #endif
178 #if DEFAULT_ARCH32_P
179 #define MULTILIB_DEFAULTS { "m32" }
180 #else
181 #define MULTILIB_DEFAULTS { "m64" }
182 #endif
184 #else /* SPARC_BI_ARCH */
186 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
187 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
189 #undef LONG_DOUBLE_TYPE_SIZE
190 #define LONG_DOUBLE_TYPE_SIZE 128
192 #undef CC1_SPEC
193 #define CC1_SPEC CC1_SPEC64
195 #else /* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
196 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
198 /* A 32-bit only compiler. NetBSD don't support 128 bit `long double'
199 for 32-bit code, unlike Solaris. */
201 #undef LONG_DOUBLE_TYPE_SIZE
202 #define LONG_DOUBLE_TYPE_SIZE 64
204 #undef CC1_SPEC
205 #define CC1_SPEC CC1_SPEC32
207 #endif /* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
208 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */
210 #endif /* SPARC_BI_ARCH */
212 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
213 #undef CTORS_SECTION_ASM_OP
214 #undef DTORS_SECTION_ASM_OP