gcc/
[official-gcc.git] / libsanitizer / asan / asan_win.cc
blob03d45e3839ba79b9b93a518557e511d24fc0d497
1 //===-- asan_win.cc -------------------------------------------------------===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of AddressSanitizer, an address sanity checker.
9 //
10 // Windows-specific details.
11 //===----------------------------------------------------------------------===//
13 #include "sanitizer_common/sanitizer_platform.h"
14 #if SANITIZER_WINDOWS
15 #include <windows.h>
17 #include <dbghelp.h>
18 #include <stdlib.h>
20 #include "asan_interceptors.h"
21 #include "asan_internal.h"
22 #include "asan_thread.h"
23 #include "sanitizer_common/sanitizer_libc.h"
24 #include "sanitizer_common/sanitizer_mutex.h"
26 extern "C" {
27 SANITIZER_INTERFACE_ATTRIBUTE
28 int __asan_should_detect_stack_use_after_return() {
29 __asan_init();
30 return __asan_option_detect_stack_use_after_return;
34 namespace __asan {
36 // ---------------------- TSD ---------------- {{{1
37 static bool tsd_key_inited = false;
39 static __declspec(thread) void *fake_tsd = 0;
41 void AsanTSDInit(void (*destructor)(void *tsd)) {
42 // FIXME: we're ignoring the destructor for now.
43 tsd_key_inited = true;
46 void *AsanTSDGet() {
47 CHECK(tsd_key_inited);
48 return fake_tsd;
51 void AsanTSDSet(void *tsd) {
52 CHECK(tsd_key_inited);
53 fake_tsd = tsd;
56 void PlatformTSDDtor(void *tsd) {
57 AsanThread::TSDDtor(tsd);
59 // ---------------------- Various stuff ---------------- {{{1
60 void MaybeReexec() {
61 // No need to re-exec on Windows.
64 void *AsanDoesNotSupportStaticLinkage() {
65 #if defined(_DEBUG)
66 #error Please build the runtime with a non-debug CRT: /MD or /MT
67 #endif
68 return 0;
71 void AsanCheckDynamicRTPrereqs() { UNIMPLEMENTED(); }
73 void AsanCheckIncompatibleRT() {}
75 void AsanPlatformThreadInit() {
76 // Nothing here for now.
79 void ReadContextStack(void *context, uptr *stack, uptr *ssize) {
80 UNIMPLEMENTED();
83 void AsanOnSIGSEGV(int, void *siginfo, void *context) {
84 UNIMPLEMENTED();
87 } // namespace __asan
89 #endif // _WIN32