]>
Commit | Line | Data |
---|---|---|
956d6950 | 1 | /* Definitions for rtems targeting a PowerPC using elf. |
a5544970 | 2 | Copyright (C) 1996-2019 Free Software Foundation, Inc. |
ae407704 DE |
3 | Contributed by Joel Sherrill (joel@OARcorp.com). |
4 | ||
5de601cf | 5 | This file is part of GCC. |
ae407704 | 6 | |
5de601cf NC |
7 | GCC is free software; you can redistribute it and/or modify it |
8 | under the terms of the GNU General Public License as published | |
2f83c7d6 | 9 | by the Free Software Foundation; either version 3, or (at your |
5de601cf | 10 | option) any later version. |
ae407704 | 11 | |
5de601cf NC |
12 | GCC is distributed in the hope that it will be useful, but WITHOUT |
13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | |
15 | License for more details. | |
ae407704 | 16 | |
99f08974 SH |
17 | Under Section 7 of GPL version 3, you are granted additional |
18 | permissions described in the GCC Runtime Library Exception, version | |
19 | 3.1, as published by the Free Software Foundation. | |
20 | ||
21 | You should have received a copy of the GNU General Public License and | |
22 | a copy of the GCC Runtime Library Exception along with this program; | |
23 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
2f83c7d6 | 24 | <http://www.gnu.org/licenses/>. */ |
ae407704 | 25 | |
16bab95a SH |
26 | /* Copy and paste from linux64.h and freebsd64.h */ |
27 | #ifdef IN_LIBGCC2 | |
28 | #undef TARGET_64BIT | |
29 | #ifdef __powerpc64__ | |
30 | #define TARGET_64BIT 1 | |
31 | #else | |
32 | #define TARGET_64BIT 0 | |
33 | #endif | |
34 | #endif | |
35 | ||
36 | /* Copy and paste from linux64.h and freebsd64.h */ | |
37 | #undef TARGET_AIX | |
38 | #define TARGET_AIX TARGET_64BIT | |
ae407704 | 39 | |
17691698 SH |
40 | /* Simplified copy and paste from linux64.h and freebsd64.h */ |
41 | #undef DOT_SYMBOLS | |
42 | #define DOT_SYMBOLS 0 | |
43 | ||
44 | /* Copy and paste from linux64.h and freebsd64.h */ | |
45 | #undef TARGET_CMODEL | |
46 | #define TARGET_CMODEL rs6000_current_cmodel | |
47 | #define SET_CMODEL(opt) rs6000_current_cmodel = opt | |
48 | ||
7990b46f | 49 | #undef TARGET_OS_CPP_BUILTINS |
16bab95a SH |
50 | #define TARGET_OS_CPP_BUILTINS() \ |
51 | do \ | |
52 | { \ | |
53 | builtin_define ("__rtems__"); \ | |
54 | builtin_define ("__USE_INIT_FINI__"); \ | |
55 | builtin_assert ("system=rtems"); \ | |
56 | if (TARGET_64BIT) \ | |
57 | { \ | |
58 | builtin_define ("__PPC__"); \ | |
59 | builtin_define ("__PPC64__"); \ | |
60 | builtin_define ("__powerpc64__"); \ | |
61 | builtin_assert ("cpu=powerpc64"); \ | |
62 | builtin_assert ("machine=powerpc64"); \ | |
63 | } \ | |
64 | else \ | |
65 | { \ | |
66 | builtin_define_std ("PPC"); \ | |
67 | builtin_define_std ("powerpc"); \ | |
68 | builtin_assert ("cpu=powerpc"); \ | |
69 | builtin_assert ("machine=powerpc"); \ | |
70 | TARGET_OS_SYSV_CPP_BUILTINS (); \ | |
71 | } \ | |
72 | } \ | |
73 | while (0) | |
74 | ||
17691698 SH |
75 | /* Copy and paste from linux64.h and freebsd64.h */ |
76 | #undef RELOCATABLE_NEEDS_FIXUP | |
77 | #define RELOCATABLE_NEEDS_FIXUP \ | |
78 | (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE) | |
79 | ||
80 | /* Copy and paste from linux64.h */ | |
81 | #undef RS6000_ABI_NAME | |
82 | #define RS6000_ABI_NAME "linux" | |
83 | ||
16bab95a SH |
84 | /* Copy and paste from linux64.h and freebsd64.h */ |
85 | #define INVALID_64BIT "-m%s not supported in this configuration" | |
86 | ||
87 | /* A lot of copy and paste from linux64.h and freebsd64.h */ | |
88 | #undef SUBSUBTARGET_OVERRIDE_OPTIONS | |
89 | #define SUBSUBTARGET_OVERRIDE_OPTIONS \ | |
90 | do \ | |
91 | { \ | |
92 | if (rs6000_isa_flags & OPTION_MASK_64BIT) \ | |
93 | { \ | |
94 | rs6000_elf_abi = 2; \ | |
95 | rs6000_current_abi = ABI_ELFv2; \ | |
96 | if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE) \ | |
97 | { \ | |
98 | rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \ | |
99 | error (INVALID_64BIT, "relocatable"); \ | |
100 | } \ | |
101 | if (rs6000_isa_flags & OPTION_MASK_EABI) \ | |
102 | { \ | |
103 | rs6000_isa_flags &= ~OPTION_MASK_EABI; \ | |
104 | error (INVALID_64BIT, "eabi"); \ | |
105 | } \ | |
106 | if (TARGET_PROTOTYPE) \ | |
107 | { \ | |
108 | target_prototype = 0; \ | |
109 | error (INVALID_64BIT, "prototype"); \ | |
110 | } \ | |
111 | if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0) \ | |
112 | { \ | |
113 | rs6000_isa_flags |= OPTION_MASK_POWERPC64; \ | |
114 | error ("-m64 requires a PowerPC64 cpu"); \ | |
115 | } \ | |
17691698 SH |
116 | if ((rs6000_isa_flags_explicit \ |
117 | & OPTION_MASK_MINIMAL_TOC) != 0) \ | |
118 | { \ | |
119 | if (global_options_set.x_rs6000_current_cmodel \ | |
120 | && rs6000_current_cmodel != CMODEL_SMALL) \ | |
121 | error ("-mcmodel incompatible with other toc options"); \ | |
122 | SET_CMODEL (CMODEL_SMALL); \ | |
123 | } \ | |
124 | else \ | |
125 | { \ | |
126 | if (!global_options_set.x_rs6000_current_cmodel) \ | |
127 | SET_CMODEL (CMODEL_MEDIUM); \ | |
128 | if (rs6000_current_cmodel != CMODEL_SMALL) \ | |
129 | { \ | |
130 | TARGET_NO_FP_IN_TOC = 0; \ | |
131 | TARGET_NO_SUM_IN_TOC = 0; \ | |
132 | } \ | |
133 | } \ | |
16bab95a SH |
134 | } \ |
135 | } \ | |
7990b46f | 136 | while (0) |
0186a143 | 137 | |
228c1313 SH |
138 | #undef TARGET_LIBGCC_SDATA_SECTION |
139 | #define TARGET_LIBGCC_SDATA_SECTION ".sdata" | |
140 | ||
16bab95a SH |
141 | /* Copy and paste from linux64.h and freebsd64.h */ |
142 | #undef SIZE_TYPE | |
143 | #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int") | |
144 | ||
145 | /* Copy and paste from linux64.h and freebsd64.h */ | |
146 | #undef PTRDIFF_TYPE | |
147 | #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int") | |
148 | ||
149 | /* Copy and paste from freebsd64.h */ | |
150 | #undef WCHAR_TYPE | |
151 | ||
152 | /* Copy and paste from freebsd64.h */ | |
153 | #undef WCHAR_TYPE_SIZE | |
154 | #define WCHAR_TYPE_SIZE 32 | |
155 | ||
156 | /* Copy and paste from linux64.h and freebsd64.h */ | |
157 | #ifdef __powerpc64__ | |
158 | #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ | |
159 | asm (SECTION_OP "\n" \ | |
160 | " bl " #FUNC "\n" \ | |
161 | " nop\n" \ | |
162 | " .previous"); | |
163 | #endif | |
164 | ||
165 | /* This could be also POWERPC_FREEBSD. It is related to the save/restore | |
166 | defines below. */ | |
167 | #define POWERPC_LINUX | |
168 | ||
169 | /* Copy and paste from linux64.h and freebsd64.h */ | |
170 | #undef SAVE_FP_PREFIX | |
171 | #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_") | |
172 | #undef SAVE_FP_SUFFIX | |
173 | #define SAVE_FP_SUFFIX "" | |
174 | #undef RESTORE_FP_PREFIX | |
175 | #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_") | |
176 | #undef RESTORE_FP_SUFFIX | |
177 | #define RESTORE_FP_SUFFIX "" | |
b9d13999 | 178 | |
17691698 SH |
179 | /* Copy and paste from linux64.h and freebsd64.h */ |
180 | #undef ASM_PREFERRED_EH_DATA_FORMAT | |
181 | #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ | |
182 | (TARGET_64BIT || flag_pic \ | |
183 | ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \ | |
184 | | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \ | |
185 | : DW_EH_PE_absptr) | |
186 | ||
187 | /* Copy and paste from linux64.h and freebsd64.h */ | |
188 | #undef TOC_SECTION_ASM_OP | |
189 | #define TOC_SECTION_ASM_OP \ | |
190 | (TARGET_64BIT \ | |
191 | ? "\t.section\t\".toc\",\"aw\"" \ | |
192 | : "\t.section\t\".got\",\"aw\"") | |
193 | ||
194 | /* Copy and paste from linux64.h and freebsd64.h */ | |
195 | #undef MINIMAL_TOC_SECTION_ASM_OP | |
196 | #define MINIMAL_TOC_SECTION_ASM_OP \ | |
197 | (TARGET_64BIT \ | |
198 | ? "\t.section\t\".toc1\",\"aw\"" \ | |
199 | : (flag_pic \ | |
200 | ? "\t.section\t\".got2\",\"aw\"" \ | |
201 | : "\t.section\t\".got1\",\"aw\"")) | |
202 | ||
16bab95a SH |
203 | /* Copy and paste from linux64.h and freebsd64.h */ |
204 | #undef ASM_DECLARE_FUNCTION_SIZE | |
205 | #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ | |
206 | do \ | |
207 | { \ | |
208 | if (!flag_inhibit_size_directive) \ | |
209 | { \ | |
210 | fputs ("\t.size\t", (FILE)); \ | |
211 | if (TARGET_64BIT && DOT_SYMBOLS) \ | |
212 | putc ('.', (FILE)); \ | |
213 | assemble_name ((FILE), (FNAME)); \ | |
214 | fputs (",.-", (FILE)); \ | |
215 | rs6000_output_function_entry (FILE, FNAME); \ | |
216 | putc ('\n', (FILE)); \ | |
217 | } \ | |
218 | } \ | |
219 | while (0) | |
220 | ||
221 | /* Copy and paste from linux64.h and freebsd64.h */ | |
222 | #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P | |
223 | #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \ | |
224 | (TARGET_TOC \ | |
225 | && (GET_CODE (X) == SYMBOL_REF \ | |
226 | || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \ | |
227 | && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \ | |
228 | || GET_CODE (X) == LABEL_REF \ | |
229 | || (GET_CODE (X) == CONST_INT \ | |
230 | && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \ | |
231 | || (GET_CODE (X) == CONST_DOUBLE \ | |
232 | && ((TARGET_64BIT \ | |
233 | && (TARGET_MINIMAL_TOC \ | |
234 | || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \ | |
235 | && ! TARGET_NO_FP_IN_TOC))) \ | |
236 | || (!TARGET_64BIT \ | |
237 | && !TARGET_NO_FP_IN_TOC \ | |
238 | && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \ | |
239 | && BITS_PER_WORD == HOST_BITS_PER_INT))))) | |
240 | ||
241 | #undef CPP_OS_DEFAULT_SPEC | |
242 | #define CPP_OS_DEFAULT_SPEC "\ | |
b9d13999 RC |
243 | %{!mcpu*: %{!Dppc*: %{!Dmpc*: -Dmpc750} } }\ |
244 | %{mcpu=403: %{!Dppc*: %{!Dmpc*: -Dppc403} } } \ | |
245 | %{mcpu=505: %{!Dppc*: %{!Dmpc*: -Dmpc505} } } \ | |
246 | %{mcpu=601: %{!Dppc*: %{!Dmpc*: -Dppc601} } } \ | |
247 | %{mcpu=602: %{!Dppc*: %{!Dmpc*: -Dppc602} } } \ | |
248 | %{mcpu=603: %{!Dppc*: %{!Dmpc*: -Dppc603} } } \ | |
249 | %{mcpu=603e: %{!Dppc*: %{!Dmpc*: -Dppc603e} } } \ | |
250 | %{mcpu=604: %{!Dppc*: %{!Dmpc*: -Dmpc604} } } \ | |
251 | %{mcpu=750: %{!Dppc*: %{!Dmpc*: -Dmpc750} } } \ | |
252 | %{mcpu=821: %{!Dppc*: %{!Dmpc*: -Dmpc821} } } \ | |
bce15ee8 | 253 | %{mcpu=860: %{!Dppc*: %{!Dmpc*: -Dmpc860} } } \ |
887974fd SH |
254 | %{mcpu=8540: %{!Dppc*: %{!Dmpc*: -Dppc8540} } } \ |
255 | %{mcpu=e6500: -D__PPC_CPU_E6500__}" | |
b9d13999 | 256 | |
16bab95a SH |
257 | #undef ASM_DEFAULT_SPEC |
258 | #define ASM_DEFAULT_SPEC "-mppc%{m64:64}" | |
259 | ||
260 | #undef ASM_SPEC | |
261 | #define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)" | |
262 | ||
263 | #define ASM_SPEC32 "-a32 \ | |
264 | %{mrelocatable} %{mrelocatable-lib} %{" FPIE_OR_FPIC_SPEC ":-K PIC} \ | |
265 | %{memb|msdata=eabi: -memb}" | |
266 | ||
267 | #define ASM_SPEC64 "-a64" | |
268 | ||
269 | #define ASM_SPEC_COMMON "%(asm_cpu) \ | |
270 | %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}}" \ | |
271 | ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) | |
272 | ||
273 | #undef LINK_OS_DEFAULT_SPEC | |
274 | #define LINK_OS_DEFAULT_SPEC \ | |
275 | "%{!m64:%(link_os_spec32)}%{m64:%(link_os_spec64)}" | |
276 | ||
277 | #define LINK_OS_SPEC32 ENDIAN_SELECT(" -m elf32ppc", \ | |
278 | " -m elf32lppc", \ | |
279 | " -m elf32ppc") | |
280 | #define LINK_OS_SPEC64 ENDIAN_SELECT(" -m elf64ppc", \ | |
281 | " -m elf64lppc", \ | |
282 | " -m elf64ppc") | |
283 | ||
b9d13999 RC |
284 | #undef SUBSUBTARGET_EXTRA_SPECS |
285 | #define SUBSUBTARGET_EXTRA_SPECS \ | |
16bab95a SH |
286 | { "asm_spec_common", ASM_SPEC_COMMON }, \ |
287 | { "asm_spec32", ASM_SPEC32 }, \ | |
288 | { "asm_spec64", ASM_SPEC64 }, \ | |
289 | { "link_os_spec32", LINK_OS_SPEC32 }, \ | |
290 | { "link_os_spec64", LINK_OS_SPEC64 }, | |
62045234 AM |
291 | |
292 | /* Use gnu-user.h LINK_GCC_SEQUENCE_SPEC for rtems. */ | |
293 | #undef LINK_GCC_C_SEQUENCE_SPEC | |
294 | #define LINK_GCC_C_SEQUENCE_SPEC \ | |
295 | "%{mads|myellowknife|mmvme|msim:%G %L %G;" \ | |
296 | "!mcall-*|mcall-linux:" GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC ";" \ | |
297 | ":%G %L %G}" |