annotate libsanitizer/sanitizer_common/sanitizer_win_weak_interception.h @ 137:d22083d7f10b

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:16:42 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 //===-- sanitizer_win_weak_interception.h ---------------------------------===//
kono
parents:
diff changeset
2 //
kono
parents:
diff changeset
3 // This file is distributed under the University of Illinois Open Source
kono
parents:
diff changeset
4 // License. See LICENSE.TXT for details.
kono
parents:
diff changeset
5 //
kono
parents:
diff changeset
6 //===----------------------------------------------------------------------===//
kono
parents:
diff changeset
7 // This header provide helper macros to delegate calls of weak functions to the
kono
parents:
diff changeset
8 // implementation in the main executable when a strong definition is present.
kono
parents:
diff changeset
9 //===----------------------------------------------------------------------===//
kono
parents:
diff changeset
10 #ifndef SANITIZER_WIN_WEAK_INTERCEPTION_H
kono
parents:
diff changeset
11 #define SANITIZER_WIN_WEAK_INTERCEPTION_H
kono
parents:
diff changeset
12 #include "sanitizer_internal_defs.h"
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 namespace __sanitizer {
kono
parents:
diff changeset
15 int interceptWhenPossible(uptr dll_function, const char *real_function);
kono
parents:
diff changeset
16 }
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 // ----------------- Function interception helper macros -------------------- //
kono
parents:
diff changeset
19 // Weak functions, could be redefined in the main executable, but that is not
kono
parents:
diff changeset
20 // necessary, so we shouldn't die if we can not find a reference.
kono
parents:
diff changeset
21 #define INTERCEPT_WEAK(Name) interceptWhenPossible((uptr) Name, #Name);
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 #define INTERCEPT_SANITIZER_WEAK_FUNCTION(Name) \
kono
parents:
diff changeset
24 static int intercept_##Name() { \
kono
parents:
diff changeset
25 return __sanitizer::interceptWhenPossible((__sanitizer::uptr) Name, #Name);\
kono
parents:
diff changeset
26 } \
kono
parents:
diff changeset
27 __pragma(section(".WEAK$M", long, read)) \
kono
parents:
diff changeset
28 __declspec(allocate(".WEAK$M")) int (*__weak_intercept_##Name)() = \
kono
parents:
diff changeset
29 intercept_##Name;
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 #endif // SANITIZER_WIN_WEAK_INTERCEPTION_H