]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/gcc/config/rs6000/freebsd.h
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / contrib / gcc / config / rs6000 / freebsd.h
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 #ifdef HAVE_LD_NO_DOT_SYMS
41 /* New ABI uses a local sym for the function entry point.  */
42 extern int dot_symbols;
43 #undef DOT_SYMBOLS
44 #define DOT_SYMBOLS dot_symbols
45 #endif
46
47 #undef  FBSD_TARGET_CPU_CPP_BUILTINS
48 #define FBSD_TARGET_CPU_CPP_BUILTINS()          \
49   do                                            \
50     {                                           \
51       builtin_define ("__PPC__");               \
52       builtin_define ("__ppc__");               \
53       builtin_define ("__PowerPC__");           \
54       builtin_define ("__powerpc__");           \
55       if (TARGET_64BIT)                         \
56         {                                       \
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"); \
63         } else {                                \
64           builtin_assert ("cpu=powerpc");       \
65           builtin_assert ("machine=powerpc");   \
66         }                                       \
67     }                                           \
68   while (0)
69
70 #define INVALID_64BIT "-m%s not supported in this configuration"
71 #define INVALID_32BIT INVALID_64BIT
72
73 #undef  SUBSUBTARGET_OVERRIDE_OPTIONS
74 #define SUBSUBTARGET_OVERRIDE_OPTIONS                           \
75   do                                                            \
76     {                                                           \
77       if (!rs6000_explicit_options.alignment)                   \
78         rs6000_alignment_flags = MASK_ALIGN_NATURAL;            \
79       if (TARGET_64BIT)                                         \
80         {                                                       \
81           if (DEFAULT_ABI != ABI_AIX)                           \
82             {                                                   \
83               rs6000_current_abi = ABI_AIX;                     \
84               error (INVALID_64BIT, "call");                    \
85             }                                                   \
86           dot_symbols = !strcmp (rs6000_abi_name, "aixdesc");   \
87           if (target_flags & MASK_RELOCATABLE)                  \
88             {                                                   \
89               target_flags &= ~MASK_RELOCATABLE;                \
90               error (INVALID_64BIT, "relocatable");             \
91             }                                                   \
92           if (target_flags & MASK_EABI)                         \
93             {                                                   \
94               target_flags &= ~MASK_EABI;                       \
95               error (INVALID_64BIT, "eabi");                    \
96             }                                                   \
97           if (target_flags & MASK_PROTOTYPE)                    \
98             {                                                   \
99               target_flags &= ~MASK_PROTOTYPE;                  \
100               error (INVALID_64BIT, "prototype");               \
101             }                                                   \
102           if ((target_flags & MASK_POWERPC64) == 0)             \
103             {                                                   \
104               target_flags |= MASK_POWERPC64;                   \
105               error ("64 bit CPU required");                    \
106             }                                                   \
107         }                                                       \
108     }                                                           \
109   while (0)
110
111
112 #undef  STARTFILE_DEFAULT_SPEC
113 #define STARTFILE_DEFAULT_SPEC "%(startfile_freebsd)"
114
115 #undef  ENDFILE_DEFAULT_SPEC
116 #define ENDFILE_DEFAULT_SPEC "%(endfile_freebsd)"
117
118 #undef  LIB_DEFAULT_SPEC
119 #define LIB_DEFAULT_SPEC "%(lib_freebsd)"
120
121 #undef  LINK_START_DEFAULT_SPEC
122 #define LINK_START_DEFAULT_SPEC "%(link_start_freebsd)"
123
124 #undef  LINK_OS_DEFAULT_SPEC
125 #define LINK_OS_DEFAULT_SPEC "%(link_os_freebsd)"
126
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}}"
131
132
133 /************************[  Target stuff  ]***********************************/
134
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.  */
138
139 #undef  SIZE_TYPE
140 #define SIZE_TYPE       (TARGET_64BIT ? "long unsigned int" : "unsigned int")
141
142 #undef  PTRDIFF_TYPE
143 #define PTRDIFF_TYPE    (TARGET_64BIT ? "long int" : "int")
144
145 /* rs6000.h gets this wrong for FreeBSD.  We use the GCC defaults instead.  */
146 #undef WCHAR_TYPE
147
148 #undef  WCHAR_TYPE_SIZE
149 #define WCHAR_TYPE_SIZE 32
150
151 #undef  TARGET_VERSION
152 #define TARGET_VERSION fprintf (stderr, " (FreeBSD/PowerPC ELF)");
153
154 /* Override rs6000.h definition.  */
155 #undef  ASM_APP_ON
156 #define ASM_APP_ON "#APP\n"
157
158 /* Override rs6000.h definition.  */
159 #undef  ASM_APP_OFF
160 #define ASM_APP_OFF "#NO_APP\n"
161
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;    \
171   mcall-aixdesc |                  \
172   mcall-freebsd |                  \
173   mcall-netbsd  |                  \
174   mcall-openbsd |                  \
175   mcall-linux   |                  \
176   mcall-gnu             :-mbig;    \
177   mcall-i960-old        :-mlittle}"
178 #define LINK_OS_FREEBSD_SPEC_DEF "\
179   %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \
180   %{v:-V} \
181   %{assert*} %{R*} %{rpath*} %{defsym*} \
182   %{shared:-Bshareable %{h*} %{soname*}} \
183   %{!shared: \
184     %{!static: \
185       %{rdynamic: -export-dynamic} \
186       %{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} \
187     %{static:-Bstatic}} \
188   %{symbolic:-Bsymbolic}"
189
190
191 #undef  ASM_DEFAULT_SPEC
192 #undef  ASM_SPEC
193 #undef  LINK_OS_FREEBSD_SPEC
194 #define ASM_DEFAULT_SPEC        "-mppc%{!m32:64}"
195 #define ASM_SPEC                "%{m32:-a32}%{!m32:-a64} " SVR4_ASM_SPEC
196 #define LINK_OS_FREEBSD_SPEC    "%{m32:-melf32ppc}%{!m32:-melf64ppc} " LINK_OS_FREEBSD_SPEC_DEF
197 #endif
198
199 /* _init and _fini functions are built from bits spread across many
200    object files, each potentially with a different TOC pointer.  For
201    that reason, place a nop after the call so that the linker can
202    restore the TOC pointer if a TOC adjusting call stub is needed.  */
203 #ifdef __powerpc64__
204 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)      \
205   asm (SECTION_OP "\n"                                  \
206 "       bl " #FUNC "\n"                                 \
207 "       nop\n"                                          \
208 "       .previous");
209 #endif
210
211 /* __throw will restore its own return address to be the same as the
212    return address of the function that the throw is being made to.
213    This is unfortunate, because we want to check the original
214    return address to see if we need to restore the TOC.
215    So we have to squirrel it away with this.  */
216 #define SETUP_FRAME_ADDRESSES() \
217   do { if (TARGET_64BIT) rs6000_aix_emit_builtin_unwind_init (); } while (0)
218
219 /* Select a format to encode pointers in exception handling data.  CODE
220    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
221    true if the symbol may be affected by dynamic relocations.  */
222 #undef  ASM_PREFERRED_EH_DATA_FORMAT
223 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
224   ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE)                     \
225    ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel               \
226       | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4))             \
227    : DW_EH_PE_absptr)
228
229 #ifdef __powerpc64__
230 #define MD_FROB_UPDATE_CONTEXT(CTX, FS)                                 \
231     if ((FS)->regs.reg[2].how == REG_UNSAVED)                           \
232       {                                                                 \
233         unsigned int *insn = (unsigned int *)                           \
234             _Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM);                \
235         if (insn != NULL && *insn == 0xE8410028)                        \
236           _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40);                 \
237       }
238 #endif
239
240 #define TARGET_ASM_FILE_END rs6000_elf_end_indicate_exec_stack
241
242 /* FreeBSD doesn't support saving and restoring 64-bit regs with a 32-bit
243    kernel. This is supported when running on a 64-bit kernel with
244    COMPAT_FREEBSD32, but tell GCC it isn't so that our 32-bit binaries
245    are compatible. */
246 #define OS_MISSING_POWERPC64 !TARGET_64BIT
247
248 /* Function profiling bits */
249 #undef  RS6000_MCOUNT
250 #define RS6000_MCOUNT ((TARGET_64BIT) ? "._mcount" : "_mcount")
251 #define PROFILE_HOOK(LABEL) \
252   do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
253
254 #undef NEED_INDICATE_EXEC_STACK
255 #define NEED_INDICATE_EXEC_STACK 1