1 //===-- sanitizer_win_weak_interception.h ---------------------------------===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
7 // This header provide helper macros to delegate calls of weak functions to the
8 // implementation in the main executable when a strong definition is present.
9 //===----------------------------------------------------------------------===//
10 #ifndef SANITIZER_WIN_WEAK_INTERCEPTION_H
11 #define SANITIZER_WIN_WEAK_INTERCEPTION_H
12 #include "sanitizer_internal_defs.h"
14 namespace __sanitizer
{
15 int interceptWhenPossible(uptr dll_function
, const char *real_function
);
18 // ----------------- Function interception helper macros -------------------- //
19 // Weak functions, could be redefined in the main executable, but that is not
20 // necessary, so we shouldn't die if we can not find a reference.
21 #define INTERCEPT_WEAK(Name) interceptWhenPossible((uptr) Name, #Name);
23 #define INTERCEPT_SANITIZER_WEAK_FUNCTION(Name) \
24 static int intercept_##Name() { \
25 return __sanitizer::interceptWhenPossible((__sanitizer::uptr) Name, #Name);\
27 __pragma(section(".WEAK$M", long, read)) \
28 __declspec(allocate(".WEAK$M")) int (*__weak_intercept_##Name)() = \
31 #endif // SANITIZER_WIN_WEAK_INTERCEPTION_H