Make shift argument to eoshift0 and eoshift2 be of type index_type
[official-gcc.git] / libsanitizer / asan / asan_globals_win.cc
blob118c0ac991c980d0e974ddb26b40201398dec3d8
1 //===-- asan_globals_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 // Global registration code that is linked into every Windows DLL and EXE.
9 //
10 //===----------------------------------------------------------------------===//
12 #include "asan_interface_internal.h"
13 #if SANITIZER_WINDOWS
15 namespace __asan {
17 #pragma section(".ASAN$GA", read, write) // NOLINT
18 #pragma section(".ASAN$GZ", read, write) // NOLINT
19 extern "C" __declspec(allocate(".ASAN$GA"))
20 __asan_global __asan_globals_start = {};
21 extern "C" __declspec(allocate(".ASAN$GZ"))
22 __asan_global __asan_globals_end = {};
23 #pragma comment(linker, "/merge:.ASAN=.data")
25 static void call_on_globals(void (*hook)(__asan_global *, uptr)) {
26 __asan_global *start = &__asan_globals_start + 1;
27 __asan_global *end = &__asan_globals_end;
28 uptr bytediff = (uptr)end - (uptr)start;
29 if (bytediff % sizeof(__asan_global) != 0) {
30 #ifdef SANITIZER_DLL_THUNK
31 __debugbreak();
32 #else
33 CHECK("corrupt asan global array");
34 #endif
36 // We know end >= start because the linker sorts the portion after the dollar
37 // sign alphabetically.
38 uptr n = end - start;
39 hook(start, n);
42 static void register_dso_globals() {
43 call_on_globals(&__asan_register_globals);
46 static void unregister_dso_globals() {
47 call_on_globals(&__asan_unregister_globals);
50 // Register globals
51 #pragma section(".CRT$XCU", long, read) // NOLINT
52 #pragma section(".CRT$XTX", long, read) // NOLINT
53 extern "C" __declspec(allocate(".CRT$XCU"))
54 void (*const __asan_dso_reg_hook)() = &register_dso_globals;
55 extern "C" __declspec(allocate(".CRT$XTX"))
56 void (*const __asan_dso_unreg_hook)() = &unregister_dso_globals;
58 } // namespace __asan
60 #endif // SANITIZER_WINDOWS