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