1 /* Definitions for PowerPC running FreeBSD using the ELF format
2 Copyright (C) 2001, 2003 Free Software Foundation, Inc.
3 Contributed by David E. O'Brien <obrien@FreeBSD.org> and BSDi.
5 This file is part of GCC.
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
9 by the Free Software Foundation; either version 2, or (at your
10 option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the
19 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
20 MA 02110-1301, USA. */
22 /* Override the defaults, which exist to force the proper definition. */
27 #define TARGET_64BIT 1
29 #define TARGET_64BIT 0
33 /* On 64-bit systems, use the AIX ABI like Linux and NetBSD */
36 #define DEFAULT_ABI (TARGET_64BIT ? ABI_AIX : ABI_V4)
38 #define TARGET_AIX TARGET_64BIT
40 #ifdef HAVE_LD_NO_DOT_SYMS
41 /* New ABI uses a local sym for the function entry point. */
42 extern int dot_symbols;
44 #define DOT_SYMBOLS dot_symbols
47 #undef FBSD_TARGET_CPU_CPP_BUILTINS
48 #define FBSD_TARGET_CPU_CPP_BUILTINS() \
51 builtin_define ("__PPC__"); \
52 builtin_define ("__ppc__"); \
53 builtin_define ("__PowerPC__"); \
54 builtin_define ("__powerpc__"); \
57 builtin_define ("__LP64__"); \
58 builtin_define ("__ppc64__"); \
59 builtin_define ("__powerpc64__"); \
60 builtin_define ("__arch64__"); \
61 builtin_assert ("cpu=powerpc64"); \
62 builtin_assert ("machine=powerpc64"); \
64 builtin_assert ("cpu=powerpc"); \
65 builtin_assert ("machine=powerpc"); \
70 #define INVALID_64BIT "-m%s not supported in this configuration"
71 #define INVALID_32BIT INVALID_64BIT
73 #undef SUBSUBTARGET_OVERRIDE_OPTIONS
74 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
77 if (!rs6000_explicit_options.alignment) \
78 rs6000_alignment_flags = MASK_ALIGN_NATURAL; \
81 if (DEFAULT_ABI != ABI_AIX) \
83 rs6000_current_abi = ABI_AIX; \
84 error (INVALID_64BIT, "call"); \
86 dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); \
87 if (target_flags & MASK_RELOCATABLE) \
89 target_flags &= ~MASK_RELOCATABLE; \
90 error (INVALID_64BIT, "relocatable"); \
92 if (target_flags & MASK_EABI) \
94 target_flags &= ~MASK_EABI; \
95 error (INVALID_64BIT, "eabi"); \
97 if (target_flags & MASK_PROTOTYPE) \
99 target_flags &= ~MASK_PROTOTYPE; \
100 error (INVALID_64BIT, "prototype"); \
102 if ((target_flags & MASK_POWERPC64) == 0) \
104 target_flags |= MASK_POWERPC64; \
105 error ("64 bit CPU required"); \
112 #undef STARTFILE_DEFAULT_SPEC
113 #define STARTFILE_DEFAULT_SPEC "%(startfile_freebsd)"
115 #undef ENDFILE_DEFAULT_SPEC
116 #define ENDFILE_DEFAULT_SPEC "%(endfile_freebsd)"
118 #undef LIB_DEFAULT_SPEC
119 #define LIB_DEFAULT_SPEC "%(lib_freebsd)"
121 #undef LINK_START_DEFAULT_SPEC
122 #define LINK_START_DEFAULT_SPEC "%(link_start_freebsd)"
124 #undef LINK_OS_DEFAULT_SPEC
125 #define LINK_OS_DEFAULT_SPEC "%(link_os_freebsd)"
127 /* XXX: This is wrong for many platforms in sysv4.h.
128 We should work on getting that definition fixed. */
129 #undef LINK_SHLIB_SPEC
130 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
133 /************************[ Target stuff ]***********************************/
135 /* Define the actual types of some ANSI-mandated types.
136 Needs to agree with <machine/ansi.h>. GCC defaults come from c-decl.c,
137 c-common.c, and config/<arch>/<arch>.h. */
140 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
143 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
145 /* rs6000.h gets this wrong for FreeBSD. We use the GCC defaults instead. */
148 #undef WCHAR_TYPE_SIZE
149 #define WCHAR_TYPE_SIZE 32
151 #undef TARGET_VERSION
152 #define TARGET_VERSION fprintf (stderr, " (FreeBSD/PowerPC ELF)");
154 /* Override rs6000.h definition. */
156 #define ASM_APP_ON "#APP\n"
158 /* Override rs6000.h definition. */
160 #define ASM_APP_OFF "#NO_APP\n"
162 /* Tell the assembler we want 32/64-bit binaries if -m32 or -m64 is passed */
163 #if (TARGET_DEFAULT & MASK_64BIT)
164 #define SVR4_ASM_SPEC "%(asm_cpu) \
165 %{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \
166 %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
167 %{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} \
168 %{memb|msdata|msdata=eabi: -memb} \
169 %{mlittle|mlittle-endian:-mlittle; \
170 mbig|mbig-endian :-mbig; \
177 mcall-i960-old :-mlittle}"
178 #define LINK_OS_FREEBSD_SPEC_DEF "\
179 %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \
181 %{assert*} %{R*} %{rpath*} %{defsym*} \
182 %{shared:-Bshareable %{h*} %{soname*}} \
183 %{!static:--enable-new-dtags} \
186 %{rdynamic: -export-dynamic} \
187 %{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} \
188 %{static:-Bstatic}} \
189 %{symbolic:-Bsymbolic}"
192 #undef ASM_DEFAULT_SPEC
194 #undef LINK_OS_FREEBSD_SPEC
195 #define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
196 #define ASM_SPEC "%{m32:-a32}%{!m32:-a64} " SVR4_ASM_SPEC
197 #define LINK_OS_FREEBSD_SPEC "%{m32:-melf32ppc_fbsd}%{!m32:-melf64ppc_fbsd} " LINK_OS_FREEBSD_SPEC_DEF
200 /* _init and _fini functions are built from bits spread across many
201 object files, each potentially with a different TOC pointer. For
202 that reason, place a nop after the call so that the linker can
203 restore the TOC pointer if a TOC adjusting call stub is needed. */
205 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
206 asm (SECTION_OP "\n" \
212 /* __throw will restore its own return address to be the same as the
213 return address of the function that the throw is being made to.
214 This is unfortunate, because we want to check the original
215 return address to see if we need to restore the TOC.
216 So we have to squirrel it away with this. */
217 #define SETUP_FRAME_ADDRESSES() \
218 do { if (TARGET_64BIT) rs6000_aix_emit_builtin_unwind_init (); } while (0)
220 /* Select a format to encode pointers in exception handling data. CODE
221 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
222 true if the symbol may be affected by dynamic relocations. */
223 #undef ASM_PREFERRED_EH_DATA_FORMAT
224 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
225 ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE) \
226 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
227 | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
231 #define MD_FROB_UPDATE_CONTEXT(CTX, FS) \
232 if ((FS)->regs.reg[2].how == REG_UNSAVED) \
234 unsigned int *insn = (unsigned int *) \
235 _Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM); \
236 if (insn != NULL && *insn == 0xE8410028) \
237 _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40); \
241 #define TARGET_ASM_FILE_END rs6000_elf_end_indicate_exec_stack
243 /* FreeBSD doesn't support saving and restoring 64-bit regs with a 32-bit
244 kernel. This is supported when running on a 64-bit kernel with
245 COMPAT_FREEBSD32, but tell GCC it isn't so that our 32-bit binaries
247 #define OS_MISSING_POWERPC64 !TARGET_64BIT
249 /* Function profiling bits */
251 #define RS6000_MCOUNT ((TARGET_64BIT) ? "._mcount" : "_mcount")
252 #define PROFILE_HOOK(LABEL) \
253 do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
255 #undef NEED_INDICATE_EXEC_STACK
256 #define NEED_INDICATE_EXEC_STACK 1
258 /* This is how to declare the size of a function. */
259 #undef ASM_DECLARE_FUNCTION_SIZE
260 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
263 if (!flag_inhibit_size_directive) \
265 fputs ("\t.size\t", (FILE)); \
266 if (TARGET_64BIT && DOT_SYMBOLS) \
267 putc ('.', (FILE)); \
268 assemble_name ((FILE), (FNAME)); \
269 fputs (",.-", (FILE)); \
270 rs6000_output_function_entry (FILE, FNAME); \
271 putc ('\n', (FILE)); \