annotate libsanitizer/sanitizer_common/sanitizer_win_weak_interception.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
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 //
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
111
kono
parents:
diff changeset
6 //
kono
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
kono
parents:
diff changeset
8 // This header provide helper macros to delegate calls of weak functions to the
kono
parents:
diff changeset
9 // implementation in the main executable when a strong definition is present.
kono
parents:
diff changeset
10 //===----------------------------------------------------------------------===//
kono
parents:
diff changeset
11 #ifndef SANITIZER_WIN_WEAK_INTERCEPTION_H
kono
parents:
diff changeset
12 #define SANITIZER_WIN_WEAK_INTERCEPTION_H
kono
parents:
diff changeset
13 #include "sanitizer_internal_defs.h"
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 namespace __sanitizer {
kono
parents:
diff changeset
16 int interceptWhenPossible(uptr dll_function, const char *real_function);
kono
parents:
diff changeset
17 }
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 // ----------------- Function interception helper macros -------------------- //
kono
parents:
diff changeset
20 // Weak functions, could be redefined in the main executable, but that is not
kono
parents:
diff changeset
21 // necessary, so we shouldn't die if we can not find a reference.
kono
parents:
diff changeset
22 #define INTERCEPT_WEAK(Name) interceptWhenPossible((uptr) Name, #Name);
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 #define INTERCEPT_SANITIZER_WEAK_FUNCTION(Name) \
kono
parents:
diff changeset
25 static int intercept_##Name() { \
kono
parents:
diff changeset
26 return __sanitizer::interceptWhenPossible((__sanitizer::uptr) Name, #Name);\
kono
parents:
diff changeset
27 } \
kono
parents:
diff changeset
28 __pragma(section(".WEAK$M", long, read)) \
kono
parents:
diff changeset
29 __declspec(allocate(".WEAK$M")) int (*__weak_intercept_##Name)() = \
kono
parents:
diff changeset
30 intercept_##Name;
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 #endif // SANITIZER_WIN_WEAK_INTERCEPTION_H