summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-03-21 23:51:21 +0000
committerReid Kleckner <rnk@google.com>2016-03-21 23:51:21 +0000
commit81f7729c3dd975c266d9ee0c8b4dce6a5ca0edc8 (patch)
tree9f26e16e91ae44e13389af4bb8701dca2cb910cc
parented051774bae7464609db61427e395794b303e178 (diff)
downloadbcm5719-llvm-81f7729c3dd975c266d9ee0c8b4dce6a5ca0edc8.tar.gz
bcm5719-llvm-81f7729c3dd975c266d9ee0c8b4dce6a5ca0edc8.zip
[asan] Set the unhandled exception filter slightly later during startup
VS 2015 moved the priority of their exception filter initializer from XIY to XCAA. We now set ours to XCAB, which makes it run after both CRT versions but before user constructors, as it should. Fixes null_deref.cc and a variety of related tests with VS 2015. Only 4 failures remain. llvm-svn: 264006
-rw-r--r--compiler-rt/lib/asan/asan_win.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler-rt/lib/asan/asan_win.cc b/compiler-rt/lib/asan/asan_win.cc
index 92bd893d10e..bb6b1db7c6c 100644
--- a/compiler-rt/lib/asan/asan_win.cc
+++ b/compiler-rt/lib/asan/asan_win.cc
@@ -242,10 +242,16 @@ int __asan_set_seh_filter() {
}
#if !ASAN_DYNAMIC
-// Put a pointer to __asan_set_seh_filter at the end of the global list
-// of C initializers, after the default EH is set by the CRT.
-#pragma section(".CRT$XIZ", long, read) // NOLINT
-__declspec(allocate(".CRT$XIZ"))
+// The CRT runs initializers in this order:
+// - C initializers, from XIA to XIZ
+// - C++ initializers, from XCA to XCZ
+// Prior to 2015, the CRT set the unhandled exception filter at priority XIY,
+// near the end of C initialization. Starting in 2015, it was moved to the
+// beginning of C++ initialization. We set our priority to XCAB to run
+// immediately after the CRT runs. This way, our exception filter is called
+// first and we can delegate to their filter if appropriate.
+#pragma section(".CRT$XCAB", long, read) // NOLINT
+__declspec(allocate(".CRT$XCAB"))
int (*__intercept_seh)() = __asan_set_seh_filter;
#endif
// }}}
OpenPOWER on IntegriCloud