[PATCH] D148991: [compiler-rt][asan][win] Intercept exceptions for i686 MinGW
Alvin Wong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 22 06:32:02 PDT 2023
alvinhochun created this revision.
alvinhochun added reviewers: vitalybuka, mstorsjo.
Herald added subscribers: Enna1, pengfei, fedor.sergeev, krytarowski, dberris.
Herald added a project: All.
alvinhochun requested review of this revision.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.
The i686-w64-windows-gnu target does not use SEH (which MSVC uses),
but DWARF-2 exception handling or possibly sjlj depending on the
toolchain build options. On this target we have to actually intercept
functions in libc++ and libunwind which handles throwing exceptions.
This fixes the `TestCases/intercept-rethrow-exception.cpp` test.
The x86_64-w64-windows-gnu target already works because it uses SEH
which is handled by intercepting RaiseException, so this change does not
affect x86_64.
Depends on https://reviews.llvm.org/D148990
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D148991
Files:
compiler-rt/lib/asan/asan_interceptors.h
compiler-rt/lib/interception/interception_win.cpp
Index: compiler-rt/lib/interception/interception_win.cpp
===================================================================
--- compiler-rt/lib/interception/interception_win.cpp
+++ compiler-rt/lib/interception/interception_win.cpp
@@ -898,6 +898,10 @@
"msvcr120.dll", // VS2013
"vcruntime140.dll", // VS2015
"ucrtbase.dll", // Universal CRT
+#if (defined(__MINGW32__) && defined(__i386__))
+ "libc++.dll", // libc++
+ "libunwind.dll", // libunwind
+#endif
// NTDLL should go last as it exports some functions that we should
// override in the CRT [presumably only used internally].
"ntdll.dll", NULL};
Index: compiler-rt/lib/asan/asan_interceptors.h
===================================================================
--- compiler-rt/lib/asan/asan_interceptors.h
+++ compiler-rt/lib/asan/asan_interceptors.h
@@ -78,8 +78,8 @@
# define ASAN_INTERCEPT___LONGJMP_CHK 0
#endif
-#if ASAN_HAS_EXCEPTIONS && !SANITIZER_WINDOWS && !SANITIZER_SOLARIS && \
- !SANITIZER_NETBSD
+#if ASAN_HAS_EXCEPTIONS && !SANITIZER_SOLARIS && !SANITIZER_NETBSD && \
+ (!SANITIZER_WINDOWS || (defined(__MINGW32__) && defined(__i386__)))
# define ASAN_INTERCEPT___CXA_THROW 1
# define ASAN_INTERCEPT___CXA_RETHROW_PRIMARY_EXCEPTION 1
# if defined(_GLIBCXX_SJLJ_EXCEPTIONS) || (SANITIZER_IOS && defined(__arm__))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148991.516066.patch
Type: text/x-patch
Size: 1373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230422/7fd4ca4c/attachment.bin>
More information about the llvm-commits
mailing list