1 /* C6X EABI compliant unwinding routines.
2 Copyright (C) 2011-2015 Free Software Foundation, Inc.
4 This file is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation; either version 3, or (at your option) any
9 This file is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 Under Section 7 of GPL version 3, you are granted additional
15 permissions described in the GCC Runtime Library Exception, version
16 3.1, as published by the Free Software Foundation.
18 You should have received a copy of the GNU General Public License and
19 a copy of the GCC Runtime Library Exception along with this program;
20 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
21 <http://www.gnu.org/licenses/>. */
26 #define NUM_SAVED_REGS 32
28 #define R_B3 (R_B0 + 3)
29 #define R_B15 (R_B0 + 15)
34 #define VRS_PC(vrs) ((vrs)->core.pc)
35 #define VRS_SP(vrs) ((vrs)->core.reg[R_SP])
36 #define VRS_RETURN(vrs) ((vrs)->core.reg[R_B3])
40 _uw reg
[NUM_SAVED_REGS
];
46 /* The first fields must be the same as a phase2_vrs. */
47 _uw demand_save_flags
; /* Currently always zero. */
48 struct core_regs core
;
49 _uw prev_sp
; /* Only valid during forced unwinding. */
52 /* This must match the structure created by the assembly wrappers. */
55 _uw demand_save_flags
;
56 struct core_regs core
;
59 /* Coprocessor register state manipulation functions. */
61 /* Restore coprocessor state after phase1 unwinding. */
63 restore_non_core_regs (phase1_vrs
* vrs
__attribute__((unused
)))
67 #include "unwind-arm-common.inc"
69 /* ABI defined personality routines. */
70 extern _Unwind_Reason_Code
__c6xabi_unwind_cpp_pr0 (_Unwind_State
,
71 _Unwind_Control_Block
*, _Unwind_Context
*);// __attribute__((weak));
72 extern _Unwind_Reason_Code
__c6xabi_unwind_cpp_pr1 (_Unwind_State
,
73 _Unwind_Control_Block
*, _Unwind_Context
*) __attribute__((weak
));
74 extern _Unwind_Reason_Code
__c6xabi_unwind_cpp_pr2 (_Unwind_State
,
75 _Unwind_Control_Block
*, _Unwind_Context
*) __attribute__((weak
));
76 extern _Unwind_Reason_Code
__c6xabi_unwind_cpp_pr3 (_Unwind_State
,
77 _Unwind_Control_Block
*, _Unwind_Context
*) __attribute__((weak
));
78 extern _Unwind_Reason_Code
__c6xabi_unwind_cpp_pr4 (_Unwind_State
,
79 _Unwind_Control_Block
*, _Unwind_Context
*) __attribute__((weak
));
81 /* ABI defined routine to store a virtual register to memory. */
83 _Unwind_VRS_Result
_Unwind_VRS_Get (_Unwind_Context
*context
,
84 _Unwind_VRS_RegClass regclass
,
86 _Unwind_VRS_DataRepresentation representation
,
89 phase1_vrs
*vrs
= (phase1_vrs
*) context
;
94 if (representation
!= _UVRSD_UINT32
)
98 *(_uw
*) valuep
= vrs
->core
.pc
;
101 if (regno
>= NUM_SAVED_REGS
)
102 return _UVRSR_FAILED
;
103 *(_uw
*) valuep
= vrs
->core
.reg
[regno
];
107 return _UVRSR_FAILED
;
112 /* ABI defined function to load a virtual register from memory. */
114 _Unwind_VRS_Result
_Unwind_VRS_Set (_Unwind_Context
*context
,
115 _Unwind_VRS_RegClass regclass
,
117 _Unwind_VRS_DataRepresentation representation
,
120 phase1_vrs
*vrs
= (phase1_vrs
*) context
;
125 if (representation
!= _UVRSD_UINT32
)
126 return _UVRSR_FAILED
;
129 vrs
->core
.pc
= *(_uw
*) valuep
;
132 if (regno
>= NUM_SAVED_REGS
)
133 return _UVRSR_FAILED
;
135 vrs
->core
.reg
[regno
] = *(_uw
*) valuep
;
139 return _UVRSR_FAILED
;
144 /* Core unwinding functions. */
146 /* Calculate the address encoded by a 31-bit self-relative offset at address
149 selfrel_offset31 (const _uw
*p
)
154 return offset
+ (_uw
) p
;
159 __gnu_unwind_get_pr_addr (int idx
)
164 return (_uw
) &__c6xabi_unwind_cpp_pr0
;
167 return (_uw
) &__c6xabi_unwind_cpp_pr1
;
170 return (_uw
) &__c6xabi_unwind_cpp_pr2
;
173 return (_uw
) &__c6xabi_unwind_cpp_pr3
;
176 return (_uw
) &__c6xabi_unwind_cpp_pr4
;
184 /* ABI defined personality routine entry points. */
187 __c6xabi_unwind_cpp_pr0 (_Unwind_State state
,
188 _Unwind_Control_Block
*ucbp
,
189 _Unwind_Context
*context
)
191 return __gnu_unwind_pr_common (state
, ucbp
, context
, 0);
195 __c6xabi_unwind_cpp_pr1 (_Unwind_State state
,
196 _Unwind_Control_Block
*ucbp
,
197 _Unwind_Context
*context
)
199 return __gnu_unwind_pr_common (state
, ucbp
, context
, 1);
203 __c6xabi_unwind_cpp_pr2 (_Unwind_State state
,
204 _Unwind_Control_Block
*ucbp
,
205 _Unwind_Context
*context
)
207 return __gnu_unwind_pr_common (state
, ucbp
, context
, 2);
211 __c6xabi_unwind_cpp_pr3 (_Unwind_State state
,
212 _Unwind_Control_Block
*ucbp
,
213 _Unwind_Context
*context
)
215 return __gnu_unwind_pr_common (state
, ucbp
, context
, 3);
219 __c6xabi_unwind_cpp_pr4 (_Unwind_State state
,
220 _Unwind_Control_Block
*ucbp
,
221 _Unwind_Context
*context
)
223 return __gnu_unwind_pr_common (state
, ucbp
, context
, 4);