1 /* ARM EABI compliant unwinding routines.
2 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
3 Contributed by Paul Brook
5 This file is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
10 In addition to the permissions in the GNU General Public License, the
11 Free Software Foundation gives you unlimited permission to link the
12 compiled version of this file into combinations with other programs,
13 and to distribute those combinations without any restriction coming
14 from the use of this file. (The General Public License restrictions
15 do apply in other respects; for example, they cover modification of
16 the file, and distribution when not linked into a combine
19 This file is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; see the file COPYING. If not, write to
26 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
27 Boston, MA 02110-1301, USA. */
30 /* We add a prototype for abort here to avoid creating a dependency on
32 extern void abort (void);
34 /* Definitions for C++ runtime support routines. We make these weak
35 declarations to avoid pulling in libsupc++ unnecessarily. */
36 typedef unsigned char bool;
38 typedef struct _ZSt9type_info type_info
; /* This names C++ type_info type */
40 void __attribute__((weak
)) __cxa_call_unexpected(_Unwind_Control_Block
*ucbp
);
41 bool __attribute__((weak
)) __cxa_begin_cleanup(_Unwind_Control_Block
*ucbp
);
42 bool __attribute__((weak
)) __cxa_type_match(_Unwind_Control_Block
*ucbp
,
43 const type_info
*rttip
,
44 void **matched_object
);
46 _Unwind_Ptr
__attribute__((weak
))
47 __gnu_Unwind_Find_exidx (_Unwind_Ptr
, int *);
55 #define EXIDX_CANTUNWIND 1
56 #define uint32_highbit (((_uw) 1) << 31)
58 #define UCB_FORCED_STOP_FN(ucbp) ((ucbp)->unwinder_cache.reserved1)
59 #define UCB_PR_ADDR(ucbp) ((ucbp)->unwinder_cache.reserved2)
60 #define UCB_SAVED_CALLSITE_ADDR(ucbp) ((ucbp)->unwinder_cache.reserved3)
61 #define UCB_FORCED_STOP_ARG(ucbp) ((ucbp)->unwinder_cache.reserved4)
68 /* We use normal integer types here to avoid the compiler generating
69 coprocessor instructions. */
86 /* Unwind descriptors. */
100 /* The ABI specifies that the unwind routines may only use core registers,
101 except when actually manipulating coprocessor state. This allows
102 us to write one implementation that works on all platforms by
103 demand-saving coprocessor registers.
105 During unwinding we hold the coprocessor state in the actual hardware
106 registers and allocate demand-save areas for use during phase1
111 /* The first fields must be the same as a phase2_vrs. */
112 _uw demand_save_flags
;
113 struct core_regs core
;
114 _uw prev_sp
; /* Only valid during forced unwinding. */
119 #define DEMAND_SAVE_VFP 1
121 /* This must match the structure created by the assembly wrappers. */
124 _uw demand_save_flags
;
125 struct core_regs core
;
129 /* An exception index table entry. */
131 typedef struct __EIT_entry
137 /* Assembly helper functions. */
139 /* Restore core register state. Never returns. */
140 void __attribute__((noreturn
)) restore_core_regs (struct core_regs
*);
143 /* Coprocessor register state manipulation functions. */
145 void __gnu_Unwind_Save_VFP (struct vfp_regs
* p
);
146 void __gnu_Unwind_Restore_VFP (struct vfp_regs
* p
);
148 /* Restore coprocessor state after phase1 unwinding. */
150 restore_non_core_regs (phase1_vrs
* vrs
)
152 if ((vrs
->demand_save_flags
& DEMAND_SAVE_VFP
) == 0)
153 __gnu_Unwind_Restore_VFP (&vrs
->vfp
);
156 /* A better way to do this would probably be to compare the absolute address
157 with a segment relative relocation of the same symbol. */
159 extern int __text_start
;
160 extern int __data_start
;
162 /* The exception index table location. */
163 extern __EIT_entry __exidx_start
;
164 extern __EIT_entry __exidx_end
;
166 /* ABI defined personality routines. */
167 extern _Unwind_Reason_Code
__aeabi_unwind_cpp_pr0 (_Unwind_State
,
168 _Unwind_Control_Block
*, _Unwind_Context
*);// __attribute__((weak));
169 extern _Unwind_Reason_Code
__aeabi_unwind_cpp_pr1 (_Unwind_State
,
170 _Unwind_Control_Block
*, _Unwind_Context
*) __attribute__((weak
));
171 extern _Unwind_Reason_Code
__aeabi_unwind_cpp_pr2 (_Unwind_State
,
172 _Unwind_Control_Block
*, _Unwind_Context
*) __attribute__((weak
));
174 /* ABI defined routine to store a virtual register to memory. */
176 _Unwind_VRS_Result
_Unwind_VRS_Get (_Unwind_Context
*context
,
177 _Unwind_VRS_RegClass regclass
,
179 _Unwind_VRS_DataRepresentation representation
,
182 phase1_vrs
*vrs
= (phase1_vrs
*) context
;
187 if (representation
!= _UVRSD_UINT32
189 return _UVRSR_FAILED
;
190 *(_uw
*) valuep
= vrs
->core
.r
[regno
];
197 return _UVRSR_NOT_IMPLEMENTED
;
200 return _UVRSR_FAILED
;
205 /* ABI defined function to load a virtual register from memory. */
207 _Unwind_VRS_Result
_Unwind_VRS_Set (_Unwind_Context
*context
,
208 _Unwind_VRS_RegClass regclass
,
210 _Unwind_VRS_DataRepresentation representation
,
213 phase1_vrs
*vrs
= (phase1_vrs
*) context
;
218 if (representation
!= _UVRSD_UINT32
220 return _UVRSR_FAILED
;
222 vrs
->core
.r
[regno
] = *(_uw
*) valuep
;
229 return _UVRSR_NOT_IMPLEMENTED
;
232 return _UVRSR_FAILED
;
237 /* ABI defined function to pop registers off the stack. */
239 _Unwind_VRS_Result
_Unwind_VRS_Pop (_Unwind_Context
*context
,
240 _Unwind_VRS_RegClass regclass
,
242 _Unwind_VRS_DataRepresentation representation
)
244 phase1_vrs
*vrs
= (phase1_vrs
*) context
;
254 if (representation
!= _UVRSD_UINT32
)
255 return _UVRSR_FAILED
;
257 mask
= discriminator
& 0xffff;
258 ptr
= (_uw
*) vrs
->core
.r
[R_SP
];
259 /* Pop the requested registers. */
260 for (i
= 0; i
< 16; i
++)
263 vrs
->core
.r
[i
] = *(ptr
++);
265 /* Writeback the stack pointer value if it wasn't restored. */
266 if ((mask
& (1 << R_SP
)) == 0)
267 vrs
->core
.r
[R_SP
] = (_uw
) ptr
;
273 _uw start
= discriminator
>> 16;
274 _uw count
= discriminator
& 0xffff;
279 if ((representation
!= _UVRSD_VFPX
&& representation
!= _UVRSD_DOUBLE
)
280 || start
+ count
> 16)
281 return _UVRSR_FAILED
;
283 if (vrs
->demand_save_flags
& DEMAND_SAVE_VFP
)
285 /* Demand-save resisters for stage1. */
286 vrs
->demand_save_flags
&= ~DEMAND_SAVE_VFP
;
287 __gnu_Unwind_Save_VFP (&vrs
->vfp
);
290 /* Restore the registers from the stack. Do this by saving the
291 current VFP registers to a memory area, moving the in-memory
292 values into that area, and restoring from the whole area.
293 For _UVRSD_VFPX we assume FSTMX standard format 1. */
294 __gnu_Unwind_Save_VFP (&tmp
);
296 /* The stack address is only guaranteed to be word aligned, so
297 we can't use doubleword copies. */
298 sp
= (_uw
*) vrs
->core
.r
[R_SP
];
299 dest
= (_uw
*) &tmp
.d
[start
];
304 /* Skip the pad word */
305 if (representation
== _UVRSD_VFPX
)
308 /* Set the new stack pointer. */
309 vrs
->core
.r
[R_SP
] = (_uw
) sp
;
311 /* Reload the registers. */
312 __gnu_Unwind_Restore_VFP (&tmp
);
319 return _UVRSR_NOT_IMPLEMENTED
;
322 return _UVRSR_FAILED
;
327 /* Core unwinding functions. */
329 /* Calculate the address encoded by a 31-bit self-relative offset at address
332 selfrel_offset31 (const _uw
*p
)
337 /* Sign extend to 32 bits. */
338 if (offset
& (1 << 30))
341 return offset
+ (_uw
) p
;
345 /* Perform a binary search for RETURN_ADDRESS in TABLE. The table contains
348 static const __EIT_entry
*
349 search_EIT_table (const __EIT_entry
* table
, int nrec
, _uw return_address
)
356 return (__EIT_entry
*) 0;
363 n
= (left
+ right
) / 2;
364 this_fn
= selfrel_offset31 (&table
[n
].fnoffset
);
366 next_fn
= selfrel_offset31 (&table
[n
+ 1].fnoffset
) - 1;
368 next_fn
= (_uw
)0 - 1;
370 if (return_address
< this_fn
)
373 return (__EIT_entry
*) 0;
376 else if (return_address
<= next_fn
)
383 /* Find the exception index table eintry for the given address.
384 Fill in the relevant fields of the UCB.
385 Returns _URC_FAILURE if an error occurred, _URC_OK on success. */
387 static _Unwind_Reason_Code
388 get_eit_entry (_Unwind_Control_Block
*ucbp
, _uw return_address
)
390 const __EIT_entry
* eitp
;
393 /* The return address is the address of the instruction following the
394 call instruction (plus one in thumb mode). If this was the last
395 instruction in the function the address will lie in the following
396 function. Subtract 2 from the address so that it points within the call
397 instruction itself. */
400 if (__gnu_Unwind_Find_exidx
)
402 eitp
= (const __EIT_entry
*) __gnu_Unwind_Find_exidx (return_address
,
406 UCB_PR_ADDR (ucbp
) = 0;
412 eitp
= &__exidx_start
;
413 nrec
= &__exidx_end
- &__exidx_start
;
416 eitp
= search_EIT_table (eitp
, nrec
, return_address
);
420 UCB_PR_ADDR (ucbp
) = 0;
423 ucbp
->pr_cache
.fnstart
= selfrel_offset31 (&eitp
->fnoffset
);
425 /* Can this frame be unwound at all? */
426 if (eitp
->content
== EXIDX_CANTUNWIND
)
428 UCB_PR_ADDR (ucbp
) = 0;
429 return _URC_END_OF_STACK
;
432 /* Obtain the address of the "real" __EHT_Header word. */
434 if (eitp
->content
& uint32_highbit
)
436 /* It is immediate data. */
437 ucbp
->pr_cache
.ehtp
= (_Unwind_EHT_Header
*)&eitp
->content
;
438 ucbp
->pr_cache
.additional
= 1;
442 /* The low 31 bits of the content field are a self-relative
443 offset to an _Unwind_EHT_Entry structure. */
444 ucbp
->pr_cache
.ehtp
=
445 (_Unwind_EHT_Header
*) selfrel_offset31 (&eitp
->content
);
446 ucbp
->pr_cache
.additional
= 0;
449 /* Discover the personality routine address. */
450 if (*ucbp
->pr_cache
.ehtp
& (1u << 31))
452 /* One of the predefined standard routines. */
453 _uw idx
= (*(_uw
*) ucbp
->pr_cache
.ehtp
>> 24) & 0xf;
455 UCB_PR_ADDR (ucbp
) = (_uw
) &__aeabi_unwind_cpp_pr0
;
457 UCB_PR_ADDR (ucbp
) = (_uw
) &__aeabi_unwind_cpp_pr1
;
459 UCB_PR_ADDR (ucbp
) = (_uw
) &__aeabi_unwind_cpp_pr2
;
462 UCB_PR_ADDR (ucbp
) = 0;
468 /* Execute region offset to PR */
469 UCB_PR_ADDR (ucbp
) = selfrel_offset31 (ucbp
->pr_cache
.ehtp
);
475 /* Perform phase2 unwinding. VRS is the initial virtual register state. */
477 static void __attribute__((noreturn
))
478 unwind_phase2 (_Unwind_Control_Block
* ucbp
, phase2_vrs
* vrs
)
480 _Unwind_Reason_Code pr_result
;
484 /* Find the entry for this routine. */
485 if (get_eit_entry (ucbp
, vrs
->core
.r
[R_PC
]) != _URC_OK
)
488 UCB_SAVED_CALLSITE_ADDR (ucbp
) = vrs
->core
.r
[R_PC
];
490 /* Call the pr to decide what to do. */
491 pr_result
= ((personality_routine
) UCB_PR_ADDR (ucbp
))
492 (_US_UNWIND_FRAME_STARTING
, ucbp
, (_Unwind_Context
*) vrs
);
494 while (pr_result
== _URC_CONTINUE_UNWIND
);
496 if (pr_result
!= _URC_INSTALL_CONTEXT
)
499 restore_core_regs (&vrs
->core
);
502 /* Perform phase2 forced unwinding. */
504 static _Unwind_Reason_Code
505 unwind_phase2_forced (_Unwind_Control_Block
*ucbp
, phase2_vrs
*entry_vrs
,
508 _Unwind_Stop_Fn stop_fn
= (_Unwind_Stop_Fn
) UCB_FORCED_STOP_FN (ucbp
);
509 void *stop_arg
= (void *)UCB_FORCED_STOP_ARG (ucbp
);
510 _Unwind_Reason_Code pr_result
= 0;
511 /* We use phase1_vrs here even though we do not demand save, for the
513 phase1_vrs saved_vrs
, next_vrs
;
515 /* Save the core registers. */
516 saved_vrs
.core
= entry_vrs
->core
;
517 /* We don't need to demand-save the non-core registers, because we
518 unwind in a single pass. */
519 saved_vrs
.demand_save_flags
= 0;
521 /* Unwind until we reach a propagation barrier. */
524 _Unwind_State action
;
525 _Unwind_Reason_Code entry_code
;
526 _Unwind_Reason_Code stop_code
;
528 /* Find the entry for this routine. */
529 entry_code
= get_eit_entry (ucbp
, saved_vrs
.core
.r
[R_PC
]);
533 action
= _US_UNWIND_FRAME_RESUME
| _US_FORCE_UNWIND
;
537 action
= _US_UNWIND_FRAME_STARTING
| _US_FORCE_UNWIND
;
539 if (entry_code
== _URC_OK
)
541 UCB_SAVED_CALLSITE_ADDR (ucbp
) = saved_vrs
.core
.r
[R_PC
];
543 next_vrs
= saved_vrs
;
545 /* Call the pr to decide what to do. */
546 pr_result
= ((personality_routine
) UCB_PR_ADDR (ucbp
))
547 (action
, ucbp
, (void *) &next_vrs
);
549 saved_vrs
.prev_sp
= next_vrs
.core
.r
[R_SP
];
553 /* Treat any failure as the end of unwinding, to cope more
554 gracefully with missing EH information. Mixed EH and
555 non-EH within one object will usually result in failure,
556 because the .ARM.exidx tables do not indicate the end
557 of the code to which they apply; but mixed EH and non-EH
558 shared objects should return an unwind failure at the
559 entry of a non-EH shared object. */
560 action
|= _US_END_OF_STACK
;
562 saved_vrs
.prev_sp
= saved_vrs
.core
.r
[R_SP
];
565 stop_code
= stop_fn (1, action
, ucbp
->exception_class
, ucbp
,
566 (void *)&saved_vrs
, stop_arg
);
567 if (stop_code
!= _URC_NO_REASON
)
570 if (entry_code
!= _URC_OK
)
573 saved_vrs
= next_vrs
;
575 while (pr_result
== _URC_CONTINUE_UNWIND
);
577 if (pr_result
!= _URC_INSTALL_CONTEXT
)
579 /* Some sort of failure has occurred in the pr and probably the
580 pr returned _URC_FAILURE. */
584 restore_core_regs (&saved_vrs
.core
);
587 /* This is a very limited implementation of _Unwind_GetCFA. It returns
588 the stack pointer as it is about to be unwound, and is only valid
589 while calling the stop function during forced unwinding. If the
590 current personality routine result is going to run a cleanup, this
591 will not be the CFA; but when the frame is really unwound, it will
595 _Unwind_GetCFA (_Unwind_Context
*context
)
597 return ((phase1_vrs
*) context
)->prev_sp
;
600 /* Perform phase1 unwinding. UCBP is the exception being thrown, and
601 entry_VRS is the register state on entry to _Unwind_RaiseException. */
604 __gnu_Unwind_RaiseException (_Unwind_Control_Block
*, phase2_vrs
*);
607 __gnu_Unwind_RaiseException (_Unwind_Control_Block
* ucbp
,
608 phase2_vrs
* entry_vrs
)
610 phase1_vrs saved_vrs
;
611 _Unwind_Reason_Code pr_result
;
613 /* Set the pc to the call site. */
614 entry_vrs
->core
.r
[R_PC
] = entry_vrs
->core
.r
[R_LR
];
616 /* Save the core registers. */
617 saved_vrs
.core
= entry_vrs
->core
;
618 /* Set demand-save flags. */
619 saved_vrs
.demand_save_flags
= ~(_uw
) 0;
621 /* Unwind until we reach a propagation barrier. */
624 /* Find the entry for this routine. */
625 if (get_eit_entry (ucbp
, saved_vrs
.core
.r
[R_PC
]) != _URC_OK
)
628 /* Call the pr to decide what to do. */
629 pr_result
= ((personality_routine
) UCB_PR_ADDR (ucbp
))
630 (_US_VIRTUAL_UNWIND_FRAME
, ucbp
, (void *) &saved_vrs
);
632 while (pr_result
== _URC_CONTINUE_UNWIND
);
634 /* We've unwound as far as we want to go, so restore the original
636 restore_non_core_regs (&saved_vrs
);
637 if (pr_result
!= _URC_HANDLER_FOUND
)
639 /* Some sort of failure has occurred in the pr and probably the
640 pr returned _URC_FAILURE. */
644 unwind_phase2 (ucbp
, entry_vrs
);
647 /* Resume unwinding after a cleanup has been run. UCBP is the exception
648 being thrown and ENTRY_VRS is the register state on entry to
651 __gnu_Unwind_ForcedUnwind (_Unwind_Control_Block
*,
652 _Unwind_Stop_Fn
, void *, phase2_vrs
*);
655 __gnu_Unwind_ForcedUnwind (_Unwind_Control_Block
*ucbp
,
656 _Unwind_Stop_Fn stop_fn
, void *stop_arg
,
657 phase2_vrs
*entry_vrs
)
659 UCB_FORCED_STOP_FN (ucbp
) = (_uw
) stop_fn
;
660 UCB_FORCED_STOP_ARG (ucbp
) = (_uw
) stop_arg
;
662 /* Set the pc to the call site. */
663 entry_vrs
->core
.r
[R_PC
] = entry_vrs
->core
.r
[R_LR
];
665 return unwind_phase2_forced (ucbp
, entry_vrs
, 0);
669 __gnu_Unwind_Resume (_Unwind_Control_Block
*, phase2_vrs
*);
672 __gnu_Unwind_Resume (_Unwind_Control_Block
* ucbp
, phase2_vrs
* entry_vrs
)
674 _Unwind_Reason_Code pr_result
;
676 /* Recover the saved address. */
677 entry_vrs
->core
.r
[R_PC
] = UCB_SAVED_CALLSITE_ADDR (ucbp
);
679 if (UCB_FORCED_STOP_FN (ucbp
))
681 unwind_phase2_forced (ucbp
, entry_vrs
, 1);
683 /* We can't return failure at this point. */
687 /* Call the cached PR. */
688 pr_result
= ((personality_routine
) UCB_PR_ADDR (ucbp
))
689 (_US_UNWIND_FRAME_RESUME
, ucbp
, (_Unwind_Context
*) entry_vrs
);
693 case _URC_INSTALL_CONTEXT
:
694 /* Upload the registers to enter the landing pad. */
695 restore_core_regs (&entry_vrs
->core
);
697 case _URC_CONTINUE_UNWIND
:
698 /* Continue unwinding the next frame. */
699 unwind_phase2 (ucbp
, entry_vrs
);
707 __gnu_Unwind_Resume_or_Rethrow (_Unwind_Control_Block
*, phase2_vrs
*);
710 __gnu_Unwind_Resume_or_Rethrow (_Unwind_Control_Block
* ucbp
,
711 phase2_vrs
* entry_vrs
)
713 if (!UCB_FORCED_STOP_FN (ucbp
))
714 return __gnu_Unwind_RaiseException (ucbp
, entry_vrs
);
716 /* Set the pc to the call site. */
717 entry_vrs
->core
.r
[R_PC
] = entry_vrs
->core
.r
[R_LR
];
718 /* Continue unwinding the next frame. */
719 return unwind_phase2_forced (ucbp
, entry_vrs
, 0);
722 /* Clean up an exception object when unwinding is complete. */
724 _Unwind_Complete (_Unwind_Control_Block
* ucbp
__attribute__((unused
)))
729 /* Get the _Unwind_Control_Block from an _Unwind_Context. */
731 static inline _Unwind_Control_Block
*
732 unwind_UCB_from_context (_Unwind_Context
* context
)
734 return (_Unwind_Control_Block
*) _Unwind_GetGR (context
, R_IP
);
738 /* Free an exception. */
741 _Unwind_DeleteException (_Unwind_Exception
* exc
)
743 if (exc
->exception_cleanup
)
744 (*exc
->exception_cleanup
) (_URC_FOREIGN_EXCEPTION_CAUGHT
, exc
);
748 /* Common implementation for ARM ABI defined personality routines.
749 ID is the index of the personality routine, other arguments are as defined
750 by __aeabi_unwind_cpp_pr{0,1,2}. */
752 static _Unwind_Reason_Code
753 __gnu_unwind_pr_common (_Unwind_State state
,
754 _Unwind_Control_Block
*ucbp
,
755 _Unwind_Context
*context
,
758 __gnu_unwind_state uws
;
763 int phase2_call_unexpected_after_unwind
= 0;
765 int forced_unwind
= state
& _US_FORCE_UNWIND
;
767 state
&= _US_ACTION_MASK
;
769 data
= (_uw
*) ucbp
->pr_cache
.ehtp
;
770 uws
.data
= *(data
++);
780 uws
.words_left
= (uws
.data
>> 16) & 0xff;
783 data
+= uws
.words_left
;
786 /* Restore the saved pointer. */
787 if (state
== _US_UNWIND_FRAME_RESUME
)
788 data
= (_uw
*) ucbp
->cleanup_cache
.bitpattern
[0];
790 if ((ucbp
->pr_cache
.additional
& 1) == 0)
792 /* Process descriptors. */
800 len
= ((EHT32
*) data
)->length
;
801 offset
= ((EHT32
*) data
)->offset
;
806 len
= ((EHT16
*) data
)->length
;
807 offset
= ((EHT16
*) data
)->offset
;
811 fnstart
= ucbp
->pr_cache
.fnstart
+ (offset
& ~1);
812 addr
= _Unwind_GetGR (context
, R_PC
);
813 in_range
= (fnstart
<= addr
&& addr
< fnstart
+ (len
& ~1));
815 switch (((offset
& 1) << 1) | (len
& 1))
819 if (state
!= _US_VIRTUAL_UNWIND_FRAME
822 /* Cleanup in range, and we are running cleanups. */
825 /* Landing pad address is 31-bit pc-relative offset. */
826 lp
= selfrel_offset31 (data
);
828 /* Save the exception data pointer. */
829 ucbp
->cleanup_cache
.bitpattern
[0] = (_uw
) data
;
830 if (!__cxa_begin_cleanup (ucbp
))
832 /* Setup the VRS to enter the landing pad. */
833 _Unwind_SetGR (context
, R_PC
, lp
);
834 return _URC_INSTALL_CONTEXT
;
836 /* Cleanup not in range, or we are in stage 1. */
842 if (state
== _US_VIRTUAL_UNWIND_FRAME
)
846 /* Check for a barrier. */
850 /* Check for no-throw areas. */
851 if (data
[1] == (_uw
) -2)
854 /* The thrown object immediately follows the ECB. */
855 matched
= (void *)(ucbp
+ 1);
856 if (data
[1] != (_uw
) -1)
858 /* Match a catch specification. */
859 rtti
= _Unwind_decode_target2 ((_uw
) &data
[1]);
860 if (!__cxa_type_match (ucbp
, (type_info
*) rtti
,
867 ucbp
->barrier_cache
.sp
=
868 _Unwind_GetGR (context
, R_SP
);
869 ucbp
->barrier_cache
.bitpattern
[0] = (_uw
) matched
;
870 ucbp
->barrier_cache
.bitpattern
[1] = (_uw
) data
;
871 return _URC_HANDLER_FOUND
;
874 /* Handler out of range, or not matched. */
876 else if (ucbp
->barrier_cache
.sp
== _Unwind_GetGR (context
, R_SP
)
877 && ucbp
->barrier_cache
.bitpattern
[1] == (_uw
) data
)
879 /* Matched a previous propagation barrier. */
882 /* Setup for entry to the handler. */
883 lp
= selfrel_offset31 (data
);
884 _Unwind_SetGR (context
, R_PC
, lp
);
885 _Unwind_SetGR (context
, 0, (_uw
) ucbp
);
886 return _URC_INSTALL_CONTEXT
;
888 /* Catch handler not matched. Advance to the next descriptor. */
893 rtti_count
= data
[0] & 0x7fffffff;
894 /* Exception specification. */
895 if (state
== _US_VIRTUAL_UNWIND_FRAME
)
897 if (in_range
&& (!forced_unwind
|| !rtti_count
))
899 /* Match against the exception specification. */
904 for (i
= 0; i
< rtti_count
; i
++)
906 matched
= (void *)(ucbp
+ 1);
907 rtti
= _Unwind_decode_target2 ((_uw
) &data
[i
+ 1]);
908 if (__cxa_type_match (ucbp
, (type_info
*) rtti
,
915 /* Exception does not match the spec. */
916 ucbp
->barrier_cache
.sp
=
917 _Unwind_GetGR (context
, R_SP
);
918 ucbp
->barrier_cache
.bitpattern
[0] = (_uw
) matched
;
919 ucbp
->barrier_cache
.bitpattern
[1] = (_uw
) data
;
920 return _URC_HANDLER_FOUND
;
923 /* Handler out of range, or exception is permitted. */
925 else if (ucbp
->barrier_cache
.sp
== _Unwind_GetGR (context
, R_SP
)
926 && ucbp
->barrier_cache
.bitpattern
[1] == (_uw
) data
)
928 /* Matched a previous propagation barrier. */
930 /* Record the RTTI list for __cxa_call_unexpected. */
931 ucbp
->barrier_cache
.bitpattern
[1] = rtti_count
;
932 ucbp
->barrier_cache
.bitpattern
[2] = 0;
933 ucbp
->barrier_cache
.bitpattern
[3] = 4;
934 ucbp
->barrier_cache
.bitpattern
[4] = (_uw
) &data
[1];
936 if (data
[0] & uint32_highbit
)
937 phase2_call_unexpected_after_unwind
= 1;
940 data
+= rtti_count
+ 1;
941 /* Setup for entry to the handler. */
942 lp
= selfrel_offset31 (data
);
944 _Unwind_SetGR (context
, R_PC
, lp
);
945 _Unwind_SetGR (context
, 0, (_uw
) ucbp
);
946 return _URC_INSTALL_CONTEXT
;
949 if (data
[0] & uint32_highbit
)
951 data
+= rtti_count
+ 1;
955 /* Should never happen. */
958 /* Finished processing this descriptor. */
962 if (__gnu_unwind_execute (context
, &uws
) != _URC_OK
)
965 if (phase2_call_unexpected_after_unwind
)
967 /* Enter __cxa_unexpected as if called from the call site. */
968 _Unwind_SetGR (context
, R_LR
, _Unwind_GetGR (context
, R_PC
));
969 _Unwind_SetGR (context
, R_PC
, (_uw
) &__cxa_call_unexpected
);
970 return _URC_INSTALL_CONTEXT
;
973 return _URC_CONTINUE_UNWIND
;
977 /* ABI defined personality routine entry points. */
980 __aeabi_unwind_cpp_pr0 (_Unwind_State state
,
981 _Unwind_Control_Block
*ucbp
,
982 _Unwind_Context
*context
)
984 return __gnu_unwind_pr_common (state
, ucbp
, context
, 0);
988 __aeabi_unwind_cpp_pr1 (_Unwind_State state
,
989 _Unwind_Control_Block
*ucbp
,
990 _Unwind_Context
*context
)
992 return __gnu_unwind_pr_common (state
, ucbp
, context
, 1);
996 __aeabi_unwind_cpp_pr2 (_Unwind_State state
,
997 _Unwind_Control_Block
*ucbp
,
998 _Unwind_Context
*context
)
1000 return __gnu_unwind_pr_common (state
, ucbp
, context
, 2);
1003 /* These two should never be used. */
1005 _Unwind_GetDataRelBase (_Unwind_Context
*context
__attribute__ ((unused
)))
1011 _Unwind_GetTextRelBase (_Unwind_Context
*context
__attribute__ ((unused
)))