]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/interception/interception_linux.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / interception / interception_linux.h
1 //===-- interception_linux.h ------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is a part of AddressSanitizer, an address sanity checker.
11 //
12 // Linux-specific interception methods.
13 //===----------------------------------------------------------------------===//
14
15 #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \
16     SANITIZER_OPENBSD || SANITIZER_SOLARIS
17
18 #if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
19 # error "interception_linux.h should be included from interception library only"
20 #endif
21
22 #ifndef INTERCEPTION_LINUX_H
23 #define INTERCEPTION_LINUX_H
24
25 namespace __interception {
26 // returns true if a function with the given name was found.
27 bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
28     uptr real, uptr wrapper);
29 void *GetFuncAddrVer(const char *func_name, const char *ver);
30 }  // namespace __interception
31
32 #define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)                          \
33   ::__interception::GetRealFunctionAddress(                                \
34       #func, (::__interception::uptr *)&__interception::PTR_TO_REAL(func), \
35       (::__interception::uptr) & (func),                                   \
36       (::__interception::uptr) & WRAP(func))
37
38 // Android,  Solaris and OpenBSD do not have dlvsym
39 #if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD
40 #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
41   (::__interception::real_##func = (func##_f)(                \
42        unsigned long)::__interception::GetFuncAddrVer(#func, symver))
43 #else
44 #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
45   INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
46 #endif  // !SANITIZER_ANDROID && !SANITIZER_SOLARIS
47
48 #endif  // INTERCEPTION_LINUX_H
49 #endif  // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD ||
50         // SANITIZER_OPENBSD || SANITIZER_SOLARIS