Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 9402a93

Browse files
committed
rt.unwind: Add support for ARM EABI unwinder
1 parent c71c42f commit 9402a93

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

src/rt/unwind.d

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ module rt.unwind;
1111

1212
import core.stdc.stdint;
1313

14+
version (ARM)
15+
{
16+
version (iOS) {} else version = ARM_EABI_UNWINDER;
17+
}
18+
1419
extern (C):
1520

1621
alias uintptr_t _Unwind_Word;
@@ -36,6 +41,8 @@ enum
3641
_URC_INSTALL_CONTEXT = 7,
3742
_URC_CONTINUE_UNWIND = 8
3843
}
44+
version (ARM_EABI_UNWINDER)
45+
enum _URC_FAILURE = 9;
3946

4047
alias int _Unwind_Action;
4148
enum _Unwind_Action _UA_SEARCH_PHASE = 1;
@@ -48,7 +55,53 @@ alias _Unwind_Exception_Cleanup_Fn = void function(
4855
_Unwind_Reason_Code reason,
4956
_Unwind_Exception *exc);
5057

51-
version (X86_64)
58+
version (ARM_EABI_UNWINDER)
59+
{
60+
align(8) struct _Unwind_Control_Block
61+
{
62+
ulong exception_class;
63+
void function(_Unwind_Reason_Code, _Unwind_Control_Block *) exception_cleanup;
64+
65+
/* Unwinder cache, private fields for the unwinder's use */
66+
struct unwinder_cache_t
67+
{
68+
uint reserved1; /* init reserved1 to 0, then don't touch */
69+
uint reserved2;
70+
uint reserved3;
71+
uint reserved4;
72+
uint reserved5;
73+
}
74+
unwinder_cache_t unwinder_cache;
75+
76+
/* Propagation barrier cache (valid after phase 1): */
77+
struct barrier_cache_t
78+
{
79+
uint sp;
80+
uint[5] bitpattern;
81+
}
82+
barrier_cache_t barrier_cache;
83+
84+
/* Cleanup cache (preserved over cleanup): */
85+
struct cleanup_cache_t
86+
{
87+
uint[4] bitpattern;
88+
}
89+
cleanup_cache_t cleanup_cache;
90+
91+
/* Pr cache (for pr's benefit): */
92+
struct pr_cache_t
93+
{
94+
uint fnstart; /* function start address */
95+
void* ehtp; /* pointer to EHT entry header word */
96+
uint additional;
97+
uint reserved1;
98+
}
99+
pr_cache_t pr_cache;
100+
}
101+
102+
alias _Unwind_Exception = _Unwind_Control_Block;
103+
}
104+
else version (X86_64)
52105
{
53106
align(16) struct _Unwind_Exception
54107
{
@@ -93,6 +146,12 @@ void _Unwind_Resume(_Unwind_Exception* exception_object);
93146
_Unwind_Reason_Code _Unwind_Resume_or_Rethrow(_Unwind_Exception* exception_object);
94147
_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void*);
95148

149+
version (ARM_EABI_UNWINDER)
150+
{
151+
_Unwind_Reason_Code __gnu_unwind_frame(_Unwind_Exception* exception_object, _Unwind_Context* context);
152+
void _Unwind_Complete(_Unwind_Exception* exception_object);
153+
}
154+
96155
_Unwind_Word _Unwind_GetGR(_Unwind_Context* context, int index);
97156
void _Unwind_SetGR(_Unwind_Context* context, int index, _Unwind_Word new_value);
98157
_Unwind_Ptr _Unwind_GetIP(_Unwind_Context* context);

0 commit comments

Comments
 (0)