* target.h (asm_out.file_start, file_start_app_off,
[official-gcc.git] / gcc / config / rs6000 / linux64.h
blobc1c1edb4d30686339b4db0f80cdd83f9458c2117
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.
5 This file is part of GCC.
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.
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.
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. */
22 #ifndef RS6000_BI_ARCH
24 #undef DEFAULT_ABI
25 #define DEFAULT_ABI ABI_AIX
27 #undef TARGET_64BIT
28 #define TARGET_64BIT 1
30 #define DEFAULT_ARCH64_P 1
31 #define RS6000_BI_ARCH_P 0
33 #else
35 #define DEFAULT_ARCH64_P (TARGET_DEFAULT & MASK_64BIT)
36 #define RS6000_BI_ARCH_P 1
38 #endif
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
49 #undef TARGET_AIX
50 #define TARGET_AIX TARGET_64BIT
52 #undef PROCESSOR_DEFAULT64
53 #define PROCESSOR_DEFAULT64 PROCESSOR_PPC630
55 #undef TARGET_RELOCATABLE
56 #define TARGET_RELOCATABLE (!TARGET_64BIT && (target_flags & MASK_RELOCATABLE))
58 #undef RS6000_ABI_NAME
59 #define RS6000_ABI_NAME (TARGET_64BIT ? "aixdesc" : "sysv")
61 #define INVALID_64BIT "-m%s not supported in this configuration"
62 #define INVALID_32BIT INVALID_64BIT
64 #undef SUBSUBTARGET_OVERRIDE_OPTIONS
65 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
66 do \
67 { \
68 if (TARGET_64BIT) \
69 { \
70 if (DEFAULT_ABI != ABI_AIX) \
71 { \
72 DEFAULT_ABI = ABI_AIX; \
73 error (INVALID_64BIT, "call"); \
74 } \
75 if (TARGET_RELOCATABLE) \
76 { \
77 target_flags &= ~MASK_RELOCATABLE; \
78 error (INVALID_64BIT, "relocatable"); \
79 } \
80 if (TARGET_EABI) \
81 { \
82 target_flags &= ~MASK_EABI; \
83 error (INVALID_64BIT, "eabi"); \
84 } \
85 if (TARGET_PROTOTYPE) \
86 { \
87 target_flags &= ~MASK_PROTOTYPE; \
88 error (INVALID_64BIT, "prototype"); \
89 } \
90 } \
91 else \
92 { \
93 if (!RS6000_BI_ARCH_P) \
94 error (INVALID_32BIT, "32"); \
95 } \
96 } \
97 while (0)
99 #ifdef RS6000_BI_ARCH
101 #undef OVERRIDE_OPTIONS
102 #define OVERRIDE_OPTIONS \
103 rs6000_override_options (((TARGET_DEFAULT ^ target_flags) & MASK_64BIT) \
104 ? (char *) 0 : TARGET_CPU_DEFAULT)
106 #endif
108 #undef ASM_DEFAULT_SPEC
109 #undef ASM_SPEC
110 #undef LINK_OS_LINUX_SPEC
112 #ifndef RS6000_BI_ARCH
113 #define ASM_DEFAULT_SPEC "-mppc64"
114 #define ASM_SPEC "%(asm_spec64) %(asm_spec_common)"
115 #define LINK_OS_LINUX_SPEC "%(link_os_linux_spec64)"
116 #else
117 #if DEFAULT_ARCH64_P
118 #define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
119 #define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
120 #define LINK_OS_LINUX_SPEC "%{m32:%(link_os_linux_spec32)}%{!m32:%(link_os_linux_spec64)}"
121 #else
122 #define ASM_DEFAULT_SPEC "-mppc%{m64:64}"
123 #define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
124 #define LINK_OS_LINUX_SPEC "%{!m64:%(link_os_linux_spec32)}%{m64:%(link_os_linux_spec64)}"
125 #endif
126 #endif
128 #define ASM_SPEC32 "-a32 %{n} %{T} %{Ym,*} %{Yd,*} \
129 %{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} \
130 %{memb} %{!memb: %{msdata: -memb} %{msdata=eabi: -memb}} \
131 %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
132 %{mcall-freebsd: -mbig} \
133 %{mcall-i960-old: -mlittle} \
134 %{mcall-linux: -mbig} \
135 %{mcall-gnu: -mbig} \
136 %{mcall-netbsd: -mbig} \
137 }}}}"
139 #define ASM_SPEC64 "-a64"
141 #define ASM_SPEC_COMMON "%(asm_cpu) \
142 %{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \
143 %{v:-V} %{Qy:} %{!Qn:-Qy} %{Wa,*:%*} \
144 %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian}"
146 #undef SUBSUBTARGET_EXTRA_SPECS
147 #define SUBSUBTARGET_EXTRA_SPECS \
148 { "asm_spec_common", ASM_SPEC_COMMON }, \
149 { "asm_spec32", ASM_SPEC32 }, \
150 { "asm_spec64", ASM_SPEC64 }, \
151 { "link_os_linux_spec32", LINK_OS_LINUX_SPEC32 }, \
152 { "link_os_linux_spec64", LINK_OS_LINUX_SPEC64 },
154 #undef MULTILIB_DEFAULTS
155 #if DEFAULT_ARCH64_P
156 #define MULTILIB_DEFAULTS { "m64" }
157 #else
158 #define MULTILIB_DEFAULTS { "m32" }
159 #endif
161 #ifndef RS6000_BI_ARCH
163 /* 64-bit PowerPC Linux always has a TOC. */
164 #undef TARGET_TOC
165 #define TARGET_TOC 1
167 /* Some things from sysv4.h we don't do when 64 bit. */
168 #undef TARGET_RELOCATABLE
169 #define TARGET_RELOCATABLE 0
170 #undef TARGET_EABI
171 #define TARGET_EABI 0
172 #undef TARGET_PROTOTYPE
173 #define TARGET_PROTOTYPE 0
175 #endif
177 #define MASK_PROFILE_KERNEL 0x00080000
179 /* Non-standard profiling for kernels, which just saves LR then calls
180 _mcount without worrying about arg saves. The idea is to change
181 the function prologue as little as possible as it isn't easy to
182 account for arg save/restore code added just for _mcount. */
183 #define TARGET_PROFILE_KERNEL (target_flags & MASK_PROFILE_KERNEL)
185 /* Override sysv4.h. */
186 #undef EXTRA_SUBTARGET_SWITCHES
187 #define EXTRA_SUBTARGET_SWITCHES \
188 {"profile-kernel", MASK_PROFILE_KERNEL, \
189 N_("Call mcount for profiling before a function prologue") }, \
190 {"no-profile-kernel", -MASK_PROFILE_KERNEL, \
191 N_("Call mcount for profiling after a function prologue") },
193 /* We use glibc _mcount for profiling. */
194 #define NO_PROFILE_COUNTERS TARGET_64BIT
195 #define PROFILE_HOOK(LABEL) \
196 do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
198 /* We don't need to generate entries in .fixup. */
199 #undef RELOCATABLE_NEEDS_FIXUP
201 /* This now supports a natural alignment mode. */
202 /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */
203 #undef ADJUST_FIELD_ALIGN
204 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
205 ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE) \
206 ? 128 \
207 : (TARGET_64BIT \
208 && TARGET_ALIGN_NATURAL == 0 \
209 && TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
210 ? get_inner_array_type (FIELD) \
211 : TREE_TYPE (FIELD)) == DFmode) \
212 ? MIN ((COMPUTED), 32) \
213 : (COMPUTED))
215 /* AIX increases natural record alignment to doubleword if the first
216 field is an FP double while the FP fields remain word aligned. */
217 #undef ROUND_TYPE_ALIGN
218 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
219 ((TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE) \
220 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128) \
221 : (TARGET_64BIT \
222 && (TREE_CODE (STRUCT) == RECORD_TYPE \
223 || TREE_CODE (STRUCT) == UNION_TYPE \
224 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
225 && TYPE_FIELDS (STRUCT) != 0 \
226 && TARGET_ALIGN_NATURAL == 0 \
227 && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode) \
228 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64) \
229 : MAX ((COMPUTED), (SPECIFIED)))
231 /* Indicate that jump tables go in the text section. */
232 #undef JUMP_TABLES_IN_TEXT_SECTION
233 #define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT
235 /* __throw will restore its own return address to be the same as the
236 return address of the function that the throw is being made to.
237 This is unfortunate, because we want to check the original
238 return address to see if we need to restore the TOC.
239 So we have to squirrel it away with this. */
240 #define SETUP_FRAME_ADDRESSES() \
241 do { if (TARGET_64BIT) rs6000_aix_emit_builtin_unwind_init (); } while (0)
243 /* Override svr4.h */
244 #undef MD_EXEC_PREFIX
245 #undef MD_STARTFILE_PREFIX
247 /* Override sysv4.h */
248 #undef CPP_SYSV_SPEC
249 #define CPP_SYSV_SPEC ""
251 #undef TARGET_OS_CPP_BUILTINS
252 #define TARGET_OS_CPP_BUILTINS() \
253 do \
255 if (TARGET_64BIT) \
257 builtin_define ("__PPC__"); \
258 builtin_define ("__PPC64__"); \
259 builtin_define ("__powerpc__"); \
260 builtin_define ("__powerpc64__"); \
261 builtin_define ("__PIC__"); \
262 builtin_assert ("cpu=powerpc64"); \
263 builtin_assert ("machine=powerpc64"); \
265 else \
267 builtin_define_std ("PPC"); \
268 builtin_define_std ("powerpc"); \
269 builtin_assert ("cpu=powerpc"); \
270 builtin_assert ("machine=powerpc"); \
271 TARGET_OS_SYSV_CPP_BUILTINS (); \
274 while (0)
276 #undef CPP_OS_DEFAULT_SPEC
277 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
279 /* The GNU C++ standard library currently requires _GNU_SOURCE being
280 defined on glibc-based systems. This temporary hack accomplishes this,
281 it should go away as soon as libstdc++-v3 has a real fix. */
282 #undef CPLUSPLUS_CPP_SPEC
283 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
285 #undef LINK_SHLIB_SPEC
286 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
288 #undef LIB_DEFAULT_SPEC
289 #define LIB_DEFAULT_SPEC "%(lib_linux)"
291 #undef STARTFILE_DEFAULT_SPEC
292 #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
294 #undef ENDFILE_DEFAULT_SPEC
295 #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
297 #undef LINK_START_DEFAULT_SPEC
298 #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
300 #undef LINK_OS_DEFAULT_SPEC
301 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
303 #define LINK_OS_LINUX_SPEC32 "-m elf32ppclinux %{!shared: %{!static: \
304 %{rdynamic:-export-dynamic} \
305 %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
307 #define LINK_OS_LINUX_SPEC64 "-m elf64ppc %{!shared: %{!static: \
308 %{rdynamic:-export-dynamic} \
309 %{!dynamic-linker:-dynamic-linker /lib64/ld64.so.1}}}"
311 #undef TOC_SECTION_ASM_OP
312 #define TOC_SECTION_ASM_OP \
313 (TARGET_64BIT \
314 ? "\t.section\t\".toc\",\"aw\"" \
315 : "\t.section\t\".got\",\"aw\"")
317 #undef MINIMAL_TOC_SECTION_ASM_OP
318 #define MINIMAL_TOC_SECTION_ASM_OP \
319 (TARGET_64BIT \
320 ? "\t.section\t\".toc1\",\"aw\"" \
321 : ((TARGET_RELOCATABLE || flag_pic) \
322 ? "\t.section\t\".got2\",\"aw\"" \
323 : "\t.section\t\".got1\",\"aw\""))
325 #undef TARGET_VERSION
326 #define TARGET_VERSION fprintf (stderr, " (PowerPC64 GNU/Linux)");
328 /* Must be at least as big as our pointer type. */
329 #undef SIZE_TYPE
330 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
332 #undef PTRDIFF_TYPE
333 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
335 #undef WCHAR_TYPE
336 #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")
337 #undef WCHAR_TYPE_SIZE
338 #define WCHAR_TYPE_SIZE 32
340 /* Override rs6000.h definition. */
341 #undef ASM_APP_ON
342 #define ASM_APP_ON "#APP\n"
344 /* Override rs6000.h definition. */
345 #undef ASM_APP_OFF
346 #define ASM_APP_OFF "#NO_APP\n"
348 /* PowerPC no-op instruction. */
349 #undef RS6000_CALL_GLUE
350 #define RS6000_CALL_GLUE (TARGET_64BIT ? "nop" : "cror 31,31,31")
352 #undef RS6000_MCOUNT
353 #define RS6000_MCOUNT "_mcount"
355 #ifdef __powerpc64__
356 /* _init and _fini functions are built from bits spread across many
357 object files, each potentially with a different TOC pointer. For
358 that reason, place a nop after the call so that the linker can
359 restore the TOC pointer if a TOC adjusting call stub is needed. */
360 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
361 asm (SECTION_OP "\n" \
362 " bl ." #FUNC "\n" \
363 " nop\n" \
364 " .previous");
365 #endif
367 /* FP save and restore routines. */
368 #undef SAVE_FP_PREFIX
369 #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
370 #undef SAVE_FP_SUFFIX
371 #define SAVE_FP_SUFFIX (TARGET_64BIT ? "" : "_l")
372 #undef RESTORE_FP_PREFIX
373 #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
374 #undef RESTORE_FP_SUFFIX
375 #define RESTORE_FP_SUFFIX (TARGET_64BIT ? "" : "_l")
377 /* Dwarf2 debugging. */
378 #undef PREFERRED_DEBUGGING_TYPE
379 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
381 /* This is how to declare the size of a function. */
382 #undef ASM_DECLARE_FUNCTION_SIZE
383 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
384 do \
386 if (!flag_inhibit_size_directive) \
388 fputs ("\t.size\t", (FILE)); \
389 if (TARGET_64BIT) \
390 putc ('.', (FILE)); \
391 assemble_name ((FILE), (FNAME)); \
392 fputs (",.-", (FILE)); \
393 if (TARGET_64BIT) \
394 putc ('.', (FILE)); \
395 assemble_name ((FILE), (FNAME)); \
396 putc ('\n', (FILE)); \
399 while (0)
401 /* Return nonzero if this entry is to be written into the constant
402 pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
403 or a CONST containing one of them. If -mfp-in-toc (the default),
404 we also do this for floating-point constants. We actually can only
405 do this if the FP formats of the target and host machines are the
406 same, but we can't check that since not every file that uses
407 GO_IF_LEGITIMATE_ADDRESS_P includes real.h. We also do this when
408 we can write the entry into the TOC and the entry is not larger
409 than a TOC entry. */
411 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
412 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
413 (TARGET_TOC \
414 && (GET_CODE (X) == SYMBOL_REF \
415 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
416 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
417 || GET_CODE (X) == LABEL_REF \
418 || (GET_CODE (X) == CONST_INT \
419 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
420 || (GET_CODE (X) == CONST_DOUBLE \
421 && ((TARGET_64BIT \
422 && (TARGET_POWERPC64 \
423 || TARGET_MINIMAL_TOC \
424 || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
425 && ! TARGET_NO_FP_IN_TOC))) \
426 || (!TARGET_64BIT \
427 && !TARGET_NO_FP_IN_TOC \
428 && !TARGET_RELOCATABLE \
429 && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
430 && BITS_PER_WORD == HOST_BITS_PER_INT)))))
432 /* This is the same as the dbxelf.h version, except that we need to
433 use the function code label, not the function descriptor. */
434 #undef ASM_OUTPUT_SOURCE_LINE
435 #define ASM_OUTPUT_SOURCE_LINE(FILE, LINE, COUNTER) \
436 do \
438 char temp[256]; \
439 ASM_GENERATE_INTERNAL_LABEL (temp, "LM", COUNTER); \
440 fprintf (FILE, "\t.stabn 68,0,%d,", LINE); \
441 assemble_name (FILE, temp); \
442 putc ('-', FILE); \
443 if (TARGET_64BIT) \
444 putc ('.', FILE); \
445 assemble_name (FILE, \
446 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\
447 putc ('\n', FILE); \
448 (*targetm.asm_out.internal_label) (FILE, "LM", COUNTER); \
450 while (0)
452 /* Similarly, we want the function code label here. */
453 #define DBX_OUTPUT_BRAC(FILE, NAME, BRAC) \
454 do \
456 const char *flab; \
457 fprintf (FILE, "%s%d,0,0,", ASM_STABN_OP, BRAC); \
458 assemble_name (FILE, NAME); \
459 putc ('-', FILE); \
460 if (current_function_func_begin_label != NULL_TREE) \
461 flab = IDENTIFIER_POINTER (current_function_func_begin_label); \
462 else \
464 if (TARGET_64BIT) \
465 putc ('.', FILE); \
466 flab = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0); \
468 assemble_name (FILE, flab); \
469 putc ('\n', FILE); \
471 while (0)
473 #define DBX_OUTPUT_LBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_LBRAC)
474 #define DBX_OUTPUT_RBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_RBRAC)
476 /* Another case where we want the dot name. */
477 #define DBX_OUTPUT_NFUN(FILE, LSCOPE, DECL) \
478 do \
480 fprintf (FILE, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN); \
481 assemble_name (FILE, LSCOPE); \
482 putc ('-', FILE); \
483 if (TARGET_64BIT) \
484 putc ('.', FILE); \
485 assemble_name (FILE, XSTR (XEXP (DECL_RTL (DECL), 0), 0)); \
486 putc ('\n', FILE); \
488 while (0)
490 /* Select a format to encode pointers in exception handling data. CODE
491 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
492 true if the symbol may be affected by dynamic relocations. */
493 #undef ASM_PREFERRED_EH_DATA_FORMAT
494 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
495 ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE) \
496 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
497 | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
498 : DW_EH_PE_absptr)
500 /* For backward compatibility, we must continue to use the AIX
501 structure return convention. */
502 #undef DRAFT_V4_STRUCT_RET
503 #define DRAFT_V4_STRUCT_RET (!TARGET_64BIT)
505 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
507 /* Do code reading to identify a signal frame, and set the frame
508 state data appropriately. See unwind-dw2.c for the structs. */
510 #ifdef IN_LIBGCC2
511 #include <signal.h>
512 #include <sys/ucontext.h>
514 #ifdef __powerpc64__
515 enum { SIGNAL_FRAMESIZE = 128 };
516 #else
517 enum { SIGNAL_FRAMESIZE = 64 };
518 #endif
519 #endif
521 #ifdef __powerpc64__
523 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
524 do { \
525 unsigned char *pc_ = (CONTEXT)->ra; \
526 struct sigcontext *sc_; \
527 long new_cfa_; \
528 int i_; \
530 /* addi r1, r1, 128; li r0, 0x0077; sc (sigreturn) */ \
531 /* addi r1, r1, 128; li r0, 0x00AC; sc (rt_sigreturn) */ \
532 if (*(unsigned int *) (pc_+0) != 0x38210000 + SIGNAL_FRAMESIZE \
533 || *(unsigned int *) (pc_+8) != 0x44000002) \
534 break; \
535 if (*(unsigned int *) (pc_+4) == 0x38000077) \
537 struct sigframe { \
538 char gap[SIGNAL_FRAMESIZE]; \
539 struct sigcontext sigctx; \
540 } *rt_ = (CONTEXT)->cfa; \
541 sc_ = &rt_->sigctx; \
543 else if (*(unsigned int *) (pc_+4) == 0x380000AC) \
545 struct rt_sigframe { \
546 int tramp[6]; \
547 struct siginfo *pinfo; \
548 struct ucontext *puc; \
549 } *rt_ = (struct rt_sigframe *) pc_; \
550 sc_ = &rt_->puc->uc_mcontext; \
552 else \
553 break; \
555 new_cfa_ = sc_->regs->gpr[STACK_POINTER_REGNUM]; \
556 (FS)->cfa_how = CFA_REG_OFFSET; \
557 (FS)->cfa_reg = STACK_POINTER_REGNUM; \
558 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
560 for (i_ = 0; i_ < 32; i_++) \
561 if (i_ != STACK_POINTER_REGNUM) \
563 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
564 (FS)->regs.reg[i_].loc.offset \
565 = (long)&(sc_->regs->gpr[i_]) - new_cfa_; \
568 (FS)->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET; \
569 (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset \
570 = (long)&(sc_->regs->link) - new_cfa_; \
572 /* The unwinder expects the IP to point to the following insn, \
573 whereas the kernel returns the address of the actual \
574 faulting insn. We store NIP+4 in an unused register slot to \
575 get the same result for multiple evaluation of the same signal \
576 frame. */ \
577 sc_->regs->gpr[47] = sc_->regs->nip + 4; \
578 (FS)->regs.reg[CR0_REGNO].how = REG_SAVED_OFFSET; \
579 (FS)->regs.reg[CR0_REGNO].loc.offset \
580 = (long)&(sc_->regs->gpr[47]) - new_cfa_; \
581 (FS)->retaddr_column = CR0_REGNO; \
582 goto SUCCESS; \
583 } while (0)
585 #else
587 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
588 do { \
589 unsigned char *pc_ = (CONTEXT)->ra; \
590 struct sigcontext *sc_; \
591 long new_cfa_; \
592 int i_; \
594 /* li r0, 0x7777; sc (sigreturn old) */ \
595 /* li r0, 0x0077; sc (sigreturn new) */ \
596 /* li r0, 0x6666; sc (rt_sigreturn old) */ \
597 /* li r0, 0x00AC; sc (rt_sigreturn new) */ \
598 if (*(unsigned int *) (pc_+4) != 0x44000002) \
599 break; \
600 if (*(unsigned int *) (pc_+0) == 0x38007777 \
601 || *(unsigned int *) (pc_+0) == 0x38000077) \
603 struct sigframe { \
604 char gap[SIGNAL_FRAMESIZE]; \
605 struct sigcontext sigctx; \
606 } *rt_ = (CONTEXT)->cfa; \
607 sc_ = &rt_->sigctx; \
609 else if (*(unsigned int *) (pc_+0) == 0x38006666 \
610 || *(unsigned int *) (pc_+0) == 0x380000AC) \
612 struct rt_sigframe { \
613 char gap[SIGNAL_FRAMESIZE]; \
614 unsigned long _unused[2]; \
615 struct siginfo *pinfo; \
616 void *puc; \
617 struct siginfo info; \
618 struct ucontext uc; \
619 } *rt_ = (CONTEXT)->cfa; \
620 sc_ = &rt_->uc.uc_mcontext; \
622 else \
623 break; \
625 new_cfa_ = sc_->regs->gpr[STACK_POINTER_REGNUM]; \
626 (FS)->cfa_how = CFA_REG_OFFSET; \
627 (FS)->cfa_reg = STACK_POINTER_REGNUM; \
628 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
630 for (i_ = 0; i_ < 32; i_++) \
631 if (i_ != STACK_POINTER_REGNUM) \
633 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
634 (FS)->regs.reg[i_].loc.offset \
635 = (long)&(sc_->regs->gpr[i_]) - new_cfa_; \
638 (FS)->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET; \
639 (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset \
640 = (long)&(sc_->regs->link) - new_cfa_; \
642 /* The unwinder expects the IP to point to the following insn, \
643 whereas the kernel returns the address of the actual \
644 faulting insn. We store NIP+4 in an unused register slot to \
645 get the same result for multiple evaluation of the same signal \
646 frame. */ \
647 sc_->regs->gpr[47] = sc_->regs->nip + 4; \
648 (FS)->regs.reg[CR0_REGNO].how = REG_SAVED_OFFSET; \
649 (FS)->regs.reg[CR0_REGNO].loc.offset \
650 = (long)&(sc_->regs->gpr[47]) - new_cfa_; \
651 (FS)->retaddr_column = CR0_REGNO; \
652 goto SUCCESS; \
653 } while (0)
655 #endif