]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rs6000/aix.h
re PR target/47109 (m68k-netbsdelf: collect2 build fails with undefined reference...
[thirdparty/gcc.git] / gcc / config / rs6000 / aix.h
1 /* Definitions of target machine for GNU compiler,
2 for IBM RS/6000 POWER running AIX.
3 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010,
4 2011 Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 3, or (at your
11 option) any later version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
21
22 /* Yes! We are AIX! */
23 #define DEFAULT_ABI ABI_AIX
24 #undef TARGET_AIX
25 #define TARGET_AIX 1
26
27 /* Linux64.h wants to redefine TARGET_AIX based on -m64, but it can't be used
28 in the #if conditional in options-default.h, so provide another macro. */
29 #undef TARGET_AIX_OS
30 #define TARGET_AIX_OS 1
31
32 /* AIX always has a TOC. */
33 #define TARGET_NO_TOC 0
34 #define TARGET_TOC 1
35 #define FIXED_R2 1
36
37 /* AIX allows r13 to be used in 32-bit mode. */
38 #define FIXED_R13 0
39
40 /* 32-bit and 64-bit AIX stack boundary is 128. */
41 #undef STACK_BOUNDARY
42 #define STACK_BOUNDARY 128
43
44 #undef TARGET_IEEEQUAD
45 #define TARGET_IEEEQUAD 0
46
47 /* The AIX linker will discard static constructors in object files before
48 collect has a chance to see them, so scan the object files directly. */
49 #define COLLECT_EXPORT_LIST
50
51 #if HAVE_AS_REF
52 /* Issue assembly directives that create a reference to the given DWARF table
53 identifier label from the current function section. This is defined to
54 ensure we drag frame frame tables associated with needed function bodies in
55 a link with garbage collection activated. */
56 #define ASM_OUTPUT_DWARF_TABLE_REF rs6000_aix_asm_output_dwarf_table_ref
57 #endif
58
59 /* This is the only version of nm that collect2 can work with. */
60 #define REAL_NM_FILE_NAME "/usr/ucb/nm"
61
62 #define USER_LABEL_PREFIX ""
63
64 /* Don't turn -B into -L if the argument specifies a relative file name. */
65 #define RELATIVE_PREFIX_NOT_LINKDIR
66
67 /* Because of the above, we must have gcc search itself to find libgcc.a. */
68 #define LINK_LIBGCC_SPECIAL_1
69
70 #define MFWRAP_SPEC " %{static: %{fmudflap|fmudflapth: \
71 -brename:malloc,__wrap_malloc -brename:__real_malloc,malloc \
72 -brename:free,__wrap_free -brename:__real_free,free \
73 -brename:calloc,__wrap_calloc -brename:__real_calloc,calloc \
74 -brename:realloc,__wrap_realloc -brename:__real_realloc,realloc \
75 -brename:mmap,__wrap_mmap -brename:__real_mmap,mmap \
76 -brename:munmap,__wrap_munmap -brename:__real_munmap,munmap \
77 -brename:alloca,__wrap_alloca -brename:__real_alloca,alloca \
78 } %{fmudflapth: \
79 -brename:pthread_create,__wrap_pthread_create \
80 -brename:__real_pthread_create,pthread_create \
81 -brename:pthread_join,__wrap_pthread_join \
82 -brename:__real_pthread_join,pthread_join \
83 -brename:pthread_exit,__wrap_pthread_exit \
84 -brename:__real_pthread_exit,pthread_exit \
85 }} %{fmudflap|fmudflapth: \
86 -brename:main,__wrap_main -brename:__real_main,main \
87 }"
88
89 #define MFLIB_SPEC " %{fmudflap: -lmudflap \
90 %{static:%(link_gcc_c_sequence) -lmudflap}} \
91 %{fmudflapth: -lmudflapth -lpthread \
92 %{static:%(link_gcc_c_sequence) -lmudflapth}} "
93
94 /* Names to predefine in the preprocessor for this target machine. */
95 #define TARGET_OS_AIX_CPP_BUILTINS() \
96 do \
97 { \
98 builtin_define ("_IBMR2"); \
99 builtin_define ("_POWER"); \
100 builtin_define ("_AIX"); \
101 builtin_define ("_AIX32"); \
102 builtin_define ("_AIX41"); \
103 builtin_define ("_LONG_LONG"); \
104 if (TARGET_LONG_DOUBLE_128) \
105 builtin_define ("__LONGDOUBLE128"); \
106 builtin_assert ("system=unix"); \
107 builtin_assert ("system=aix"); \
108 } \
109 while (0)
110
111 /* Define appropriate architecture macros for preprocessor depending on
112 target switches. */
113
114 #define CPP_SPEC "%{posix: -D_POSIX_SOURCE}\
115 %{ansi: -D_ANSI_C_SOURCE}"
116
117 #define CC1_SPEC "%(cc1_cpu)"
118
119 #undef ASM_DEFAULT_SPEC
120 #define ASM_DEFAULT_SPEC ""
121
122 /* Tell the assembler to assume that all undefined names are external.
123
124 Don't do this until the fixed IBM assembler is more generally available.
125 When this becomes permanently defined, the ASM_OUTPUT_EXTERNAL,
126 ASM_OUTPUT_EXTERNAL_LIBCALL, and RS6000_OUTPUT_BASENAME macros will no
127 longer be needed. Also, the extern declaration of mcount in
128 rs6000_xcoff_file_start will no longer be needed. */
129
130 /* #define ASM_SPEC "-u %(asm_cpu)" */
131
132 /* Default location of syscalls.exp under AIX */
133 #define LINK_SYSCALLS_SPEC "-bI:%R/lib/syscalls.exp"
134
135 /* Default location of libg.exp under AIX */
136 #define LINK_LIBG_SPEC "-bexport:%R/usr/lib/libg.exp"
137
138 /* Define the options for the binder: Start text at 512, align all segments
139 to 512 bytes, and warn if there is text relocation.
140
141 The -bhalt:4 option supposedly changes the level at which ld will abort,
142 but it also suppresses warnings about multiply defined symbols and is
143 used by the AIX cc command. So we use it here.
144
145 -bnodelcsect undoes a poor choice of default relating to multiply-defined
146 csects. See AIX documentation for more information about this.
147
148 -bM:SRE tells the linker that the output file is Shared REusable. Note
149 that to actually build a shared library you will also need to specify an
150 export list with the -Wl,-bE option. */
151
152 #define LINK_SPEC "-T512 -H512 %{!r:-btextro} -bhalt:4 -bnodelcsect\
153 %{static:-bnso %(link_syscalls) } \
154 %{!shared:%{g*: %(link_libg) }} %{shared:-bM:SRE}"
155
156 /* Profiled library versions are used by linking with special directories. */
157 #define LIB_SPEC "%{pg:-L%R/lib/profiled -L%R/usr/lib/profiled}\
158 %{p:-L%R/lib/profiled -L%R/usr/lib/profiled} %{!shared:%{g*:-lg}} -lc"
159
160 /* Static linking with shared libstdc++ requires libsupc++ as well. */
161 #define LIBSTDCXX_STATIC "supc++"
162
163 /* This now supports a natural alignment mode. */
164 /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */
165 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
166 ((TARGET_ALIGN_NATURAL == 0 \
167 && TYPE_MODE (strip_array_types (TREE_TYPE (FIELD))) == DFmode) \
168 ? MIN ((COMPUTED), 32) \
169 : (COMPUTED))
170
171 /* AIX increases natural record alignment to doubleword if the first
172 field is an FP double while the FP fields remain word aligned. */
173 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
174 ((TREE_CODE (STRUCT) == RECORD_TYPE \
175 || TREE_CODE (STRUCT) == UNION_TYPE \
176 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
177 && TARGET_ALIGN_NATURAL == 0 \
178 ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
179 : MAX ((COMPUTED), (SPECIFIED)))
180
181 /* The AIX ABI isn't explicit on whether aggregates smaller than a
182 word/doubleword should be padded upward or downward. One could
183 reasonably assume that they follow the normal rules for structure
184 layout treating the parameter area as any other block of memory,
185 then map the reg param area to registers, i.e., pad upward, which
186 is the way IBM Compilers for AIX behave.
187 Setting both of the following defines results in this behavior. */
188 #define AGGREGATE_PADDING_FIXED 1
189 #define AGGREGATES_PAD_UPWARD_ALWAYS 1
190
191 /* Specify padding for the last element of a block move between
192 registers and memory. FIRST is nonzero if this is the only
193 element. */
194 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
195 (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
196
197 /* Indicate that jump tables go in the text section. */
198
199 #define JUMP_TABLES_IN_TEXT_SECTION 1
200
201 /* Define any extra SPECS that the compiler needs to generate. */
202 #undef SUBTARGET_EXTRA_SPECS
203 #define SUBTARGET_EXTRA_SPECS \
204 { "link_syscalls", LINK_SYSCALLS_SPEC }, \
205 { "link_libg", LINK_LIBG_SPEC }
206
207 /* Define cutoff for using external functions to save floating point. */
208 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) == 62 || (FIRST_REG) == 63)
209 /* And similarly for general purpose registers. */
210 #define GP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 32)
211
212 /* If the current unwind info (FS) does not contain explicit info
213 saving R2, then we have to do a minor amount of code reading to
214 figure out if it was saved. The big problem here is that the
215 code that does the save/restore is generated by the linker, so
216 we have no good way to determine at compile time what to do. */
217
218 #define R_LR 65
219
220 #ifdef __64BIT__
221 #define MD_FROB_UPDATE_CONTEXT(CTX, FS) \
222 do { \
223 if ((FS)->regs.reg[2].how == REG_UNSAVED) \
224 { \
225 unsigned int *insn \
226 = (unsigned int *) \
227 _Unwind_GetGR ((CTX), R_LR); \
228 if (*insn == 0xE8410028) \
229 _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40); \
230 } \
231 } while (0)
232 #else
233 #define MD_FROB_UPDATE_CONTEXT(CTX, FS) \
234 do { \
235 if ((FS)->regs.reg[2].how == REG_UNSAVED) \
236 { \
237 unsigned int *insn \
238 = (unsigned int *) \
239 _Unwind_GetGR ((CTX), R_LR); \
240 if (*insn == 0x80410014) \
241 _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 20); \
242 } \
243 } while (0)
244 #endif
245
246 #define PROFILE_HOOK(LABEL) output_profile_hook (LABEL)
247
248 /* No version of AIX fully supports AltiVec or 64-bit instructions in
249 32-bit mode. */
250 #define OS_MISSING_POWERPC64 1
251 #define OS_MISSING_ALTIVEC 1
252
253 /* WINT_TYPE */
254 #define WINT_TYPE "int"
255
256 /* Static stack checking is supported by means of probes. */
257 #define STACK_CHECK_STATIC_BUILTIN 1