freebsd.h revision 217396
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. 4 5 This file is part of GCC. 6 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. 11 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. 16 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. */ 21 22/* Override the defaults, which exist to force the proper definition. */ 23 24#ifdef IN_LIBGCC2 25#undef TARGET_64BIT 26#ifdef __powerpc64__ 27#define TARGET_64BIT 1 28#else 29#define TARGET_64BIT 0 30#endif 31#endif 32 33/* On 64-bit systems, use the AIX ABI like Linux and NetBSD */ 34 35#undef DEFAULT_ABI 36#define DEFAULT_ABI (TARGET_64BIT ? ABI_AIX : ABI_V4) 37#undef TARGET_AIX 38#define TARGET_AIX TARGET_64BIT 39 40#undef FBSD_TARGET_CPU_CPP_BUILTINS 41#define FBSD_TARGET_CPU_CPP_BUILTINS() \ 42 do \ 43 { \ 44 builtin_define ("__PPC__"); \ 45 builtin_define ("__ppc__"); \ 46 builtin_define ("__PowerPC__"); \ 47 builtin_define ("__powerpc__"); \ 48 if (TARGET_64BIT) \ 49 { \ 50 builtin_define ("__LP64__"); \ 51 builtin_define ("__ppc64__"); \ 52 builtin_define ("__powerpc64__"); \ 53 builtin_define ("__arch64__"); \ 54 builtin_assert ("cpu=powerpc64"); \ 55 builtin_assert ("machine=powerpc64"); \ 56 } else { \ 57 builtin_assert ("cpu=powerpc"); \ 58 builtin_assert ("machine=powerpc"); \ 59 } \ 60 } \ 61 while (0) 62 63#define INVALID_64BIT "-m%s not supported in this configuration" 64#define INVALID_32BIT INVALID_64BIT 65 66#undef SUBSUBTARGET_OVERRIDE_OPTIONS 67#define SUBSUBTARGET_OVERRIDE_OPTIONS \ 68 do \ 69 { \ 70 if (!rs6000_explicit_options.alignment) \ 71 rs6000_alignment_flags = MASK_ALIGN_NATURAL; \ 72 if (TARGET_64BIT) \ 73 { \ 74 if (DEFAULT_ABI != ABI_AIX) \ 75 { \ 76 rs6000_current_abi = ABI_AIX; \ 77 error (INVALID_64BIT, "call"); \ 78 } \ 79 dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); \ 80 if (target_flags & MASK_RELOCATABLE) \ 81 { \ 82 target_flags &= ~MASK_RELOCATABLE; \ 83 error (INVALID_64BIT, "relocatable"); \ 84 } \ 85 if (target_flags & MASK_EABI) \ 86 { \ 87 target_flags &= ~MASK_EABI; \ 88 error (INVALID_64BIT, "eabi"); \ 89 } \ 90 if (target_flags & MASK_PROTOTYPE) \ 91 { \ 92 target_flags &= ~MASK_PROTOTYPE; \ 93 error (INVALID_64BIT, "prototype"); \ 94 } \ 95 if ((target_flags & MASK_POWERPC64) == 0) \ 96 { \ 97 target_flags |= MASK_POWERPC64; \ 98 error ("64 bit CPU required"); \ 99 } \ 100 } \ 101 } \ 102 while (0) 103 104 105#undef STARTFILE_DEFAULT_SPEC 106#define STARTFILE_DEFAULT_SPEC "%(startfile_freebsd)" 107 108#undef ENDFILE_DEFAULT_SPEC 109#define ENDFILE_DEFAULT_SPEC "%(endfile_freebsd)" 110 111#undef LIB_DEFAULT_SPEC 112#define LIB_DEFAULT_SPEC "%(lib_freebsd)" 113 114#undef LINK_START_DEFAULT_SPEC 115#define LINK_START_DEFAULT_SPEC "%(link_start_freebsd)" 116 117#undef LINK_OS_DEFAULT_SPEC 118#define LINK_OS_DEFAULT_SPEC "%(link_os_freebsd)" 119 120/* XXX: This is wrong for many platforms in sysv4.h. 121 We should work on getting that definition fixed. */ 122#undef LINK_SHLIB_SPEC 123#define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}" 124 125 126/************************[ Target stuff ]***********************************/ 127 128/* Define the actual types of some ANSI-mandated types. 129 Needs to agree with <machine/ansi.h>. GCC defaults come from c-decl.c, 130 c-common.c, and config/<arch>/<arch>.h. */ 131 132#undef SIZE_TYPE 133#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int") 134 135#undef PTRDIFF_TYPE 136#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int") 137 138/* rs6000.h gets this wrong for FreeBSD. We use the GCC defaults instead. */ 139#undef WCHAR_TYPE 140 141#undef WCHAR_TYPE_SIZE 142#define WCHAR_TYPE_SIZE 32 143 144#undef TARGET_VERSION 145#define TARGET_VERSION fprintf (stderr, " (FreeBSD/PowerPC ELF)"); 146 147/* Override rs6000.h definition. */ 148#undef ASM_APP_ON 149#define ASM_APP_ON "#APP\n" 150 151/* Override rs6000.h definition. */ 152#undef ASM_APP_OFF 153#define ASM_APP_OFF "#NO_APP\n" 154 155/* Tell the assembler we want 32/64-bit binaries if -m32 or -m64 is passed */ 156#if (TARGET_DEFAULT & MASK_64BIT) 157#define SVR4_ASM_SPEC "%(asm_cpu) \ 158%{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \ 159%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \ 160%{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} \ 161%{memb|msdata|msdata=eabi: -memb} \ 162%{mlittle|mlittle-endian:-mlittle; \ 163 mbig|mbig-endian :-mbig; \ 164 mcall-aixdesc | \ 165 mcall-freebsd | \ 166 mcall-netbsd | \ 167 mcall-openbsd | \ 168 mcall-linux | \ 169 mcall-gnu :-mbig; \ 170 mcall-i960-old :-mlittle}" 171#define LINK_OS_FREEBSD_SPEC_DEF "\ 172 %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \ 173 %{v:-V} \ 174 %{assert*} %{R*} %{rpath*} %{defsym*} \ 175 %{shared:-Bshareable %{h*} %{soname*}} \ 176 %{!shared: \ 177 %{!static: \ 178 %{rdynamic: -export-dynamic} \ 179 %{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} \ 180 %{static:-Bstatic}} \ 181 %{symbolic:-Bsymbolic}" 182 183 184#undef ASM_DEFAULT_SPEC 185#undef ASM_SPEC 186#undef LINK_OS_FREEBSD_SPEC 187#define ASM_DEFAULT_SPEC "-mppc%{!m32:64}" 188#define ASM_SPEC "%{m32:-a32}%{!m32:-a64} " SVR4_ASM_SPEC 189#define LINK_OS_FREEBSD_SPEC "%{m32:-melf32ppc}%{!m32:-melf64ppc} " LINK_OS_FREEBSD_SPEC_DEF 190#endif 191 192/* _init and _fini functions are built from bits spread across many 193 object files, each potentially with a different TOC pointer. For 194 that reason, place a nop after the call so that the linker can 195 restore the TOC pointer if a TOC adjusting call stub is needed. */ 196#ifdef __powerpc64__ 197#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ 198 asm (SECTION_OP "\n" \ 199" bl ." #FUNC "\n" \ 200" nop\n" \ 201" .previous"); 202#endif 203 204/* __throw will restore its own return address to be the same as the 205 return address of the function that the throw is being made to. 206 This is unfortunate, because we want to check the original 207 return address to see if we need to restore the TOC. 208 So we have to squirrel it away with this. */ 209#define SETUP_FRAME_ADDRESSES() \ 210 do { if (TARGET_64BIT) rs6000_aix_emit_builtin_unwind_init (); } while (0) 211 212/* Select a format to encode pointers in exception handling data. CODE 213 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is 214 true if the symbol may be affected by dynamic relocations. */ 215#undef ASM_PREFERRED_EH_DATA_FORMAT 216#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ 217 ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE) \ 218 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \ 219 | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \ 220 : DW_EH_PE_absptr) 221 222#ifdef __powerpc64__ 223#define MD_FROB_UPDATE_CONTEXT(CTX, FS) \ 224 if ((FS)->regs.reg[2].how == REG_UNSAVED) \ 225 { \ 226 unsigned int *insn = (unsigned int *) \ 227 _Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM); \ 228 if (insn != NULL && *insn == 0xE8410028) \ 229 _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40); \ 230 } 231#endif 232 233#define TARGET_ASM_FILE_END rs6000_elf_end_indicate_exec_stack 234 235/* FreeBSD doesn't support saving and restoring 64-bit regs with a 32-bit 236 kernel. This is supported when running on a 64-bit kernel with 237 COMPAT_FREEBSD32, but tell GCC it isn't so that our 32-bit binaries 238 are compatible. */ 239#define OS_MISSING_POWERPC64 !TARGET_64BIT 240 241/* Function profiling bits */ 242#undef RS6000_MCOUNT 243#define RS6000_MCOUNT ((TARGET_64BIT) ? "._mcount" : "_mcount") 244#define PROFILE_HOOK(LABEL) \ 245 do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0) 246 247#undef NEED_INDICATE_EXEC_STACK 248#define NEED_INDICATE_EXEC_STACK 1 249