summaryrefslogtreecommitdiff
path: root/libcxxabi
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-07-23 22:09:23 +0000
committerMartin Storsjo <martin@martin.st>2018-07-23 22:09:23 +0000
commitc38051a0f51e130fb60addcab00e29f7e12a526a (patch)
tree79c42b0e106e148225ed7696e2dc9a5c6c8889fb /libcxxabi
parent1355bc5f6c7e4c69a6690f4e845ab3389915e45e (diff)
Implement a GCC compatible SEH unwinding personality, __gxx_personality_seh0
This allows handling SEH based exceptions, with unwind functions provided by libgcc. Differential Revision: https://reviews.llvm.org/D49638
Diffstat (limited to 'libcxxabi')
-rw-r--r--libcxxabi/src/cxa_personality.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp
index 7f857faf78f..6759d8a71f9 100644
--- a/libcxxabi/src/cxa_personality.cpp
+++ b/libcxxabi/src/cxa_personality.cpp
@@ -23,6 +23,16 @@
#include "private_typeinfo.h"
#include "unwind.h"
+#if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+#include <windows.h>
+#include <winnt.h>
+
+extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD,
+ void *, PCONTEXT,
+ PDISPATCHER_CONTEXT,
+ _Unwind_Personality_Fn);
+#endif
+
/*
Exception Header Layout:
@@ -934,12 +944,16 @@ _UA_CLEANUP_PHASE
*/
#if !defined(_LIBCXXABI_ARM_EHABI)
+#if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+static _Unwind_Reason_Code __gxx_personality_imp
+#else
_LIBCXXABI_FUNC_VIS _Unwind_Reason_Code
#ifdef __USING_SJLJ_EXCEPTIONS__
__gxx_personality_sj0
#else
__gxx_personality_v0
#endif
+#endif
(int version, _Unwind_Action actions, uint64_t exceptionClass,
_Unwind_Exception* unwind_exception, _Unwind_Context* context)
{
@@ -1022,6 +1036,17 @@ __gxx_personality_v0
// We were called improperly: neither a phase 1 or phase 2 search
return _URC_FATAL_PHASE1_ERROR;
}
+
+#if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+extern "C" EXCEPTION_DISPOSITION
+__gxx_personality_seh0(PEXCEPTION_RECORD ms_exc, void *this_frame,
+ PCONTEXT ms_orig_context, PDISPATCHER_CONTEXT ms_disp)
+{
+ return _GCC_specific_handler(ms_exc, this_frame, ms_orig_context, ms_disp,
+ __gxx_personality_imp);
+}
+#endif
+
#else
extern "C" _Unwind_Reason_Code __gnu_unwind_frame(_Unwind_Exception*,