1 /* DWARF2 exception handling and frame unwind runtime interface routines.
2 Copyright (C) 1997-2013 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
27 #include "coretypes.h"
29 #include "libgcc_tm.h"
32 #ifdef __USING_SJLJ_EXCEPTIONS__
33 # define NO_SIZE_OF_ENCODED_VALUE
35 #include "unwind-pe.h"
36 #include "unwind-dw2-fde.h"
38 #include "unwind-dw2.h"
44 #ifndef __USING_SJLJ_EXCEPTIONS__
46 #ifndef STACK_GROWS_DOWNWARD
47 #define STACK_GROWS_DOWNWARD 0
49 #undef STACK_GROWS_DOWNWARD
50 #define STACK_GROWS_DOWNWARD 1
53 /* Dwarf frame registers used for pre gcc 3.0 compiled glibc. */
54 #ifndef PRE_GCC3_DWARF_FRAME_REGISTERS
55 #define PRE_GCC3_DWARF_FRAME_REGISTERS DWARF_FRAME_REGISTERS
58 #ifndef DWARF_REG_TO_UNWIND_COLUMN
59 #define DWARF_REG_TO_UNWIND_COLUMN(REGNO) (REGNO)
62 /* ??? For the public function interfaces, we tend to gcc_assert that the
63 column numbers are in range. For the dwarf2 unwind info this does happen,
64 although so far in a case that doesn't actually matter.
66 See PR49146, in which a call from x86_64 ms abi to x86_64 unix abi stores
67 the call-saved xmm registers and annotates them. We havn't bothered
68 providing support for the xmm registers for the x86_64 port primarily
69 because the 64-bit windows targets don't use dwarf2 unwind, using sjlj or
70 SEH instead. Adding the support for unix targets would generally be a
71 waste. However, some runtime libraries supplied with ICC do contain such
72 an unorthodox transition, as well as the unwind info to match. This loss
73 of register restoration doesn't matter in practice, because the exception
74 is caught in the native unix abi, where all of the xmm registers are
77 Ideally, we'd record some bit to notice when we're failing to restore some
78 register recorded in the unwind info, but to do that we need annotation on
79 the unix->ms abi edge, so that we know when the register data may be
80 discarded. And since this edge is also within the ICC library, we're
81 unlikely to be able to get the new annotation.
83 Barring a magic solution to restore the ms abi defined 128-bit xmm registers
84 (as distictly opposed to the full runtime width) without causing extra
85 overhead for normal unix abis, the best solution seems to be to simply
86 ignore unwind data for unknown columns. */
88 #define UNWIND_COLUMN_IN_RANGE(x) \
89 __builtin_expect((x) <= DWARF_FRAME_REGISTERS, 1)
91 #ifdef REG_VALUE_IN_UNWIND_CONTEXT
92 typedef _Unwind_Word _Unwind_Context_Reg_Val
;
94 #ifndef ASSUME_EXTENDED_UNWIND_CONTEXT
95 #define ASSUME_EXTENDED_UNWIND_CONTEXT 1
98 static inline _Unwind_Word
99 _Unwind_Get_Unwind_Word (_Unwind_Context_Reg_Val val
)
104 static inline _Unwind_Context_Reg_Val
105 _Unwind_Get_Unwind_Context_Reg_Val (_Unwind_Word val
)
110 typedef void *_Unwind_Context_Reg_Val
;
112 static inline _Unwind_Word
113 _Unwind_Get_Unwind_Word (_Unwind_Context_Reg_Val val
)
115 return (_Unwind_Word
) (_Unwind_Internal_Ptr
) val
;
118 static inline _Unwind_Context_Reg_Val
119 _Unwind_Get_Unwind_Context_Reg_Val (_Unwind_Word val
)
121 return (_Unwind_Context_Reg_Val
) (_Unwind_Internal_Ptr
) val
;
125 #ifndef ASSUME_EXTENDED_UNWIND_CONTEXT
126 #define ASSUME_EXTENDED_UNWIND_CONTEXT 0
129 /* This is the register and unwind state for a particular frame. This
130 provides the information necessary to unwind up past a frame and return
132 struct _Unwind_Context
134 _Unwind_Context_Reg_Val reg
[DWARF_FRAME_REGISTERS
+1];
138 struct dwarf_eh_bases bases
;
139 /* Signal frame context. */
140 #define SIGNAL_FRAME_BIT ((~(_Unwind_Word) 0 >> 1) + 1)
141 /* Context which has version/args_size/by_value fields. */
142 #define EXTENDED_CONTEXT_BIT ((~(_Unwind_Word) 0 >> 2) + 1)
144 /* 0 for now, can be increased when further fields are added to
145 struct _Unwind_Context. */
146 _Unwind_Word version
;
147 _Unwind_Word args_size
;
148 char by_value
[DWARF_FRAME_REGISTERS
+1];
151 /* Byte size of every register managed by these routines. */
152 static unsigned char dwarf_reg_size_table
[DWARF_FRAME_REGISTERS
+1];
155 /* Read unaligned data from the instruction buffer. */
160 unsigned u2
__attribute__ ((mode (HI
)));
161 unsigned u4
__attribute__ ((mode (SI
)));
162 unsigned u8
__attribute__ ((mode (DI
)));
163 signed s2
__attribute__ ((mode (HI
)));
164 signed s4
__attribute__ ((mode (SI
)));
165 signed s8
__attribute__ ((mode (DI
)));
166 } __attribute__ ((packed
));
168 static void uw_update_context (struct _Unwind_Context
*, _Unwind_FrameState
*);
169 static _Unwind_Reason_Code
uw_frame_state_for (struct _Unwind_Context
*,
170 _Unwind_FrameState
*);
173 read_pointer (const void *p
) { const union unaligned
*up
= p
; return up
->p
; }
176 read_1u (const void *p
) { return *(const unsigned char *) p
; }
179 read_1s (const void *p
) { return *(const signed char *) p
; }
182 read_2u (const void *p
) { const union unaligned
*up
= p
; return up
->u2
; }
185 read_2s (const void *p
) { const union unaligned
*up
= p
; return up
->s2
; }
187 static inline unsigned int
188 read_4u (const void *p
) { const union unaligned
*up
= p
; return up
->u4
; }
191 read_4s (const void *p
) { const union unaligned
*up
= p
; return up
->s4
; }
193 static inline unsigned long
194 read_8u (const void *p
) { const union unaligned
*up
= p
; return up
->u8
; }
196 static inline unsigned long
197 read_8s (const void *p
) { const union unaligned
*up
= p
; return up
->s8
; }
199 static inline _Unwind_Word
200 _Unwind_IsSignalFrame (struct _Unwind_Context
*context
)
202 return (context
->flags
& SIGNAL_FRAME_BIT
) ? 1 : 0;
206 _Unwind_SetSignalFrame (struct _Unwind_Context
*context
, int val
)
209 context
->flags
|= SIGNAL_FRAME_BIT
;
211 context
->flags
&= ~SIGNAL_FRAME_BIT
;
214 static inline _Unwind_Word
215 _Unwind_IsExtendedContext (struct _Unwind_Context
*context
)
217 return (ASSUME_EXTENDED_UNWIND_CONTEXT
218 || (context
->flags
& EXTENDED_CONTEXT_BIT
));
221 /* Get the value of register INDEX as saved in CONTEXT. */
224 _Unwind_GetGR (struct _Unwind_Context
*context
, int index
)
227 _Unwind_Context_Reg_Val val
;
229 #ifdef DWARF_ZERO_REG
230 if (index
== DWARF_ZERO_REG
)
234 index
= DWARF_REG_TO_UNWIND_COLUMN (index
);
235 gcc_assert (index
< (int) sizeof(dwarf_reg_size_table
));
236 size
= dwarf_reg_size_table
[index
];
237 val
= context
->reg
[index
];
239 if (_Unwind_IsExtendedContext (context
) && context
->by_value
[index
])
240 return _Unwind_Get_Unwind_Word (val
);
242 /* This will segfault if the register hasn't been saved. */
243 if (size
== sizeof(_Unwind_Ptr
))
244 return * (_Unwind_Ptr
*) (_Unwind_Internal_Ptr
) val
;
247 gcc_assert (size
== sizeof(_Unwind_Word
));
248 return * (_Unwind_Word
*) (_Unwind_Internal_Ptr
) val
;
253 _Unwind_GetPtr (struct _Unwind_Context
*context
, int index
)
255 return (void *)(_Unwind_Ptr
) _Unwind_GetGR (context
, index
);
258 /* Get the value of the CFA as saved in CONTEXT. */
261 _Unwind_GetCFA (struct _Unwind_Context
*context
)
263 return (_Unwind_Ptr
) context
->cfa
;
266 /* Overwrite the saved value for register INDEX in CONTEXT with VAL. */
269 _Unwind_SetGR (struct _Unwind_Context
*context
, int index
, _Unwind_Word val
)
274 index
= DWARF_REG_TO_UNWIND_COLUMN (index
);
275 gcc_assert (index
< (int) sizeof(dwarf_reg_size_table
));
276 size
= dwarf_reg_size_table
[index
];
278 if (_Unwind_IsExtendedContext (context
) && context
->by_value
[index
])
280 context
->reg
[index
] = _Unwind_Get_Unwind_Context_Reg_Val (val
);
284 ptr
= (void *) (_Unwind_Internal_Ptr
) context
->reg
[index
];
286 if (size
== sizeof(_Unwind_Ptr
))
287 * (_Unwind_Ptr
*) ptr
= val
;
290 gcc_assert (size
== sizeof(_Unwind_Word
));
291 * (_Unwind_Word
*) ptr
= val
;
295 /* Get the pointer to a register INDEX as saved in CONTEXT. */
298 _Unwind_GetGRPtr (struct _Unwind_Context
*context
, int index
)
300 index
= DWARF_REG_TO_UNWIND_COLUMN (index
);
301 if (_Unwind_IsExtendedContext (context
) && context
->by_value
[index
])
302 return &context
->reg
[index
];
303 return (void *) (_Unwind_Internal_Ptr
) context
->reg
[index
];
306 /* Set the pointer to a register INDEX as saved in CONTEXT. */
309 _Unwind_SetGRPtr (struct _Unwind_Context
*context
, int index
, void *p
)
311 index
= DWARF_REG_TO_UNWIND_COLUMN (index
);
312 if (_Unwind_IsExtendedContext (context
))
313 context
->by_value
[index
] = 0;
314 context
->reg
[index
] = (_Unwind_Context_Reg_Val
) (_Unwind_Internal_Ptr
) p
;
317 /* Overwrite the saved value for register INDEX in CONTEXT with VAL. */
320 _Unwind_SetGRValue (struct _Unwind_Context
*context
, int index
,
323 index
= DWARF_REG_TO_UNWIND_COLUMN (index
);
324 gcc_assert (index
< (int) sizeof(dwarf_reg_size_table
));
325 /* Return column size may be smaller than _Unwind_Context_Reg_Val. */
326 gcc_assert (dwarf_reg_size_table
[index
] <= sizeof (_Unwind_Context_Reg_Val
));
328 context
->by_value
[index
] = 1;
329 context
->reg
[index
] = _Unwind_Get_Unwind_Context_Reg_Val (val
);
332 /* Return nonzero if register INDEX is stored by value rather than
336 _Unwind_GRByValue (struct _Unwind_Context
*context
, int index
)
338 index
= DWARF_REG_TO_UNWIND_COLUMN (index
);
339 return context
->by_value
[index
];
342 /* Retrieve the return address for CONTEXT. */
345 _Unwind_GetIP (struct _Unwind_Context
*context
)
347 return (_Unwind_Ptr
) context
->ra
;
350 /* Retrieve the return address and flag whether that IP is before
351 or after first not yet fully executed instruction. */
354 _Unwind_GetIPInfo (struct _Unwind_Context
*context
, int *ip_before_insn
)
356 *ip_before_insn
= _Unwind_IsSignalFrame (context
);
357 return (_Unwind_Ptr
) context
->ra
;
360 /* Overwrite the return address for CONTEXT with VAL. */
363 _Unwind_SetIP (struct _Unwind_Context
*context
, _Unwind_Ptr val
)
365 context
->ra
= (void *) val
;
369 _Unwind_GetLanguageSpecificData (struct _Unwind_Context
*context
)
371 return context
->lsda
;
375 _Unwind_GetRegionStart (struct _Unwind_Context
*context
)
377 return (_Unwind_Ptr
) context
->bases
.func
;
381 _Unwind_FindEnclosingFunction (void *pc
)
383 struct dwarf_eh_bases bases
;
384 const struct dwarf_fde
*fde
= _Unwind_Find_FDE (pc
-1, &bases
);
393 _Unwind_GetDataRelBase (struct _Unwind_Context
*context
)
395 return (_Unwind_Ptr
) context
->bases
.dbase
;
399 _Unwind_GetTextRelBase (struct _Unwind_Context
*context
)
401 return (_Unwind_Ptr
) context
->bases
.tbase
;
405 #include "md-unwind-support.h"
407 /* Extract any interesting information from the CIE for the translation
408 unit F belongs to. Return a pointer to the byte after the augmentation,
409 or NULL if we encountered an undecipherable augmentation. */
411 static const unsigned char *
412 extract_cie_info (const struct dwarf_cie
*cie
, struct _Unwind_Context
*context
,
413 _Unwind_FrameState
*fs
)
415 const unsigned char *aug
= cie
->augmentation
;
416 const unsigned char *p
= aug
+ strlen ((const char *)aug
) + 1;
417 const unsigned char *ret
= NULL
;
421 /* g++ v2 "eh" has pointer immediately following augmentation string,
422 so it must be handled first. */
423 if (aug
[0] == 'e' && aug
[1] == 'h')
425 fs
->eh_ptr
= read_pointer (p
);
426 p
+= sizeof (void *);
430 /* After the augmentation resp. pointer for "eh" augmentation
431 follows for CIE version >= 4 address size byte and
432 segment size byte. */
433 if (__builtin_expect (cie
->version
>= 4, 0))
435 if (p
[0] != sizeof (void *) || p
[1] != 0)
439 /* Immediately following this are the code and
440 data alignment and return address column. */
441 p
= read_uleb128 (p
, &utmp
);
442 fs
->code_align
= (_Unwind_Word
)utmp
;
443 p
= read_sleb128 (p
, &stmp
);
444 fs
->data_align
= (_Unwind_Sword
)stmp
;
445 if (cie
->version
== 1)
446 fs
->retaddr_column
= *p
++;
449 p
= read_uleb128 (p
, &utmp
);
450 fs
->retaddr_column
= (_Unwind_Word
)utmp
;
452 fs
->lsda_encoding
= DW_EH_PE_omit
;
454 /* If the augmentation starts with 'z', then a uleb128 immediately
455 follows containing the length of the augmentation field following
459 p
= read_uleb128 (p
, &utmp
);
466 /* Iterate over recognized augmentation subsequences. */
469 /* "L" indicates a byte showing how the LSDA pointer is encoded. */
472 fs
->lsda_encoding
= *p
++;
476 /* "R" indicates a byte indicating how FDE addresses are encoded. */
477 else if (aug
[0] == 'R')
479 fs
->fde_encoding
= *p
++;
483 /* "P" indicates a personality routine in the CIE augmentation. */
484 else if (aug
[0] == 'P')
486 _Unwind_Ptr personality
;
488 p
= read_encoded_value (context
, *p
, p
+ 1, &personality
);
489 fs
->personality
= (_Unwind_Personality_Fn
) personality
;
493 /* "S" indicates a signal frame. */
494 else if (aug
[0] == 'S')
496 fs
->signal_frame
= 1;
500 /* Otherwise we have an unknown augmentation string.
501 Bail unless we saw a 'z' prefix. */
506 return ret
? ret
: p
;
510 /* Decode a DW_OP stack program. Return the top of stack. Push INITIAL
511 onto the stack to start. */
514 execute_stack_op (const unsigned char *op_ptr
, const unsigned char *op_end
,
515 struct _Unwind_Context
*context
, _Unwind_Word initial
)
517 _Unwind_Word stack
[64]; /* ??? Assume this is enough. */
523 while (op_ptr
< op_end
)
525 enum dwarf_location_atom op
= *op_ptr
++;
527 _uleb128_t reg
, utmp
;
528 _sleb128_t offset
, stmp
;
564 result
= op
- DW_OP_lit0
;
568 result
= (_Unwind_Word
) (_Unwind_Ptr
) read_pointer (op_ptr
);
569 op_ptr
+= sizeof (void *);
572 case DW_OP_GNU_encoded_addr
:
575 op_ptr
= read_encoded_value (context
, *op_ptr
, op_ptr
+1, &presult
);
581 result
= read_1u (op_ptr
);
585 result
= read_1s (op_ptr
);
589 result
= read_2u (op_ptr
);
593 result
= read_2s (op_ptr
);
597 result
= read_4u (op_ptr
);
601 result
= read_4s (op_ptr
);
605 result
= read_8u (op_ptr
);
609 result
= read_8s (op_ptr
);
613 op_ptr
= read_uleb128 (op_ptr
, &utmp
);
614 result
= (_Unwind_Word
)utmp
;
617 op_ptr
= read_sleb128 (op_ptr
, &stmp
);
618 result
= (_Unwind_Sword
)stmp
;
653 result
= _Unwind_GetGR (context
, op
- DW_OP_reg0
);
656 op_ptr
= read_uleb128 (op_ptr
, ®
);
657 result
= _Unwind_GetGR (context
, reg
);
692 op_ptr
= read_sleb128 (op_ptr
, &offset
);
693 result
= _Unwind_GetGR (context
, op
- DW_OP_breg0
) + offset
;
696 op_ptr
= read_uleb128 (op_ptr
, ®
);
697 op_ptr
= read_sleb128 (op_ptr
, &offset
);
698 result
= _Unwind_GetGR (context
, reg
) + (_Unwind_Word
)offset
;
702 gcc_assert (stack_elt
);
703 result
= stack
[stack_elt
- 1];
707 gcc_assert (stack_elt
);
713 gcc_assert (offset
< stack_elt
- 1);
714 result
= stack
[stack_elt
- 1 - offset
];
718 gcc_assert (stack_elt
>= 2);
719 result
= stack
[stack_elt
- 2];
725 gcc_assert (stack_elt
>= 2);
726 t
= stack
[stack_elt
- 1];
727 stack
[stack_elt
- 1] = stack
[stack_elt
- 2];
728 stack
[stack_elt
- 2] = t
;
734 _Unwind_Word t1
, t2
, t3
;
736 gcc_assert (stack_elt
>= 3);
737 t1
= stack
[stack_elt
- 1];
738 t2
= stack
[stack_elt
- 2];
739 t3
= stack
[stack_elt
- 3];
740 stack
[stack_elt
- 1] = t2
;
741 stack
[stack_elt
- 2] = t3
;
742 stack
[stack_elt
- 3] = t1
;
747 case DW_OP_deref_size
:
751 case DW_OP_plus_uconst
:
752 /* Unary operations. */
753 gcc_assert (stack_elt
);
756 result
= stack
[stack_elt
];
762 void *ptr
= (void *) (_Unwind_Ptr
) result
;
763 result
= (_Unwind_Ptr
) read_pointer (ptr
);
767 case DW_OP_deref_size
:
769 void *ptr
= (void *) (_Unwind_Ptr
) result
;
773 result
= read_1u (ptr
);
776 result
= read_2u (ptr
);
779 result
= read_4u (ptr
);
782 result
= read_8u (ptr
);
791 if ((_Unwind_Sword
) result
< 0)
800 case DW_OP_plus_uconst
:
801 op_ptr
= read_uleb128 (op_ptr
, &utmp
);
802 result
+= (_Unwind_Word
)utmp
;
828 /* Binary operations. */
829 _Unwind_Word first
, second
;
830 gcc_assert (stack_elt
>= 2);
833 second
= stack
[stack_elt
];
834 first
= stack
[stack_elt
+ 1];
839 result
= second
& first
;
842 result
= (_Unwind_Sword
) second
/ (_Unwind_Sword
) first
;
845 result
= second
- first
;
848 result
= second
% first
;
851 result
= second
* first
;
854 result
= second
| first
;
857 result
= second
+ first
;
860 result
= second
<< first
;
863 result
= second
>> first
;
866 result
= (_Unwind_Sword
) second
>> first
;
869 result
= second
^ first
;
872 result
= (_Unwind_Sword
) second
<= (_Unwind_Sword
) first
;
875 result
= (_Unwind_Sword
) second
>= (_Unwind_Sword
) first
;
878 result
= (_Unwind_Sword
) second
== (_Unwind_Sword
) first
;
881 result
= (_Unwind_Sword
) second
< (_Unwind_Sword
) first
;
884 result
= (_Unwind_Sword
) second
> (_Unwind_Sword
) first
;
887 result
= (_Unwind_Sword
) second
!= (_Unwind_Sword
) first
;
897 offset
= read_2s (op_ptr
);
903 gcc_assert (stack_elt
);
906 offset
= read_2s (op_ptr
);
908 if (stack
[stack_elt
] != 0)
919 /* Most things push a result value. */
920 gcc_assert ((size_t) stack_elt
< sizeof(stack
)/sizeof(*stack
));
921 stack
[stack_elt
++] = result
;
925 /* We were executing this program to get a value. It should be
927 gcc_assert (stack_elt
);
929 return stack
[stack_elt
];
933 /* Decode DWARF 2 call frame information. Takes pointers the
934 instruction sequence to decode, current register information and
935 CIE info, and the PC range to evaluate. */
938 execute_cfa_program (const unsigned char *insn_ptr
,
939 const unsigned char *insn_end
,
940 struct _Unwind_Context
*context
,
941 _Unwind_FrameState
*fs
)
943 struct frame_state_reg_info
*unused_rs
= NULL
;
945 /* Don't allow remember/restore between CIE and FDE programs. */
946 fs
->regs
.prev
= NULL
;
948 /* The comparison with the return address uses < rather than <= because
949 we are only interested in the effects of code before the call; for a
950 noreturn function, the return address may point to unrelated code with
951 a different stack configuration that we are not interested in. We
952 assume that the call itself is unwind info-neutral; if not, or if
953 there are delay instructions that adjust the stack, these must be
954 reflected at the point immediately before the call insn.
955 In signal frames, return address is after last completed instruction,
956 so we add 1 to return address to make the comparison <=. */
957 while (insn_ptr
< insn_end
958 && fs
->pc
< context
->ra
+ _Unwind_IsSignalFrame (context
))
960 unsigned char insn
= *insn_ptr
++;
961 _uleb128_t reg
, utmp
;
962 _sleb128_t offset
, stmp
;
964 if ((insn
& 0xc0) == DW_CFA_advance_loc
)
965 fs
->pc
+= (insn
& 0x3f) * fs
->code_align
;
966 else if ((insn
& 0xc0) == DW_CFA_offset
)
969 insn_ptr
= read_uleb128 (insn_ptr
, &utmp
);
970 offset
= (_Unwind_Sword
) utmp
* fs
->data_align
;
971 reg
= DWARF_REG_TO_UNWIND_COLUMN (reg
);
972 if (UNWIND_COLUMN_IN_RANGE (reg
))
974 fs
->regs
.reg
[reg
].how
= REG_SAVED_OFFSET
;
975 fs
->regs
.reg
[reg
].loc
.offset
= offset
;
978 else if ((insn
& 0xc0) == DW_CFA_restore
)
981 reg
= DWARF_REG_TO_UNWIND_COLUMN (reg
);
982 if (UNWIND_COLUMN_IN_RANGE (reg
))
983 fs
->regs
.reg
[reg
].how
= REG_UNSAVED
;
991 insn_ptr
= read_encoded_value (context
, fs
->fde_encoding
,
993 fs
->pc
= (void *) pc
;
997 case DW_CFA_advance_loc1
:
998 fs
->pc
+= read_1u (insn_ptr
) * fs
->code_align
;
1001 case DW_CFA_advance_loc2
:
1002 fs
->pc
+= read_2u (insn_ptr
) * fs
->code_align
;
1005 case DW_CFA_advance_loc4
:
1006 fs
->pc
+= read_4u (insn_ptr
) * fs
->code_align
;
1010 case DW_CFA_offset_extended
:
1011 insn_ptr
= read_uleb128 (insn_ptr
, ®
);
1012 insn_ptr
= read_uleb128 (insn_ptr
, &utmp
);
1013 offset
= (_Unwind_Sword
) utmp
* fs
->data_align
;
1014 reg
= DWARF_REG_TO_UNWIND_COLUMN (reg
);
1015 if (UNWIND_COLUMN_IN_RANGE (reg
))
1017 fs
->regs
.reg
[reg
].how
= REG_SAVED_OFFSET
;
1018 fs
->regs
.reg
[reg
].loc
.offset
= offset
;
1022 case DW_CFA_restore_extended
:
1023 insn_ptr
= read_uleb128 (insn_ptr
, ®
);
1024 /* FIXME, this is wrong; the CIE might have said that the
1025 register was saved somewhere. */
1026 reg
= DWARF_REG_TO_UNWIND_COLUMN (reg
);
1027 if (UNWIND_COLUMN_IN_RANGE (reg
))
1028 fs
->regs
.reg
[reg
].how
= REG_UNSAVED
;
1031 case DW_CFA_same_value
:
1032 insn_ptr
= read_uleb128 (insn_ptr
, ®
);
1033 reg
= DWARF_REG_TO_UNWIND_COLUMN (reg
);
1034 if (UNWIND_COLUMN_IN_RANGE (reg
))
1035 fs
->regs
.reg
[reg
].how
= REG_UNSAVED
;
1038 case DW_CFA_undefined
:
1039 insn_ptr
= read_uleb128 (insn_ptr
, ®
);
1040 reg
= DWARF_REG_TO_UNWIND_COLUMN (reg
);
1041 if (UNWIND_COLUMN_IN_RANGE (reg
))
1042 fs
->regs
.reg
[reg
].how
= REG_UNDEFINED
;
1048 case DW_CFA_register
:
1051 insn_ptr
= read_uleb128 (insn_ptr
, ®
);
1052 insn_ptr
= read_uleb128 (insn_ptr
, ®2
);
1053 reg
= DWARF_REG_TO_UNWIND_COLUMN (reg
);
1054 if (UNWIND_COLUMN_IN_RANGE (reg
))
1056 fs
->regs
.reg
[reg
].how
= REG_SAVED_REG
;
1057 fs
->regs
.reg
[reg
].loc
.reg
= (_Unwind_Word
)reg2
;
1062 case DW_CFA_remember_state
:
1064 struct frame_state_reg_info
*new_rs
;
1068 unused_rs
= unused_rs
->prev
;
1071 new_rs
= alloca (sizeof (struct frame_state_reg_info
));
1074 fs
->regs
.prev
= new_rs
;
1078 case DW_CFA_restore_state
:
1080 struct frame_state_reg_info
*old_rs
= fs
->regs
.prev
;
1082 old_rs
->prev
= unused_rs
;
1087 case DW_CFA_def_cfa
:
1088 insn_ptr
= read_uleb128 (insn_ptr
, &utmp
);
1089 fs
->regs
.cfa_reg
= (_Unwind_Word
)utmp
;
1090 insn_ptr
= read_uleb128 (insn_ptr
, &utmp
);
1091 fs
->regs
.cfa_offset
= (_Unwind_Word
)utmp
;
1092 fs
->regs
.cfa_how
= CFA_REG_OFFSET
;
1095 case DW_CFA_def_cfa_register
:
1096 insn_ptr
= read_uleb128 (insn_ptr
, &utmp
);
1097 fs
->regs
.cfa_reg
= (_Unwind_Word
)utmp
;
1098 fs
->regs
.cfa_how
= CFA_REG_OFFSET
;
1101 case DW_CFA_def_cfa_offset
:
1102 insn_ptr
= read_uleb128 (insn_ptr
, &utmp
);
1103 fs
->regs
.cfa_offset
= utmp
;
1104 /* cfa_how deliberately not set. */
1107 case DW_CFA_def_cfa_expression
:
1108 fs
->regs
.cfa_exp
= insn_ptr
;
1109 fs
->regs
.cfa_how
= CFA_EXP
;
1110 insn_ptr
= read_uleb128 (insn_ptr
, &utmp
);
1114 case DW_CFA_expression
:
1115 insn_ptr
= read_uleb128 (insn_ptr
, ®
);
1116 reg
= DWARF_REG_TO_UNWIND_COLUMN (reg
);
1117 if (UNWIND_COLUMN_IN_RANGE (reg
))
1119 fs
->regs
.reg
[reg
].how
= REG_SAVED_EXP
;
1120 fs
->regs
.reg
[reg
].loc
.exp
= insn_ptr
;
1122 insn_ptr
= read_uleb128 (insn_ptr
, &utmp
);
1127 case DW_CFA_offset_extended_sf
:
1128 insn_ptr
= read_uleb128 (insn_ptr
, ®
);
1129 insn_ptr
= read_sleb128 (insn_ptr
, &stmp
);
1130 offset
= stmp
* fs
->data_align
;
1131 reg
= DWARF_REG_TO_UNWIND_COLUMN (reg
);
1132 if (UNWIND_COLUMN_IN_RANGE (reg
))
1134 fs
->regs
.reg
[reg
].how
= REG_SAVED_OFFSET
;
1135 fs
->regs
.reg
[reg
].loc
.offset
= offset
;
1139 case DW_CFA_def_cfa_sf
:
1140 insn_ptr
= read_uleb128 (insn_ptr
, &utmp
);
1141 fs
->regs
.cfa_reg
= (_Unwind_Word
)utmp
;
1142 insn_ptr
= read_sleb128 (insn_ptr
, &stmp
);
1143 fs
->regs
.cfa_offset
= (_Unwind_Sword
)stmp
;
1144 fs
->regs
.cfa_how
= CFA_REG_OFFSET
;
1145 fs
->regs
.cfa_offset
*= fs
->data_align
;
1148 case DW_CFA_def_cfa_offset_sf
:
1149 insn_ptr
= read_sleb128 (insn_ptr
, &stmp
);
1150 fs
->regs
.cfa_offset
= (_Unwind_Sword
)stmp
;
1151 fs
->regs
.cfa_offset
*= fs
->data_align
;
1152 /* cfa_how deliberately not set. */
1155 case DW_CFA_val_offset
:
1156 insn_ptr
= read_uleb128 (insn_ptr
, ®
);
1157 insn_ptr
= read_uleb128 (insn_ptr
, &utmp
);
1158 offset
= (_Unwind_Sword
) utmp
* fs
->data_align
;
1159 reg
= DWARF_REG_TO_UNWIND_COLUMN (reg
);
1160 if (UNWIND_COLUMN_IN_RANGE (reg
))
1162 fs
->regs
.reg
[reg
].how
= REG_SAVED_VAL_OFFSET
;
1163 fs
->regs
.reg
[reg
].loc
.offset
= offset
;
1167 case DW_CFA_val_offset_sf
:
1168 insn_ptr
= read_uleb128 (insn_ptr
, ®
);
1169 insn_ptr
= read_sleb128 (insn_ptr
, &stmp
);
1170 offset
= stmp
* fs
->data_align
;
1171 reg
= DWARF_REG_TO_UNWIND_COLUMN (reg
);
1172 if (UNWIND_COLUMN_IN_RANGE (reg
))
1174 fs
->regs
.reg
[reg
].how
= REG_SAVED_VAL_OFFSET
;
1175 fs
->regs
.reg
[reg
].loc
.offset
= offset
;
1179 case DW_CFA_val_expression
:
1180 insn_ptr
= read_uleb128 (insn_ptr
, ®
);
1181 reg
= DWARF_REG_TO_UNWIND_COLUMN (reg
);
1182 if (UNWIND_COLUMN_IN_RANGE (reg
))
1184 fs
->regs
.reg
[reg
].how
= REG_SAVED_VAL_EXP
;
1185 fs
->regs
.reg
[reg
].loc
.exp
= insn_ptr
;
1187 insn_ptr
= read_uleb128 (insn_ptr
, &utmp
);
1191 case DW_CFA_GNU_window_save
:
1192 /* ??? Hardcoded for SPARC register window configuration. */
1193 if (DWARF_FRAME_REGISTERS
>= 32)
1194 for (reg
= 16; reg
< 32; ++reg
)
1196 fs
->regs
.reg
[reg
].how
= REG_SAVED_OFFSET
;
1197 fs
->regs
.reg
[reg
].loc
.offset
= (reg
- 16) * sizeof (void *);
1201 case DW_CFA_GNU_args_size
:
1202 insn_ptr
= read_uleb128 (insn_ptr
, &utmp
);
1203 context
->args_size
= (_Unwind_Word
)utmp
;
1206 case DW_CFA_GNU_negative_offset_extended
:
1207 /* Obsoleted by DW_CFA_offset_extended_sf, but used by
1208 older PowerPC code. */
1209 insn_ptr
= read_uleb128 (insn_ptr
, ®
);
1210 insn_ptr
= read_uleb128 (insn_ptr
, &utmp
);
1211 offset
= (_Unwind_Word
) utmp
* fs
->data_align
;
1212 reg
= DWARF_REG_TO_UNWIND_COLUMN (reg
);
1213 if (UNWIND_COLUMN_IN_RANGE (reg
))
1215 fs
->regs
.reg
[reg
].how
= REG_SAVED_OFFSET
;
1216 fs
->regs
.reg
[reg
].loc
.offset
= -offset
;
1226 /* Given the _Unwind_Context CONTEXT for a stack frame, look up the FDE for
1227 its caller and decode it into FS. This function also sets the
1228 args_size and lsda members of CONTEXT, as they are really information
1229 about the caller's frame. */
1231 static _Unwind_Reason_Code
1232 uw_frame_state_for (struct _Unwind_Context
*context
, _Unwind_FrameState
*fs
)
1234 const struct dwarf_fde
*fde
;
1235 const struct dwarf_cie
*cie
;
1236 const unsigned char *aug
, *insn
, *end
;
1238 memset (fs
, 0, sizeof (*fs
));
1239 context
->args_size
= 0;
1242 if (context
->ra
== 0)
1243 return _URC_END_OF_STACK
;
1245 fde
= _Unwind_Find_FDE (context
->ra
+ _Unwind_IsSignalFrame (context
) - 1,
1249 #ifdef MD_FALLBACK_FRAME_STATE_FOR
1250 /* Couldn't find frame unwind info for this function. Try a
1251 target-specific fallback mechanism. This will necessarily
1252 not provide a personality routine or LSDA. */
1253 return MD_FALLBACK_FRAME_STATE_FOR (context
, fs
);
1255 return _URC_END_OF_STACK
;
1259 fs
->pc
= context
->bases
.func
;
1261 cie
= get_cie (fde
);
1262 insn
= extract_cie_info (cie
, context
, fs
);
1264 /* CIE contained unknown augmentation. */
1265 return _URC_FATAL_PHASE1_ERROR
;
1267 /* First decode all the insns in the CIE. */
1268 end
= (const unsigned char *) next_fde ((const struct dwarf_fde
*) cie
);
1269 execute_cfa_program (insn
, end
, context
, fs
);
1271 /* Locate augmentation for the fde. */
1272 aug
= (const unsigned char *) fde
+ sizeof (*fde
);
1273 aug
+= 2 * size_of_encoded_value (fs
->fde_encoding
);
1278 aug
= read_uleb128 (aug
, &i
);
1281 if (fs
->lsda_encoding
!= DW_EH_PE_omit
)
1285 aug
= read_encoded_value (context
, fs
->lsda_encoding
, aug
, &lsda
);
1286 context
->lsda
= (void *) lsda
;
1289 /* Then the insns in the FDE up to our target PC. */
1292 end
= (const unsigned char *) next_fde (fde
);
1293 execute_cfa_program (insn
, end
, context
, fs
);
1295 return _URC_NO_REASON
;
1298 typedef struct frame_state
1304 long reg_or_offset
[PRE_GCC3_DWARF_FRAME_REGISTERS
+1];
1305 unsigned short cfa_reg
;
1306 unsigned short retaddr_column
;
1307 char saved
[PRE_GCC3_DWARF_FRAME_REGISTERS
+1];
1310 struct frame_state
* __frame_state_for (void *, struct frame_state
*);
1312 /* Called from pre-G++ 3.0 __throw to find the registers to restore for
1313 a given PC_TARGET. The caller should allocate a local variable of
1314 `struct frame_state' and pass its address to STATE_IN. */
1316 struct frame_state
*
1317 __frame_state_for (void *pc_target
, struct frame_state
*state_in
)
1319 struct _Unwind_Context context
;
1320 _Unwind_FrameState fs
;
1323 memset (&context
, 0, sizeof (struct _Unwind_Context
));
1324 if (!ASSUME_EXTENDED_UNWIND_CONTEXT
)
1325 context
.flags
= EXTENDED_CONTEXT_BIT
;
1326 context
.ra
= pc_target
+ 1;
1328 if (uw_frame_state_for (&context
, &fs
) != _URC_NO_REASON
)
1331 /* We have no way to pass a location expression for the CFA to our
1332 caller. It wouldn't understand it anyway. */
1333 if (fs
.regs
.cfa_how
== CFA_EXP
)
1336 for (reg
= 0; reg
< PRE_GCC3_DWARF_FRAME_REGISTERS
+ 1; reg
++)
1338 state_in
->saved
[reg
] = fs
.regs
.reg
[reg
].how
;
1339 switch (state_in
->saved
[reg
])
1342 state_in
->reg_or_offset
[reg
] = fs
.regs
.reg
[reg
].loc
.reg
;
1344 case REG_SAVED_OFFSET
:
1345 state_in
->reg_or_offset
[reg
] = fs
.regs
.reg
[reg
].loc
.offset
;
1348 state_in
->reg_or_offset
[reg
] = 0;
1353 state_in
->cfa_offset
= fs
.regs
.cfa_offset
;
1354 state_in
->cfa_reg
= fs
.regs
.cfa_reg
;
1355 state_in
->retaddr_column
= fs
.retaddr_column
;
1356 state_in
->args_size
= context
.args_size
;
1357 state_in
->eh_ptr
= fs
.eh_ptr
;
1362 typedef union { _Unwind_Ptr ptr
; _Unwind_Word word
; } _Unwind_SpTmp
;
1365 _Unwind_SetSpColumn (struct _Unwind_Context
*context
, void *cfa
,
1366 _Unwind_SpTmp
*tmp_sp
)
1368 int size
= dwarf_reg_size_table
[__builtin_dwarf_sp_column ()];
1370 if (size
== sizeof(_Unwind_Ptr
))
1371 tmp_sp
->ptr
= (_Unwind_Ptr
) cfa
;
1374 gcc_assert (size
== sizeof(_Unwind_Word
));
1375 tmp_sp
->word
= (_Unwind_Ptr
) cfa
;
1377 _Unwind_SetGRPtr (context
, __builtin_dwarf_sp_column (), tmp_sp
);
1381 uw_update_context_1 (struct _Unwind_Context
*context
, _Unwind_FrameState
*fs
)
1383 struct _Unwind_Context orig_context
= *context
;
1387 #ifdef EH_RETURN_STACKADJ_RTX
1388 /* Special handling here: Many machines do not use a frame pointer,
1389 and track the CFA only through offsets from the stack pointer from
1390 one frame to the next. In this case, the stack pointer is never
1391 stored, so it has no saved address in the context. What we do
1392 have is the CFA from the previous stack frame.
1394 In very special situations (such as unwind info for signal return),
1395 there may be location expressions that use the stack pointer as well.
1397 Do this conditionally for one frame. This allows the unwind info
1398 for one frame to save a copy of the stack pointer from the previous
1399 frame, and be able to use much easier CFA mechanisms to do it.
1400 Always zap the saved stack pointer value for the next frame; carrying
1401 the value over from one frame to another doesn't make sense. */
1403 _Unwind_SpTmp tmp_sp
;
1405 if (!_Unwind_GetGRPtr (&orig_context
, __builtin_dwarf_sp_column ()))
1406 _Unwind_SetSpColumn (&orig_context
, context
->cfa
, &tmp_sp
);
1407 _Unwind_SetGRPtr (context
, __builtin_dwarf_sp_column (), NULL
);
1410 /* Compute this frame's CFA. */
1411 switch (fs
->regs
.cfa_how
)
1413 case CFA_REG_OFFSET
:
1414 cfa
= _Unwind_GetPtr (&orig_context
, fs
->regs
.cfa_reg
);
1415 cfa
+= fs
->regs
.cfa_offset
;
1420 const unsigned char *exp
= fs
->regs
.cfa_exp
;
1423 exp
= read_uleb128 (exp
, &len
);
1424 cfa
= (void *) (_Unwind_Ptr
)
1425 execute_stack_op (exp
, exp
+ len
, &orig_context
, 0);
1434 /* Compute the addresses of all registers saved in this frame. */
1435 for (i
= 0; i
< DWARF_FRAME_REGISTERS
+ 1; ++i
)
1436 switch (fs
->regs
.reg
[i
].how
)
1442 case REG_SAVED_OFFSET
:
1443 _Unwind_SetGRPtr (context
, i
,
1444 (void *) (cfa
+ fs
->regs
.reg
[i
].loc
.offset
));
1448 if (_Unwind_GRByValue (&orig_context
, fs
->regs
.reg
[i
].loc
.reg
))
1449 _Unwind_SetGRValue (context
, i
,
1450 _Unwind_GetGR (&orig_context
,
1451 fs
->regs
.reg
[i
].loc
.reg
));
1453 _Unwind_SetGRPtr (context
, i
,
1454 _Unwind_GetGRPtr (&orig_context
,
1455 fs
->regs
.reg
[i
].loc
.reg
));
1460 const unsigned char *exp
= fs
->regs
.reg
[i
].loc
.exp
;
1464 exp
= read_uleb128 (exp
, &len
);
1465 val
= execute_stack_op (exp
, exp
+ len
, &orig_context
,
1467 _Unwind_SetGRPtr (context
, i
, (void *) val
);
1471 case REG_SAVED_VAL_OFFSET
:
1472 _Unwind_SetGRValue (context
, i
,
1473 (_Unwind_Internal_Ptr
)
1474 (cfa
+ fs
->regs
.reg
[i
].loc
.offset
));
1477 case REG_SAVED_VAL_EXP
:
1479 const unsigned char *exp
= fs
->regs
.reg
[i
].loc
.exp
;
1483 exp
= read_uleb128 (exp
, &len
);
1484 val
= execute_stack_op (exp
, exp
+ len
, &orig_context
,
1486 _Unwind_SetGRValue (context
, i
, val
);
1491 _Unwind_SetSignalFrame (context
, fs
->signal_frame
);
1493 #ifdef MD_FROB_UPDATE_CONTEXT
1494 MD_FROB_UPDATE_CONTEXT (context
, fs
);
1498 /* CONTEXT describes the unwind state for a frame, and FS describes the FDE
1499 of its caller. Update CONTEXT to refer to the caller as well. Note
1500 that the args_size and lsda members are not updated here, but later in
1501 uw_frame_state_for. */
1504 uw_update_context (struct _Unwind_Context
*context
, _Unwind_FrameState
*fs
)
1506 uw_update_context_1 (context
, fs
);
1508 /* In general this unwinder doesn't make any distinction between
1509 undefined and same_value rule. Call-saved registers are assumed
1510 to have same_value rule by default and explicit undefined
1511 rule is handled like same_value. The only exception is
1512 DW_CFA_undefined on retaddr_column which is supposed to
1513 mark outermost frame in DWARF 3. */
1514 if (fs
->regs
.reg
[DWARF_REG_TO_UNWIND_COLUMN (fs
->retaddr_column
)].how
1516 /* uw_frame_state_for uses context->ra == 0 check to find outermost
1520 /* Compute the return address now, since the return address column
1521 can change from frame to frame. */
1522 context
->ra
= __builtin_extract_return_addr
1523 (_Unwind_GetPtr (context
, fs
->retaddr_column
));
1527 uw_advance_context (struct _Unwind_Context
*context
, _Unwind_FrameState
*fs
)
1529 uw_update_context (context
, fs
);
1532 /* Fill in CONTEXT for top-of-stack. The only valid registers at this
1533 level will be the return address and the CFA. */
1535 #define uw_init_context(CONTEXT) \
1538 /* Do any necessary initialization to access arbitrary stack frames. \
1539 On the SPARC, this means flushing the register windows. */ \
1540 __builtin_unwind_init (); \
1541 uw_init_context_1 (CONTEXT, __builtin_dwarf_cfa (), \
1542 __builtin_return_address (0)); \
1547 init_dwarf_reg_size_table (void)
1549 __builtin_init_dwarf_reg_size_table (dwarf_reg_size_table
);
1552 static void __attribute__((noinline
))
1553 uw_init_context_1 (struct _Unwind_Context
*context
,
1554 void *outer_cfa
, void *outer_ra
)
1556 void *ra
= __builtin_extract_return_addr (__builtin_return_address (0));
1557 _Unwind_FrameState fs
;
1558 _Unwind_SpTmp sp_slot
;
1559 _Unwind_Reason_Code code
;
1561 memset (context
, 0, sizeof (struct _Unwind_Context
));
1563 if (!ASSUME_EXTENDED_UNWIND_CONTEXT
)
1564 context
->flags
= EXTENDED_CONTEXT_BIT
;
1566 code
= uw_frame_state_for (context
, &fs
);
1567 gcc_assert (code
== _URC_NO_REASON
);
1571 static __gthread_once_t once_regsizes
= __GTHREAD_ONCE_INIT
;
1572 if (__gthread_once (&once_regsizes
, init_dwarf_reg_size_table
) != 0
1573 && dwarf_reg_size_table
[0] == 0)
1574 init_dwarf_reg_size_table ();
1577 if (dwarf_reg_size_table
[0] == 0)
1578 init_dwarf_reg_size_table ();
1581 /* Force the frame state to use the known cfa value. */
1582 _Unwind_SetSpColumn (context
, outer_cfa
, &sp_slot
);
1583 fs
.regs
.cfa_how
= CFA_REG_OFFSET
;
1584 fs
.regs
.cfa_reg
= __builtin_dwarf_sp_column ();
1585 fs
.regs
.cfa_offset
= 0;
1587 uw_update_context_1 (context
, &fs
);
1589 /* If the return address column was saved in a register in the
1590 initialization context, then we can't see it in the given
1591 call frame data. So have the initialization context tell us. */
1592 context
->ra
= __builtin_extract_return_addr (outer_ra
);
1595 static void _Unwind_DebugHook (void *, void *)
1596 __attribute__ ((__noinline__
, __used__
, __noclone__
));
1598 /* This function is called during unwinding. It is intended as a hook
1599 for a debugger to intercept exceptions. CFA is the CFA of the
1600 target frame. HANDLER is the PC to which control will be
1603 _Unwind_DebugHook (void *cfa
__attribute__ ((__unused__
)),
1604 void *handler
__attribute__ ((__unused__
)))
1606 /* We only want to use stap probes starting with v3. Earlier
1607 versions added too much startup cost. */
1608 #if defined (HAVE_SYS_SDT_H) && defined (STAP_PROBE2) && _SDT_NOTE_TYPE >= 3
1609 STAP_PROBE2 (libgcc
, unwind
, cfa
, handler
);
1615 /* Install TARGET into CURRENT so that we can return to it. This is a
1616 macro because __builtin_eh_return must be invoked in the context of
1619 #define uw_install_context(CURRENT, TARGET) \
1622 long offset = uw_install_context_1 ((CURRENT), (TARGET)); \
1623 void *handler = __builtin_frob_return_addr ((TARGET)->ra); \
1624 _Unwind_DebugHook ((TARGET)->cfa, handler); \
1625 __builtin_eh_return (offset, handler); \
1630 uw_install_context_1 (struct _Unwind_Context
*current
,
1631 struct _Unwind_Context
*target
)
1634 _Unwind_SpTmp sp_slot
;
1636 /* If the target frame does not have a saved stack pointer,
1637 then set up the target's CFA. */
1638 if (!_Unwind_GetGRPtr (target
, __builtin_dwarf_sp_column ()))
1639 _Unwind_SetSpColumn (target
, target
->cfa
, &sp_slot
);
1641 for (i
= 0; i
< DWARF_FRAME_REGISTERS
; ++i
)
1643 void *c
= (void *) (_Unwind_Internal_Ptr
) current
->reg
[i
];
1644 void *t
= (void *) (_Unwind_Internal_Ptr
)target
->reg
[i
];
1646 gcc_assert (current
->by_value
[i
] == 0);
1647 if (target
->by_value
[i
] && c
)
1651 if (dwarf_reg_size_table
[i
] == sizeof (_Unwind_Word
))
1653 w
= (_Unwind_Internal_Ptr
) t
;
1654 memcpy (c
, &w
, sizeof (_Unwind_Word
));
1658 gcc_assert (dwarf_reg_size_table
[i
] == sizeof (_Unwind_Ptr
));
1659 p
= (_Unwind_Internal_Ptr
) t
;
1660 memcpy (c
, &p
, sizeof (_Unwind_Ptr
));
1663 else if (t
&& c
&& t
!= c
)
1664 memcpy (c
, t
, dwarf_reg_size_table
[i
]);
1667 /* If the current frame doesn't have a saved stack pointer, then we
1668 need to rely on EH_RETURN_STACKADJ_RTX to get our target stack
1669 pointer value reloaded. */
1670 if (!_Unwind_GetGRPtr (current
, __builtin_dwarf_sp_column ()))
1674 target_cfa
= _Unwind_GetPtr (target
, __builtin_dwarf_sp_column ());
1676 /* We adjust SP by the difference between CURRENT and TARGET's CFA. */
1677 if (STACK_GROWS_DOWNWARD
)
1678 return target_cfa
- current
->cfa
+ target
->args_size
;
1680 return current
->cfa
- target_cfa
- target
->args_size
;
1685 static inline _Unwind_Ptr
1686 uw_identify_context (struct _Unwind_Context
*context
)
1688 /* The CFA is not sufficient to disambiguate the context of a function
1689 interrupted by a signal before establishing its frame and the context
1690 of the signal itself. */
1691 if (STACK_GROWS_DOWNWARD
)
1692 return _Unwind_GetCFA (context
) - _Unwind_IsSignalFrame (context
);
1694 return _Unwind_GetCFA (context
) + _Unwind_IsSignalFrame (context
);
1698 #include "unwind.inc"
1700 #if defined (USE_GAS_SYMVER) && defined (SHARED) && defined (USE_LIBUNWIND_EXCEPTIONS)
1701 alias (_Unwind_Backtrace
);
1702 alias (_Unwind_DeleteException
);
1703 alias (_Unwind_FindEnclosingFunction
);
1704 alias (_Unwind_ForcedUnwind
);
1705 alias (_Unwind_GetDataRelBase
);
1706 alias (_Unwind_GetTextRelBase
);
1707 alias (_Unwind_GetCFA
);
1708 alias (_Unwind_GetGR
);
1709 alias (_Unwind_GetIP
);
1710 alias (_Unwind_GetLanguageSpecificData
);
1711 alias (_Unwind_GetRegionStart
);
1712 alias (_Unwind_RaiseException
);
1713 alias (_Unwind_Resume
);
1714 alias (_Unwind_Resume_or_Rethrow
);
1715 alias (_Unwind_SetGR
);
1716 alias (_Unwind_SetIP
);
1719 #endif /* !USING_SJLJ_EXCEPTIONS */