]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/lib/interception/interception_linux.h
Imported Upstream version 1.0.0~0alpha
[rustc.git] / src / 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 defined(__linux__) || defined(__FreeBSD__)
16
17 #if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
18 # error "interception_linux.h should be included from interception library only"
19 #endif
20
21 #ifndef INTERCEPTION_LINUX_H
22 #define INTERCEPTION_LINUX_H
23
24 namespace __interception {
25 // returns true if a function with the given name was found.
26 bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
27 uptr real, uptr wrapper);
28 void *GetFuncAddrVer(const char *func_name, const char *ver);
29 } // namespace __interception
30
31 #define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) \
32 ::__interception::GetRealFunctionAddress( \
33 #func, (::__interception::uptr *)&__interception::PTR_TO_REAL(func), \
34 (::__interception::uptr) & (func), \
35 (::__interception::uptr) & WRAP(func))
36
37 #if !defined(__ANDROID__) // android does not have dlvsym
38 # define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
39 ::__interception::real_##func = (func##_f)(unsigned long) \
40 ::__interception::GetFuncAddrVer(#func, symver)
41 #else
42 # define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
43 INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
44 #endif // !defined(__ANDROID__)
45
46 #endif // INTERCEPTION_LINUX_H
47 #endif // __linux__ || __FreeBSD__