2012-11-12 16:53:47 +01:00
|
|
|
//===-- asan_win.cc -------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of AddressSanitizer, an address sanity checker.
|
|
|
|
//
|
|
|
|
// Windows-specific details.
|
|
|
|
//===----------------------------------------------------------------------===//
|
2013-11-04 22:33:31 +01:00
|
|
|
|
|
|
|
#include "sanitizer_common/sanitizer_platform.h"
|
|
|
|
#if SANITIZER_WINDOWS
|
2012-11-12 16:53:47 +01:00
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include <dbghelp.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "asan_interceptors.h"
|
|
|
|
#include "asan_internal.h"
|
|
|
|
#include "asan_thread.h"
|
|
|
|
#include "sanitizer_common/sanitizer_libc.h"
|
2013-01-23 12:41:33 +01:00
|
|
|
#include "sanitizer_common/sanitizer_mutex.h"
|
2012-11-12 16:53:47 +01:00
|
|
|
|
2013-11-04 22:33:31 +01:00
|
|
|
extern "C" {
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
int __asan_should_detect_stack_use_after_return() {
|
|
|
|
__asan_init();
|
|
|
|
return __asan_option_detect_stack_use_after_return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-12 16:53:47 +01:00
|
|
|
namespace __asan {
|
|
|
|
|
|
|
|
// ---------------------- TSD ---------------- {{{1
|
|
|
|
static bool tsd_key_inited = false;
|
|
|
|
|
|
|
|
static __declspec(thread) void *fake_tsd = 0;
|
|
|
|
|
|
|
|
void AsanTSDInit(void (*destructor)(void *tsd)) {
|
|
|
|
// FIXME: we're ignoring the destructor for now.
|
|
|
|
tsd_key_inited = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *AsanTSDGet() {
|
|
|
|
CHECK(tsd_key_inited);
|
|
|
|
return fake_tsd;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsanTSDSet(void *tsd) {
|
|
|
|
CHECK(tsd_key_inited);
|
|
|
|
fake_tsd = tsd;
|
|
|
|
}
|
|
|
|
|
2013-12-05 10:18:38 +01:00
|
|
|
void PlatformTSDDtor(void *tsd) {
|
|
|
|
AsanThread::TSDDtor(tsd);
|
|
|
|
}
|
2012-11-12 16:53:47 +01:00
|
|
|
// ---------------------- Various stuff ---------------- {{{1
|
|
|
|
void MaybeReexec() {
|
|
|
|
// No need to re-exec on Windows.
|
|
|
|
}
|
|
|
|
|
|
|
|
void *AsanDoesNotSupportStaticLinkage() {
|
|
|
|
#if defined(_DEBUG)
|
|
|
|
#error Please build the runtime with a non-debug CRT: /MD or /MT
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-22 09:09:21 +02:00
|
|
|
void AsanCheckDynamicRTPrereqs() { UNIMPLEMENTED(); }
|
2012-11-12 16:53:47 +01:00
|
|
|
|
2014-05-22 09:09:21 +02:00
|
|
|
void AsanCheckIncompatibleRT() {}
|
2012-11-12 16:53:47 +01:00
|
|
|
|
|
|
|
void AsanPlatformThreadInit() {
|
|
|
|
// Nothing here for now.
|
|
|
|
}
|
|
|
|
|
2013-01-23 12:41:33 +01:00
|
|
|
void ReadContextStack(void *context, uptr *stack, uptr *ssize) {
|
2012-11-23 15:46:25 +01:00
|
|
|
UNIMPLEMENTED();
|
|
|
|
}
|
|
|
|
|
2014-05-22 09:09:21 +02:00
|
|
|
void AsanOnSIGSEGV(int, void *siginfo, void *context) {
|
|
|
|
UNIMPLEMENTED();
|
2012-11-12 16:53:47 +01:00
|
|
|
}
|
|
|
|
|
2014-05-22 09:09:21 +02:00
|
|
|
} // namespace __asan
|
2012-11-12 16:53:47 +01:00
|
|
|
|
|
|
|
#endif // _WIN32
|