111
|
1 /* Definitions for 64-bit PowerPC running FreeBSD using the ELF format
|
145
|
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
|
111
|
3
|
|
4 This file is part of GCC.
|
|
5
|
|
6 GCC is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published
|
|
8 by the Free Software Foundation; either version 3, or (at your
|
|
9 option) any later version.
|
|
10
|
|
11 GCC is distributed in the hope that it will be useful, but WITHOUT
|
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
14 License for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with GCC; see the file COPYING3. If not see
|
|
18 <http://www.gnu.org/licenses/>. */
|
|
19
|
145
|
20 /* Undef gnu-user.h macros we don't want. */
|
|
21 #undef CPLUSPLUS_CPP_SPEC
|
|
22 #undef LINK_GCC_C_SEQUENCE_SPEC
|
|
23
|
111
|
24 /* Override the defaults, which exist to force the proper definition. */
|
|
25
|
|
26 #ifdef IN_LIBGCC2
|
|
27 #undef TARGET_64BIT
|
|
28 #ifdef __powerpc64__
|
|
29 #define TARGET_64BIT 1
|
|
30 #else
|
|
31 #define TARGET_64BIT 0
|
|
32 #endif
|
|
33 #endif
|
|
34
|
|
35 #undef TARGET_AIX
|
|
36 #define TARGET_AIX TARGET_64BIT
|
|
37
|
|
38 #ifdef HAVE_LD_NO_DOT_SYMS
|
|
39 /* New ABI uses a local sym for the function entry point. */
|
|
40 extern int dot_symbols;
|
|
41 #undef DOT_SYMBOLS
|
|
42 #define DOT_SYMBOLS dot_symbols
|
|
43 #endif
|
|
44
|
|
45 #define TARGET_USES_LINUX64_OPT 1
|
|
46 #ifdef HAVE_LD_LARGE_TOC
|
|
47 #undef TARGET_CMODEL
|
|
48 #define TARGET_CMODEL rs6000_current_cmodel
|
|
49 #define SET_CMODEL(opt) rs6000_current_cmodel = opt
|
|
50 #else
|
|
51 #define SET_CMODEL(opt) do {} while (0)
|
|
52 #endif
|
|
53
|
|
54 /* Until now the 970 is the only Processor where FreeBSD 64-bit runs on. */
|
|
55 #undef PROCESSOR_DEFAULT
|
|
56 #define PROCESSOR_DEFAULT PROCESSOR_POWER4
|
|
57 #undef PROCESSOR_DEFAULT64
|
|
58 #define PROCESSOR_DEFAULT64 PROCESSOR_POWER4
|
|
59
|
|
60 /* We don't need to generate entries in .fixup, except when
|
|
61 -mrelocatable or -mrelocatable-lib is given. */
|
|
62 #undef RELOCATABLE_NEEDS_FIXUP
|
|
63 #define RELOCATABLE_NEEDS_FIXUP \
|
|
64 (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE)
|
|
65
|
|
66 #undef RS6000_ABI_NAME
|
|
67 #define RS6000_ABI_NAME "freebsd"
|
|
68
|
|
69 #define INVALID_64BIT "-m%s not supported in this configuration"
|
|
70 #define INVALID_32BIT INVALID_64BIT
|
|
71
|
|
72 /* Use LINUX64 instead of FREEBSD64 for compat with e.g. sysv4le.h */
|
|
73 #ifdef LINUX64_DEFAULT_ABI_ELFv2
|
|
74 #define ELFv2_ABI_CHECK (rs6000_elf_abi != 1)
|
|
75 #else
|
|
76 #define ELFv2_ABI_CHECK (rs6000_elf_abi == 2)
|
|
77 #endif
|
|
78
|
|
79 #undef SUBSUBTARGET_OVERRIDE_OPTIONS
|
|
80 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
|
|
81 do \
|
|
82 { \
|
|
83 if (!global_options_set.x_rs6000_alignment_flags) \
|
|
84 rs6000_alignment_flags = MASK_ALIGN_NATURAL; \
|
|
85 if (TARGET_64BIT) \
|
|
86 { \
|
|
87 if (DEFAULT_ABI != ABI_AIX) \
|
|
88 { \
|
|
89 rs6000_current_abi = ABI_AIX; \
|
|
90 error (INVALID_64BIT, "call"); \
|
|
91 } \
|
|
92 dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); \
|
|
93 if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE) \
|
|
94 { \
|
|
95 rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \
|
|
96 error (INVALID_64BIT, "relocatable"); \
|
|
97 } \
|
|
98 if (ELFv2_ABI_CHECK) \
|
|
99 { \
|
|
100 rs6000_current_abi = ABI_ELFv2; \
|
|
101 if (dot_symbols) \
|
145
|
102 error ("%<-mcall-aixdesc%> incompatible with %<-mabi=elfv2%>"); \
|
111
|
103 } \
|
|
104 if (rs6000_isa_flags & OPTION_MASK_EABI) \
|
|
105 { \
|
|
106 rs6000_isa_flags &= ~OPTION_MASK_EABI; \
|
|
107 error (INVALID_64BIT, "eabi"); \
|
|
108 } \
|
|
109 if (TARGET_PROTOTYPE) \
|
|
110 { \
|
|
111 target_prototype = 0; \
|
|
112 error (INVALID_64BIT, "prototype"); \
|
|
113 } \
|
|
114 if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0) \
|
|
115 { \
|
|
116 rs6000_isa_flags |= OPTION_MASK_POWERPC64; \
|
145
|
117 error ("%<-m64%> requires a PowerPC64 cpu"); \
|
111
|
118 } \
|
|
119 if ((rs6000_isa_flags_explicit \
|
|
120 & OPTION_MASK_MINIMAL_TOC) != 0) \
|
|
121 { \
|
|
122 if (global_options_set.x_rs6000_current_cmodel \
|
|
123 && rs6000_current_cmodel != CMODEL_SMALL) \
|
145
|
124 error ("%<-mcmodel%> incompatible with other toc options"); \
|
111
|
125 SET_CMODEL (CMODEL_SMALL); \
|
|
126 } \
|
|
127 else \
|
|
128 { \
|
|
129 if (!global_options_set.x_rs6000_current_cmodel) \
|
|
130 SET_CMODEL (CMODEL_MEDIUM); \
|
|
131 if (rs6000_current_cmodel != CMODEL_SMALL) \
|
|
132 { \
|
|
133 TARGET_NO_FP_IN_TOC = 0; \
|
|
134 TARGET_NO_SUM_IN_TOC = 0; \
|
|
135 } \
|
|
136 } \
|
|
137 } \
|
|
138 } \
|
|
139 while (0)
|
|
140
|
|
141 #undef ASM_SPEC
|
|
142 #undef LINK_OS_FREEBSD_SPEC
|
|
143
|
|
144 #define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
|
|
145 #define LINK_OS_FREEBSD_SPEC "%{m32:%(link_os_freebsd_spec32)}%{!m32:%(link_os_freebsd_spec64)}"
|
|
146
|
|
147 #define ASM_SPEC32 "-a32 \
|
|
148 %{mrelocatable} %{mrelocatable-lib} %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
|
|
149 %{memb} %{!memb: %{msdata=eabi: -memb}} \
|
|
150 %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
|
|
151 %{mcall-freebsd: -mbig} \
|
|
152 %{mcall-i960-old: -mlittle} \
|
|
153 %{mcall-linux: -mbig} \
|
|
154 %{mcall-gnu: -mbig} \
|
|
155 %{mcall-netbsd: -mbig} \
|
|
156 }}}}"
|
|
157
|
|
158 #define ASM_SPEC64 "-a64"
|
|
159
|
|
160 #define ASM_SPEC_COMMON "%(asm_cpu) \
|
|
161 %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}} \
|
|
162 %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian}"
|
|
163
|
|
164 #undef SUBSUBTARGET_EXTRA_SPECS
|
|
165 #define SUBSUBTARGET_EXTRA_SPECS \
|
|
166 { "asm_spec_common", ASM_SPEC_COMMON }, \
|
|
167 { "asm_spec32", ASM_SPEC32 }, \
|
|
168 { "asm_spec64", ASM_SPEC64 }, \
|
|
169 { "link_os_freebsd_spec32", LINK_OS_FREEBSD_SPEC32 }, \
|
|
170 { "link_os_freebsd_spec64", LINK_OS_FREEBSD_SPEC64 },
|
|
171
|
|
172 #define LINK_OS_FREEBSD_SPEC_DEF "\
|
|
173 %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \
|
|
174 %{v:-V} \
|
|
175 %{assert*} %{R*} %{rpath*} %{defsym*} \
|
|
176 %{shared:-Bshareable %{h*} %{soname*}} \
|
|
177 %{!shared: \
|
|
178 %{!static: \
|
|
179 %{rdynamic: -export-dynamic} \
|
|
180 %{!dynamic-linker:-dynamic-linker " FBSD_DYNAMIC_LINKER "}} \
|
|
181 %{static:-Bstatic}} \
|
|
182 %{symbolic:-Bsymbolic}"
|
|
183
|
|
184 #define LINK_OS_FREEBSD_SPEC32 "-melf32ppc_fbsd " LINK_OS_FREEBSD_SPEC_DEF
|
|
185
|
|
186 #define LINK_OS_FREEBSD_SPEC64 "-melf64ppc_fbsd " LINK_OS_FREEBSD_SPEC_DEF
|
|
187
|
|
188 #undef MULTILIB_DEFAULTS
|
|
189 #define MULTILIB_DEFAULTS { "m64" }
|
|
190
|
|
191 /* PowerPC-64 FreeBSD increases natural record alignment to doubleword if
|
|
192 the first field is an FP double, only if in power alignment mode. */
|
|
193 #undef ROUND_TYPE_ALIGN
|
|
194 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
|
|
195 ((TARGET_64BIT \
|
|
196 && (TREE_CODE (STRUCT) == RECORD_TYPE \
|
|
197 || TREE_CODE (STRUCT) == UNION_TYPE \
|
|
198 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
|
|
199 && TARGET_ALIGN_NATURAL == 0) \
|
|
200 ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
|
|
201 : MAX ((COMPUTED), (SPECIFIED)))
|
|
202
|
|
203 /* Use the default for compiling target libs. */
|
|
204 #ifdef IN_TARGET_LIBS
|
|
205 #undef TARGET_ALIGN_NATURAL
|
|
206 #define TARGET_ALIGN_NATURAL 1
|
|
207 #endif
|
|
208
|
|
209 /* Indicate that jump tables go in the text section. */
|
|
210 #undef JUMP_TABLES_IN_TEXT_SECTION
|
|
211 #define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT
|
|
212
|
|
213 /* The linux ppc64 ABI isn't explicit on whether aggregates smaller
|
|
214 than a doubleword should be padded upward or downward. You could
|
|
215 reasonably assume that they follow the normal rules for structure
|
|
216 layout treating the parameter area as any other block of memory,
|
|
217 then map the reg param area to registers. i.e. pad upward.
|
|
218 Setting both of the following defines results in this behavior.
|
|
219 Setting just the first one will result in aggregates that fit in a
|
|
220 doubleword being padded downward, and others being padded upward.
|
|
221 Not a bad idea as this results in struct { int x; } being passed
|
|
222 the same way as an int. */
|
|
223 #define AGGREGATE_PADDING_FIXED TARGET_64BIT
|
|
224 #define AGGREGATES_PAD_UPWARD_ALWAYS 0
|
|
225
|
|
226 /* Specify padding for the last element of a block move between
|
|
227 registers and memory. FIRST is nonzero if this is the only
|
|
228 element. */
|
|
229 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
|
|
230 (!(FIRST) ? PAD_UPWARD : targetm.calls.function_arg_padding (MODE, TYPE))
|
|
231
|
|
232 /* FreeBSD doesn't support saving and restoring 64-bit regs with a 32-bit
|
|
233 kernel. This is supported when running on a 64-bit kernel with
|
|
234 COMPAT_FREEBSD32, but tell GCC it isn't so that our 32-bit binaries
|
|
235 are compatible. */
|
|
236 #define OS_MISSING_POWERPC64 !TARGET_64BIT
|
|
237
|
|
238 #undef FBSD_TARGET_CPU_CPP_BUILTINS
|
|
239 #define FBSD_TARGET_CPU_CPP_BUILTINS() \
|
|
240 do \
|
|
241 { \
|
|
242 builtin_define ("__PPC__"); \
|
|
243 builtin_define ("__ppc__"); \
|
|
244 builtin_define ("__powerpc__"); \
|
|
245 if (TARGET_64BIT) \
|
|
246 { \
|
|
247 builtin_define ("__arch64__"); \
|
|
248 builtin_define ("__LP64__"); \
|
|
249 builtin_define ("__PPC64__"); \
|
|
250 builtin_define ("__powerpc64__"); \
|
|
251 builtin_assert ("cpu=powerpc64"); \
|
|
252 builtin_assert ("machine=powerpc64"); \
|
|
253 } \
|
|
254 else \
|
|
255 { \
|
|
256 builtin_define_std ("PPC"); \
|
|
257 builtin_define_std ("powerpc"); \
|
|
258 builtin_assert ("cpu=powerpc"); \
|
|
259 builtin_assert ("machine=powerpc"); \
|
|
260 TARGET_OS_SYSV_CPP_BUILTINS (); \
|
|
261 } \
|
|
262 } \
|
|
263 while (0)
|
|
264
|
|
265 #undef CPP_OS_DEFAULT_SPEC
|
|
266 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_freebsd)"
|
|
267
|
|
268 #undef CPP_OS_FREEBSD_SPEC
|
|
269 #define CPP_OS_FREEBSD_SPEC ""
|
|
270
|
|
271 #undef STARTFILE_DEFAULT_SPEC
|
|
272 #define STARTFILE_DEFAULT_SPEC "%(startfile_freebsd)"
|
|
273
|
|
274 #undef ENDFILE_DEFAULT_SPEC
|
|
275 #define ENDFILE_DEFAULT_SPEC "%(endfile_freebsd)"
|
|
276
|
|
277 #undef LIB_DEFAULT_SPEC
|
|
278 #define LIB_DEFAULT_SPEC "%(lib_freebsd)"
|
|
279
|
|
280 #undef LINK_START_DEFAULT_SPEC
|
|
281 #define LINK_START_DEFAULT_SPEC "%(link_start_freebsd)"
|
|
282
|
|
283 #undef LINK_OS_DEFAULT_SPEC
|
|
284 #define LINK_OS_DEFAULT_SPEC "%(link_os_freebsd)"
|
|
285
|
|
286 /* XXX: This is wrong for many platforms in sysv4.h.
|
|
287 We should work on getting that definition fixed. */
|
|
288 #undef LINK_SHLIB_SPEC
|
|
289 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
|
|
290
|
|
291
|
|
292 /************************[ Target stuff ]***********************************/
|
|
293
|
|
294 /* Define the actual types of some ANSI-mandated types.
|
|
295 Needs to agree with <machine/ansi.h>. GCC defaults come from c-decl.c,
|
|
296 c-common.c, and config/<arch>/<arch>.h. */
|
|
297
|
|
298
|
|
299 #undef SIZE_TYPE
|
|
300 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
|
|
301
|
|
302 #undef PTRDIFF_TYPE
|
|
303 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
|
|
304
|
|
305 /* rs6000.h gets this wrong for FreeBSD. We use the GCC defaults instead. */
|
|
306 #undef WCHAR_TYPE
|
|
307
|
|
308 #undef WCHAR_TYPE_SIZE
|
|
309 #define WCHAR_TYPE_SIZE 32
|
|
310
|
|
311 /* Function profiling bits */
|
|
312 #undef RS6000_MCOUNT
|
|
313 #define RS6000_MCOUNT "_mcount"
|
|
314
|
|
315 #define PROFILE_HOOK(LABEL) \
|
|
316 do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
|
|
317
|
|
318 /* _init and _fini functions are built from bits spread across many
|
|
319 object files, each potentially with a different TOC pointer. For
|
|
320 that reason, place a nop after the call so that the linker can
|
|
321 restore the TOC pointer if a TOC adjusting call stub is needed. */
|
|
322 #ifdef __powerpc64__
|
|
323 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
|
|
324 asm (SECTION_OP "\n" \
|
|
325 " bl " #FUNC "\n" \
|
|
326 " nop\n" \
|
|
327 " .previous");
|
|
328 #endif
|
|
329
|
|
330 /* FP save and restore routines. */
|
|
331 #undef SAVE_FP_PREFIX
|
|
332 #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
|
|
333 #undef SAVE_FP_SUFFIX
|
|
334 #define SAVE_FP_SUFFIX ""
|
|
335 #undef RESTORE_FP_PREFIX
|
|
336 #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
|
|
337 #undef RESTORE_FP_SUFFIX
|
|
338 #define RESTORE_FP_SUFFIX ""
|
|
339
|
|
340 /* Select a format to encode pointers in exception handling data. CODE
|
|
341 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
|
|
342 true if the symbol may be affected by dynamic relocations. */
|
|
343 #undef ASM_PREFERRED_EH_DATA_FORMAT
|
|
344 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
|
|
345 (TARGET_64BIT || flag_pic \
|
|
346 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
|
|
347 | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
|
|
348 : DW_EH_PE_absptr)
|
|
349
|
|
350 /* Static stack checking is supported by means of probes. */
|
|
351 #define STACK_CHECK_STATIC_BUILTIN 1
|
|
352
|
|
353 /* The default value isn't sufficient in 64-bit mode. */
|
|
354 #define STACK_CHECK_PROTECT (TARGET_64BIT ? 16 * 1024 : 12 * 1024)
|
|
355
|
|
356 /* Use standard DWARF numbering for DWARF debugging information. */
|
|
357 #define RS6000_USE_DWARF_NUMBERING
|
|
358
|
|
359 /* PowerPC64 Linux word-aligns FP doubles when -malign-power is given. */
|
|
360 #undef ADJUST_FIELD_ALIGN
|
|
361 #define ADJUST_FIELD_ALIGN(FIELD, TYPE, COMPUTED) \
|
|
362 (rs6000_special_adjust_field_align_p ((TYPE), (COMPUTED)) \
|
|
363 ? 128 \
|
|
364 : (TARGET_64BIT \
|
|
365 && TARGET_ALIGN_NATURAL == 0 \
|
|
366 && TYPE_MODE (strip_array_types (TYPE)) == DFmode) \
|
|
367 ? MIN ((COMPUTED), 32) \
|
|
368 : (COMPUTED))
|
|
369
|
|
370 #undef TOC_SECTION_ASM_OP
|
|
371 #define TOC_SECTION_ASM_OP \
|
|
372 (TARGET_64BIT \
|
|
373 ? "\t.section\t\".toc\",\"aw\"" \
|
|
374 : "\t.section\t\".got\",\"aw\"")
|
|
375
|
|
376 #undef MINIMAL_TOC_SECTION_ASM_OP
|
|
377 #define MINIMAL_TOC_SECTION_ASM_OP \
|
|
378 (TARGET_64BIT \
|
|
379 ? "\t.section\t\".toc1\",\"aw\"" \
|
|
380 : (flag_pic \
|
|
381 ? "\t.section\t\".got2\",\"aw\"" \
|
|
382 : "\t.section\t\".got1\",\"aw\""))
|
|
383
|
|
384 /* This is how to declare the size of a function. */
|
|
385 #undef ASM_DECLARE_FUNCTION_SIZE
|
|
386 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
|
|
387 do \
|
|
388 { \
|
|
389 if (!flag_inhibit_size_directive) \
|
|
390 { \
|
|
391 fputs ("\t.size\t", (FILE)); \
|
|
392 if (TARGET_64BIT && DOT_SYMBOLS) \
|
|
393 putc ('.', (FILE)); \
|
|
394 assemble_name ((FILE), (FNAME)); \
|
|
395 fputs (",.-", (FILE)); \
|
|
396 rs6000_output_function_entry (FILE, FNAME); \
|
|
397 putc ('\n', (FILE)); \
|
|
398 } \
|
|
399 } \
|
|
400 while (0)
|
|
401
|
|
402 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
|
|
403 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
|
|
404 (TARGET_TOC \
|
145
|
405 && (SYMBOL_REF_P (X) \
|
111
|
406 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
|
145
|
407 && SYMBOL_REF_P (XEXP (XEXP (X, 0), 0))) \
|
111
|
408 || GET_CODE (X) == LABEL_REF \
|
145
|
409 || (CONST_INT_P (X) \
|
111
|
410 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
|
145
|
411 || (CONST_DOUBLE_P (X) \
|
111
|
412 && ((TARGET_64BIT \
|
|
413 && (TARGET_MINIMAL_TOC \
|
|
414 || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
|
|
415 && ! TARGET_NO_FP_IN_TOC))) \
|
|
416 || (!TARGET_64BIT \
|
|
417 && !TARGET_NO_FP_IN_TOC \
|
|
418 && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
|
|
419 && BITS_PER_WORD == HOST_BITS_PER_INT)))))
|
|
420
|
|
421 /* Use --as-needed -lgcc_s for eh support. */
|
|
422 #ifdef HAVE_LD_AS_NEEDED
|
|
423 #define USE_LD_AS_NEEDED 1
|
|
424 #endif
|
|
425
|
|
426 #define POWERPC_FREEBSD
|