]> gcc.gnu.org Git - gcc.git/blob - gcc/config/rs6000/linux64.h
linux64.h (SUBSUBTARGET_OVERRIDE_OPTIONS): Choose MASK_ALIGN_NATURAL if rs6000_alignm...
[gcc.git] / gcc / config / rs6000 / linux64.h
1 /* Definitions of target machine for GNU compiler,
2 for 64 bit PowerPC linux.
3 Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
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, 59 Temple Place - Suite 330, Boston,
20 MA 02111-1307, USA. */
21
22 #ifndef RS6000_BI_ARCH
23
24 #undef DEFAULT_ABI
25 #define DEFAULT_ABI ABI_AIX
26
27 #undef TARGET_64BIT
28 #define TARGET_64BIT 1
29
30 #define DEFAULT_ARCH64_P 1
31 #define RS6000_BI_ARCH_P 0
32
33 #else
34
35 #define DEFAULT_ARCH64_P (TARGET_DEFAULT & MASK_64BIT)
36 #define RS6000_BI_ARCH_P 1
37
38 #endif
39
40 #ifdef IN_LIBGCC2
41 #undef TARGET_64BIT
42 #ifdef __powerpc64__
43 #define TARGET_64BIT 1
44 #else
45 #define TARGET_64BIT 0
46 #endif
47 #endif
48
49 #undef TARGET_AIX
50 #define TARGET_AIX TARGET_64BIT
51
52 #undef PROCESSOR_DEFAULT64
53 #define PROCESSOR_DEFAULT64 PROCESSOR_PPC630
54
55 #undef TARGET_RELOCATABLE
56 #define TARGET_RELOCATABLE (!TARGET_64BIT && (target_flags & MASK_RELOCATABLE))
57
58 #undef RS6000_ABI_NAME
59 #define RS6000_ABI_NAME (TARGET_64BIT ? "aixdesc" : "sysv")
60
61 #define INVALID_64BIT "-m%s not supported in this configuration"
62 #define INVALID_32BIT INVALID_64BIT
63
64 #undef SUBSUBTARGET_OVERRIDE_OPTIONS
65 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
66 do \
67 { \
68 if (rs6000_alignment_string == 0) \
69 rs6000_alignment_flags = MASK_ALIGN_NATURAL; \
70 if (TARGET_64BIT) \
71 { \
72 if (DEFAULT_ABI != ABI_AIX) \
73 { \
74 rs6000_current_abi = ABI_AIX; \
75 error (INVALID_64BIT, "call"); \
76 } \
77 if (TARGET_RELOCATABLE) \
78 { \
79 target_flags &= ~MASK_RELOCATABLE; \
80 error (INVALID_64BIT, "relocatable"); \
81 } \
82 if (TARGET_EABI) \
83 { \
84 target_flags &= ~MASK_EABI; \
85 error (INVALID_64BIT, "eabi"); \
86 } \
87 if (TARGET_PROTOTYPE) \
88 { \
89 target_flags &= ~MASK_PROTOTYPE; \
90 error (INVALID_64BIT, "prototype"); \
91 } \
92 } \
93 else \
94 { \
95 if (!RS6000_BI_ARCH_P) \
96 error (INVALID_32BIT, "32"); \
97 } \
98 } \
99 while (0)
100
101 #ifdef RS6000_BI_ARCH
102
103 #undef OVERRIDE_OPTIONS
104 #define OVERRIDE_OPTIONS \
105 rs6000_override_options (((TARGET_DEFAULT ^ target_flags) & MASK_64BIT) \
106 ? (char *) 0 : TARGET_CPU_DEFAULT)
107
108 #endif
109
110 #undef ASM_DEFAULT_SPEC
111 #undef ASM_SPEC
112 #undef LINK_OS_LINUX_SPEC
113
114 #ifndef RS6000_BI_ARCH
115 #define ASM_DEFAULT_SPEC "-mppc64"
116 #define ASM_SPEC "%(asm_spec64) %(asm_spec_common)"
117 #define LINK_OS_LINUX_SPEC "%(link_os_linux_spec64)"
118 #else
119 #if DEFAULT_ARCH64_P
120 #define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
121 #define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
122 #define LINK_OS_LINUX_SPEC "%{m32:%(link_os_linux_spec32)}%{!m32:%(link_os_linux_spec64)}"
123 #else
124 #define ASM_DEFAULT_SPEC "-mppc%{m64:64}"
125 #define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
126 #define LINK_OS_LINUX_SPEC "%{!m64:%(link_os_linux_spec32)}%{m64:%(link_os_linux_spec64)}"
127 #endif
128 #endif
129
130 #define ASM_SPEC32 "-a32 %{n} %{T} %{Ym,*} %{Yd,*} \
131 %{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} \
132 %{memb} %{!memb: %{msdata: -memb} %{msdata=eabi: -memb}} \
133 %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
134 %{mcall-freebsd: -mbig} \
135 %{mcall-i960-old: -mlittle} \
136 %{mcall-linux: -mbig} \
137 %{mcall-gnu: -mbig} \
138 %{mcall-netbsd: -mbig} \
139 }}}}"
140
141 #define ASM_SPEC64 "-a64"
142
143 #define ASM_SPEC_COMMON "%(asm_cpu) \
144 %{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \
145 %{v:-V} %{Qy:} %{!Qn:-Qy} %{Wa,*:%*} \
146 %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian}"
147
148 #undef SUBSUBTARGET_EXTRA_SPECS
149 #define SUBSUBTARGET_EXTRA_SPECS \
150 { "asm_spec_common", ASM_SPEC_COMMON }, \
151 { "asm_spec32", ASM_SPEC32 }, \
152 { "asm_spec64", ASM_SPEC64 }, \
153 { "link_os_linux_spec32", LINK_OS_LINUX_SPEC32 }, \
154 { "link_os_linux_spec64", LINK_OS_LINUX_SPEC64 },
155
156 #undef MULTILIB_DEFAULTS
157 #if DEFAULT_ARCH64_P
158 #define MULTILIB_DEFAULTS { "m64" }
159 #else
160 #define MULTILIB_DEFAULTS { "m32" }
161 #endif
162
163 #ifndef RS6000_BI_ARCH
164
165 /* 64-bit PowerPC Linux is always big-endian. */
166 #undef TARGET_LITTLE_ENDIAN
167 #define TARGET_LITTLE_ENDIAN 0
168
169 /* 64-bit PowerPC Linux always has a TOC. */
170 #undef TARGET_TOC
171 #define TARGET_TOC 1
172
173 /* Some things from sysv4.h we don't do when 64 bit. */
174 #undef TARGET_RELOCATABLE
175 #define TARGET_RELOCATABLE 0
176 #undef TARGET_EABI
177 #define TARGET_EABI 0
178 #undef TARGET_PROTOTYPE
179 #define TARGET_PROTOTYPE 0
180
181 #endif
182
183 #define MASK_PROFILE_KERNEL 0x00080000
184
185 /* Non-standard profiling for kernels, which just saves LR then calls
186 _mcount without worrying about arg saves. The idea is to change
187 the function prologue as little as possible as it isn't easy to
188 account for arg save/restore code added just for _mcount. */
189 #define TARGET_PROFILE_KERNEL (target_flags & MASK_PROFILE_KERNEL)
190
191 /* Override sysv4.h. */
192 #undef EXTRA_SUBTARGET_SWITCHES
193 #define EXTRA_SUBTARGET_SWITCHES \
194 {"profile-kernel", MASK_PROFILE_KERNEL, \
195 N_("Call mcount for profiling before a function prologue") }, \
196 {"no-profile-kernel", -MASK_PROFILE_KERNEL, \
197 N_("Call mcount for profiling after a function prologue") },
198
199 /* We use glibc _mcount for profiling. */
200 #define NO_PROFILE_COUNTERS TARGET_64BIT
201 #define PROFILE_HOOK(LABEL) \
202 do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
203
204 /* We don't need to generate entries in .fixup. */
205 #undef RELOCATABLE_NEEDS_FIXUP
206
207 /* PowerPC64 Linux word-aligns FP doubles when -malign-power is given. */
208 #undef ADJUST_FIELD_ALIGN
209 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
210 ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE) \
211 ? 128 \
212 : (TARGET_64BIT \
213 && TARGET_ALIGN_NATURAL == 0 \
214 && TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
215 ? get_inner_array_type (FIELD) \
216 : TREE_TYPE (FIELD)) == DFmode) \
217 ? MIN ((COMPUTED), 32) \
218 : (COMPUTED))
219
220 /* PowerPC64 Linux increases natural record alignment to doubleword if
221 the first field is an FP double. */
222 #undef ROUND_TYPE_ALIGN
223 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
224 ((TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE) \
225 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128) \
226 : (TARGET_64BIT \
227 && (TREE_CODE (STRUCT) == RECORD_TYPE \
228 || TREE_CODE (STRUCT) == UNION_TYPE \
229 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
230 && TYPE_FIELDS (STRUCT) != 0 \
231 && TARGET_ALIGN_NATURAL == 0 \
232 && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode) \
233 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64) \
234 : MAX ((COMPUTED), (SPECIFIED)))
235
236 /* Indicate that jump tables go in the text section. */
237 #undef JUMP_TABLES_IN_TEXT_SECTION
238 #define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT
239
240 /* The linux ppc64 ABI isn't explicit on whether aggregates smaller
241 than a doubleword should be padded upward or downward. You could
242 reasonably assume that they follow the normal rules for structure
243 layout treating the parameter area as any other block of memory,
244 then map the reg param area to registers. ie. pad updard.
245 Setting both of the following defines results in this behavior.
246 Setting just the first one will result in aggregates that fit in a
247 doubleword being padded downward, and others being padded upward.
248 Not a bad idea as this results in struct { int x; } being passed
249 the same way as an int. */
250 #define AGGREGATE_PADDING_FIXED TARGET_64BIT
251 #define AGGREGATES_PAD_UPWARD_ALWAYS 0
252
253 /* We don't want anything in the reg parm area being passed on the
254 stack. */
255 #define MUST_PASS_IN_STACK(MODE, TYPE) \
256 ((TARGET_64BIT \
257 && (TYPE) != 0 \
258 && (TREE_CODE (TYPE_SIZE (TYPE)) != INTEGER_CST \
259 || TREE_ADDRESSABLE (TYPE))) \
260 || (!TARGET_64BIT \
261 && default_must_pass_in_stack ((MODE), (TYPE))))
262
263 /* Specify padding for the last element of a block move between
264 registers and memory. FIRST is nonzero if this is the only
265 element. */
266 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
267 (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
268
269 /* __throw will restore its own return address to be the same as the
270 return address of the function that the throw is being made to.
271 This is unfortunate, because we want to check the original
272 return address to see if we need to restore the TOC.
273 So we have to squirrel it away with this. */
274 #define SETUP_FRAME_ADDRESSES() \
275 do { if (TARGET_64BIT) rs6000_aix_emit_builtin_unwind_init (); } while (0)
276
277 /* Override svr4.h */
278 #undef MD_EXEC_PREFIX
279 #undef MD_STARTFILE_PREFIX
280
281 /* Override sysv4.h */
282 #undef CPP_SYSV_SPEC
283 #define CPP_SYSV_SPEC ""
284
285 #undef TARGET_OS_CPP_BUILTINS
286 #define TARGET_OS_CPP_BUILTINS() \
287 do \
288 { \
289 if (TARGET_64BIT) \
290 { \
291 builtin_define ("__PPC__"); \
292 builtin_define ("__PPC64__"); \
293 builtin_define ("__powerpc__"); \
294 builtin_define ("__powerpc64__"); \
295 builtin_define ("__PIC__"); \
296 builtin_assert ("cpu=powerpc64"); \
297 builtin_assert ("machine=powerpc64"); \
298 } \
299 else \
300 { \
301 builtin_define_std ("PPC"); \
302 builtin_define_std ("powerpc"); \
303 builtin_assert ("cpu=powerpc"); \
304 builtin_assert ("machine=powerpc"); \
305 TARGET_OS_SYSV_CPP_BUILTINS (); \
306 } \
307 } \
308 while (0)
309
310 #undef CPP_OS_DEFAULT_SPEC
311 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
312
313 /* The GNU C++ standard library currently requires _GNU_SOURCE being
314 defined on glibc-based systems. This temporary hack accomplishes this,
315 it should go away as soon as libstdc++-v3 has a real fix. */
316 #undef CPLUSPLUS_CPP_SPEC
317 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
318
319 #undef LINK_SHLIB_SPEC
320 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
321
322 #undef LIB_DEFAULT_SPEC
323 #define LIB_DEFAULT_SPEC "%(lib_linux)"
324
325 #undef STARTFILE_DEFAULT_SPEC
326 #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
327
328 #undef ENDFILE_DEFAULT_SPEC
329 #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
330
331 #undef LINK_START_DEFAULT_SPEC
332 #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
333
334 #undef LINK_OS_DEFAULT_SPEC
335 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
336
337 #define LINK_OS_LINUX_SPEC32 "-m elf32ppclinux %{!shared: %{!static: \
338 %{rdynamic:-export-dynamic} \
339 %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
340
341 #define LINK_OS_LINUX_SPEC64 "-m elf64ppc %{!shared: %{!static: \
342 %{rdynamic:-export-dynamic} \
343 %{!dynamic-linker:-dynamic-linker /lib64/ld64.so.1}}}"
344
345 #undef TOC_SECTION_ASM_OP
346 #define TOC_SECTION_ASM_OP \
347 (TARGET_64BIT \
348 ? "\t.section\t\".toc\",\"aw\"" \
349 : "\t.section\t\".got\",\"aw\"")
350
351 #undef MINIMAL_TOC_SECTION_ASM_OP
352 #define MINIMAL_TOC_SECTION_ASM_OP \
353 (TARGET_64BIT \
354 ? "\t.section\t\".toc1\",\"aw\"" \
355 : ((TARGET_RELOCATABLE || flag_pic) \
356 ? "\t.section\t\".got2\",\"aw\"" \
357 : "\t.section\t\".got1\",\"aw\""))
358
359 #undef TARGET_VERSION
360 #define TARGET_VERSION fprintf (stderr, " (PowerPC64 GNU/Linux)");
361
362 /* Must be at least as big as our pointer type. */
363 #undef SIZE_TYPE
364 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
365
366 #undef PTRDIFF_TYPE
367 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
368
369 #undef WCHAR_TYPE
370 #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")
371 #undef WCHAR_TYPE_SIZE
372 #define WCHAR_TYPE_SIZE 32
373
374 /* Override rs6000.h definition. */
375 #undef ASM_APP_ON
376 #define ASM_APP_ON "#APP\n"
377
378 /* Override rs6000.h definition. */
379 #undef ASM_APP_OFF
380 #define ASM_APP_OFF "#NO_APP\n"
381
382 /* PowerPC no-op instruction. */
383 #undef RS6000_CALL_GLUE
384 #define RS6000_CALL_GLUE (TARGET_64BIT ? "nop" : "cror 31,31,31")
385
386 #undef RS6000_MCOUNT
387 #define RS6000_MCOUNT "_mcount"
388
389 #ifdef __powerpc64__
390 /* _init and _fini functions are built from bits spread across many
391 object files, each potentially with a different TOC pointer. For
392 that reason, place a nop after the call so that the linker can
393 restore the TOC pointer if a TOC adjusting call stub is needed. */
394 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
395 asm (SECTION_OP "\n" \
396 " bl ." #FUNC "\n" \
397 " nop\n" \
398 " .previous");
399 #endif
400
401 /* FP save and restore routines. */
402 #undef SAVE_FP_PREFIX
403 #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
404 #undef SAVE_FP_SUFFIX
405 #define SAVE_FP_SUFFIX (TARGET_64BIT ? "" : "_l")
406 #undef RESTORE_FP_PREFIX
407 #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
408 #undef RESTORE_FP_SUFFIX
409 #define RESTORE_FP_SUFFIX (TARGET_64BIT ? "" : "_l")
410
411 /* Dwarf2 debugging. */
412 #undef PREFERRED_DEBUGGING_TYPE
413 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
414
415 /* This is how to declare the size of a function. */
416 #undef ASM_DECLARE_FUNCTION_SIZE
417 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
418 do \
419 { \
420 if (!flag_inhibit_size_directive) \
421 { \
422 fputs ("\t.size\t", (FILE)); \
423 if (TARGET_64BIT) \
424 putc ('.', (FILE)); \
425 assemble_name ((FILE), (FNAME)); \
426 fputs (",.-", (FILE)); \
427 if (TARGET_64BIT) \
428 putc ('.', (FILE)); \
429 assemble_name ((FILE), (FNAME)); \
430 putc ('\n', (FILE)); \
431 } \
432 } \
433 while (0)
434
435 /* Return nonzero if this entry is to be written into the constant
436 pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
437 or a CONST containing one of them. If -mfp-in-toc (the default),
438 we also do this for floating-point constants. We actually can only
439 do this if the FP formats of the target and host machines are the
440 same, but we can't check that since not every file that uses
441 GO_IF_LEGITIMATE_ADDRESS_P includes real.h. We also do this when
442 we can write the entry into the TOC and the entry is not larger
443 than a TOC entry. */
444
445 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
446 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
447 (TARGET_TOC \
448 && (GET_CODE (X) == SYMBOL_REF \
449 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
450 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
451 || GET_CODE (X) == LABEL_REF \
452 || (GET_CODE (X) == CONST_INT \
453 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
454 || (GET_CODE (X) == CONST_DOUBLE \
455 && ((TARGET_64BIT \
456 && (TARGET_POWERPC64 \
457 || TARGET_MINIMAL_TOC \
458 || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
459 && ! TARGET_NO_FP_IN_TOC))) \
460 || (!TARGET_64BIT \
461 && !TARGET_NO_FP_IN_TOC \
462 && !TARGET_RELOCATABLE \
463 && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
464 && BITS_PER_WORD == HOST_BITS_PER_INT)))))
465
466 /* This is the same as the dbxelf.h version, except that we need to
467 use the function code label, not the function descriptor. */
468 #undef ASM_OUTPUT_SOURCE_LINE
469 #define ASM_OUTPUT_SOURCE_LINE(FILE, LINE, COUNTER) \
470 do \
471 { \
472 char temp[256]; \
473 ASM_GENERATE_INTERNAL_LABEL (temp, "LM", COUNTER); \
474 fprintf (FILE, "\t.stabn 68,0,%d,", LINE); \
475 assemble_name (FILE, temp); \
476 putc ('-', FILE); \
477 if (TARGET_64BIT) \
478 putc ('.', FILE); \
479 assemble_name (FILE, \
480 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\
481 putc ('\n', FILE); \
482 (*targetm.asm_out.internal_label) (FILE, "LM", COUNTER); \
483 } \
484 while (0)
485
486 /* Similarly, we want the function code label here. */
487 #define DBX_OUTPUT_BRAC(FILE, NAME, BRAC) \
488 do \
489 { \
490 const char *flab; \
491 fprintf (FILE, "%s%d,0,0,", ASM_STABN_OP, BRAC); \
492 assemble_name (FILE, NAME); \
493 putc ('-', FILE); \
494 if (current_function_func_begin_label != NULL_TREE) \
495 flab = IDENTIFIER_POINTER (current_function_func_begin_label); \
496 else \
497 { \
498 if (TARGET_64BIT) \
499 putc ('.', FILE); \
500 flab = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0); \
501 } \
502 assemble_name (FILE, flab); \
503 putc ('\n', FILE); \
504 } \
505 while (0)
506
507 #define DBX_OUTPUT_LBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_LBRAC)
508 #define DBX_OUTPUT_RBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_RBRAC)
509
510 /* Another case where we want the dot name. */
511 #define DBX_OUTPUT_NFUN(FILE, LSCOPE, DECL) \
512 do \
513 { \
514 fprintf (FILE, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN); \
515 assemble_name (FILE, LSCOPE); \
516 putc ('-', FILE); \
517 if (TARGET_64BIT) \
518 putc ('.', FILE); \
519 assemble_name (FILE, XSTR (XEXP (DECL_RTL (DECL), 0), 0)); \
520 putc ('\n', FILE); \
521 } \
522 while (0)
523
524 /* Select a format to encode pointers in exception handling data. CODE
525 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
526 true if the symbol may be affected by dynamic relocations. */
527 #undef ASM_PREFERRED_EH_DATA_FORMAT
528 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
529 ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE) \
530 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
531 | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
532 : DW_EH_PE_absptr)
533
534 /* For backward compatibility, we must continue to use the AIX
535 structure return convention. */
536 #undef DRAFT_V4_STRUCT_RET
537 #define DRAFT_V4_STRUCT_RET (!TARGET_64BIT)
538
539 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
540
541 #define LINK_GCC_C_SEQUENCE_SPEC \
542 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
543
544 /* Do code reading to identify a signal frame, and set the frame
545 state data appropriately. See unwind-dw2.c for the structs. */
546
547 #ifdef IN_LIBGCC2
548 #include <signal.h>
549 #include <sys/ucontext.h>
550
551 #ifdef __powerpc64__
552 enum { SIGNAL_FRAMESIZE = 128 };
553 #else
554 enum { SIGNAL_FRAMESIZE = 64 };
555 #endif
556 #endif
557
558 #ifdef __powerpc64__
559
560 /* If the current unwind info (FS) does not contain explicit info
561 saving R2, then we have to do a minor amount of code reading to
562 figure out if it was saved. The big problem here is that the
563 code that does the save/restore is generated by the linker, so
564 we have no good way to determine at compile time what to do. */
565
566 #define MD_FROB_UPDATE_CONTEXT(CTX, FS) \
567 do { \
568 if ((FS)->regs.reg[2].how == REG_UNSAVED) \
569 { \
570 unsigned int *insn \
571 = (unsigned int *) \
572 _Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM); \
573 if (*insn == 0xE8410028) \
574 _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40); \
575 } \
576 } while (0)
577
578 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
579 do { \
580 unsigned char *pc_ = (CONTEXT)->ra; \
581 struct sigcontext *sc_; \
582 long new_cfa_; \
583 int i_; \
584 \
585 /* addi r1, r1, 128; li r0, 0x0077; sc (sigreturn) */ \
586 /* addi r1, r1, 128; li r0, 0x00AC; sc (rt_sigreturn) */ \
587 if (*(unsigned int *) (pc_+0) != 0x38210000 + SIGNAL_FRAMESIZE \
588 || *(unsigned int *) (pc_+8) != 0x44000002) \
589 break; \
590 if (*(unsigned int *) (pc_+4) == 0x38000077) \
591 { \
592 struct sigframe { \
593 char gap[SIGNAL_FRAMESIZE]; \
594 struct sigcontext sigctx; \
595 } *rt_ = (CONTEXT)->cfa; \
596 sc_ = &rt_->sigctx; \
597 } \
598 else if (*(unsigned int *) (pc_+4) == 0x380000AC) \
599 { \
600 struct rt_sigframe { \
601 int tramp[6]; \
602 struct siginfo *pinfo; \
603 struct ucontext *puc; \
604 } *rt_ = (struct rt_sigframe *) pc_; \
605 sc_ = &rt_->puc->uc_mcontext; \
606 } \
607 else \
608 break; \
609 \
610 new_cfa_ = sc_->regs->gpr[STACK_POINTER_REGNUM]; \
611 (FS)->cfa_how = CFA_REG_OFFSET; \
612 (FS)->cfa_reg = STACK_POINTER_REGNUM; \
613 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
614 \
615 for (i_ = 0; i_ < 32; i_++) \
616 if (i_ != STACK_POINTER_REGNUM) \
617 { \
618 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
619 (FS)->regs.reg[i_].loc.offset \
620 = (long)&(sc_->regs->gpr[i_]) - new_cfa_; \
621 } \
622 \
623 (FS)->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET; \
624 (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset \
625 = (long)&(sc_->regs->link) - new_cfa_; \
626 \
627 /* The unwinder expects the IP to point to the following insn, \
628 whereas the kernel returns the address of the actual \
629 faulting insn. We store NIP+4 in an unused register slot to \
630 get the same result for multiple evaluation of the same signal \
631 frame. */ \
632 sc_->regs->gpr[47] = sc_->regs->nip + 4; \
633 (FS)->regs.reg[CR0_REGNO].how = REG_SAVED_OFFSET; \
634 (FS)->regs.reg[CR0_REGNO].loc.offset \
635 = (long)&(sc_->regs->gpr[47]) - new_cfa_; \
636 (FS)->retaddr_column = CR0_REGNO; \
637 goto SUCCESS; \
638 } while (0)
639
640 #else
641
642 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
643 do { \
644 unsigned char *pc_ = (CONTEXT)->ra; \
645 struct sigcontext *sc_; \
646 long new_cfa_; \
647 int i_; \
648 \
649 /* li r0, 0x7777; sc (sigreturn old) */ \
650 /* li r0, 0x0077; sc (sigreturn new) */ \
651 /* li r0, 0x6666; sc (rt_sigreturn old) */ \
652 /* li r0, 0x00AC; sc (rt_sigreturn new) */ \
653 if (*(unsigned int *) (pc_+4) != 0x44000002) \
654 break; \
655 if (*(unsigned int *) (pc_+0) == 0x38007777 \
656 || *(unsigned int *) (pc_+0) == 0x38000077) \
657 { \
658 struct sigframe { \
659 char gap[SIGNAL_FRAMESIZE]; \
660 struct sigcontext sigctx; \
661 } *rt_ = (CONTEXT)->cfa; \
662 sc_ = &rt_->sigctx; \
663 } \
664 else if (*(unsigned int *) (pc_+0) == 0x38006666 \
665 || *(unsigned int *) (pc_+0) == 0x380000AC) \
666 { \
667 struct rt_sigframe { \
668 char gap[SIGNAL_FRAMESIZE]; \
669 unsigned long _unused[2]; \
670 struct siginfo *pinfo; \
671 void *puc; \
672 struct siginfo info; \
673 struct ucontext uc; \
674 } *rt_ = (CONTEXT)->cfa; \
675 sc_ = &rt_->uc.uc_mcontext; \
676 } \
677 else \
678 break; \
679 \
680 new_cfa_ = sc_->regs->gpr[STACK_POINTER_REGNUM]; \
681 (FS)->cfa_how = CFA_REG_OFFSET; \
682 (FS)->cfa_reg = STACK_POINTER_REGNUM; \
683 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
684 \
685 for (i_ = 0; i_ < 32; i_++) \
686 if (i_ != STACK_POINTER_REGNUM) \
687 { \
688 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
689 (FS)->regs.reg[i_].loc.offset \
690 = (long)&(sc_->regs->gpr[i_]) - new_cfa_; \
691 } \
692 \
693 (FS)->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET; \
694 (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset \
695 = (long)&(sc_->regs->link) - new_cfa_; \
696 \
697 /* The unwinder expects the IP to point to the following insn, \
698 whereas the kernel returns the address of the actual \
699 faulting insn. We store NIP+4 in an unused register slot to \
700 get the same result for multiple evaluation of the same signal \
701 frame. */ \
702 sc_->regs->gpr[47] = sc_->regs->nip + 4; \
703 (FS)->regs.reg[CR0_REGNO].how = REG_SAVED_OFFSET; \
704 (FS)->regs.reg[CR0_REGNO].loc.offset \
705 = (long)&(sc_->regs->gpr[47]) - new_cfa_; \
706 (FS)->retaddr_column = CR0_REGNO; \
707 goto SUCCESS; \
708 } while (0)
709
710 #endif
This page took 0.068199 seconds and 5 git commands to generate.