summaryrefslogtreecommitdiff
path: root/debian/patches/libcxxabi-arm-ehabi-fix.patch
blob: 65747174c3e706e154a5a7722cedd7f8df649701 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
Fix arm EHABI code to work. armhf had exception test failing without EHABI support.

No known upstream bug about this. Actual code change is more like workaround than
something that upstream would accept. Proper fix would be adding _Unwind_Control_Block
to clang unwind.h. _Unwind_Control_Block should also extend _Unwind_Exception to make
sure their ABI stays in sync.

No known upstream bug about this.

Index: llvm-toolchain-snapshot_8~svn344157/libcxxabi/src/cxa_exception.cpp
===================================================================
--- llvm-toolchain-snapshot_8~svn344157.orig/libcxxabi/src/cxa_exception.cpp
+++ llvm-toolchain-snapshot_8~svn344157/libcxxabi/src/cxa_exception.cpp
@@ -277,15 +277,16 @@ __cxa_throw(void *thrown_object, std::ty
 
 #ifdef __USING_SJLJ_EXCEPTIONS__
     _Unwind_SjLj_RaiseException(&exception_header->unwindHeader);
-#else
+#elif !LIBCXXABI_ARM_EHABI
     _Unwind_RaiseException(&exception_header->unwindHeader);
+#else
+    _Unwind_RaiseException(exception_header->unwindHeader);
 #endif
     //  This only happens when there is no handler, or some unexpected unwinding
     //     error happens.
     failed_throw(exception_header);
 }
 
-
 // 2.5.3 Exception Handlers
 /*
 The adjusted pointer is computed by the personality routine during phase 1
@@ -548,7 +549,11 @@ void __cxa_end_catch() {
             //    to touch a foreign exception in any way, that is undefined
             //     behavior.  They likely can't since the only way to catch
             //     a foreign exception is with catch (...)!
+#if !LIBCXXABI_ARM_EHABI
             _Unwind_DeleteException(&globals->caughtExceptions->unwindHeader);
+#else
+            _Unwind_DeleteException(globals->caughtExceptions->unwindHeader);
+#endif
             globals->caughtExceptions = 0;
         }
     }
@@ -605,8 +610,10 @@ void __cxa_rethrow() {
     }
 #ifdef __USING_SJLJ_EXCEPTIONS__
     _Unwind_SjLj_RaiseException(&exception_header->unwindHeader);
-#else
+#elif !LIBCXXABI_ARM_EHABI
     _Unwind_RaiseException(&exception_header->unwindHeader);
+#else
+    _Unwind_RaiseException(exception_header->unwindHeader);
 #endif
 
     //  If we get here, some kind of unwinding error has occurred.
@@ -730,8 +737,10 @@ __cxa_rethrow_primary_exception(void* th
         dep_exception_header->unwindHeader.exception_cleanup = dependent_exception_cleanup;
 #ifdef __USING_SJLJ_EXCEPTIONS__
         _Unwind_SjLj_RaiseException(&dep_exception_header->unwindHeader);
+#elif !LIBCXXABI_ARM_EHABI
+	_Unwind_RaiseException(&dep_exception_header->unwindHeader);
 #else
-        _Unwind_RaiseException(&dep_exception_header->unwindHeader);
+	_Unwind_RaiseException(dep_exception_header->unwindHeader);
 #endif
         // Some sort of unwinding error.  Note that terminate is a handler.
         __cxa_begin_catch(&dep_exception_header->unwindHeader);
Index: llvm-toolchain-snapshot_8~svn344157/libcxxabi/src/cxa_exception.hpp
===================================================================
--- llvm-toolchain-snapshot_8~svn344157.orig/libcxxabi/src/cxa_exception.hpp
+++ llvm-toolchain-snapshot_8~svn344157/libcxxabi/src/cxa_exception.hpp
@@ -28,6 +28,45 @@ uint64_t __getExceptionClass  (const _Un
 void     __setExceptionClass  (      _Unwind_Exception*, uint64_t);
 bool     __isOurExceptionClass(const _Unwind_Exception*);
 
+#if LIBCXXABI_ARM_EHABI
+// GCC has _Unwind_Control_Block in unwind.h (unwind_arm_common.h)
+#if defined(__clang__)
+struct _Unwind_Control_Block
+{
+	uint64_t exception_class;
+	void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *);
+	struct {
+		_Unwind_Word reserved1;
+		_Unwind_Word reserved2;
+		_Unwind_Word reserved3;
+		_Unwind_Word reserved4;
+		_Unwind_Word reserved5;
+	} unwinder_cache;
+	struct {
+		_Unwind_Word sp;
+		_Unwind_Word bitpattern[5];
+	} barrier_cache;
+	struct {
+		_Unwind_Word bitpattern[4];
+	} cleanup_cache;
+	struct {
+		_Unwind_Word fnstart;
+		_Unwind_Word *ehtp;
+		_Unwind_Word additional;
+		_Unwind_Word reserved1;
+	} pr_cache;
+	long long int :0;
+	operator _Unwind_Exception*() noexcept
+	{
+		return reinterpret_cast<_Unwind_Exception*>(this);
+	}
+};
+
+#endif
+
+#define _Unwind_Exception _Unwind_Control_Block
+#endif
+
 struct _LIBCXXABI_HIDDEN __cxa_exception {
 #if defined(__LP64__) || defined(_LIBCXXABI_ARM_EHABI)
     // This is a new field to support C++ 0x exception_ptr.