Deleted Added
full compact
freebsd.h (217396) freebsd.h (218824)
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
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. */
42extern int dot_symbols;
43#undef DOT_SYMBOLS
44#define DOT_SYMBOLS dot_symbols
45#endif
46
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" \
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" \
199" bl ." #FUNC "\n" \
206" 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
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