PR rtl-optimization/79386
[official-gcc.git] / libsanitizer / interception / interception_linux.h
blob61bf48a72338f4bfc8690352d67a8ebe5d749aa8
1 //===-- interception_linux.h ------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of AddressSanitizer, an address sanity checker.
9 //
10 // Linux-specific interception methods.
11 //===----------------------------------------------------------------------===//
13 #if defined(__linux__) || defined(__FreeBSD__)
15 #if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
16 # error "interception_linux.h should be included from interception library only"
17 #endif
19 #ifndef INTERCEPTION_LINUX_H
20 #define INTERCEPTION_LINUX_H
22 namespace __interception {
23 // returns true if a function with the given name was found.
24 bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
25 uptr real, uptr wrapper);
26 void *GetFuncAddrVer(const char *func_name, const char *ver);
27 } // namespace __interception
29 #define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) \
30 ::__interception::GetRealFunctionAddress( \
31 #func, (::__interception::uptr *)&__interception::PTR_TO_REAL(func), \
32 (::__interception::uptr) & (func), \
33 (::__interception::uptr) & WRAP(func))
35 #if !defined(__ANDROID__) // android does not have dlvsym
36 #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
37 (::__interception::real_##func = (func##_f)( \
38 unsigned long)::__interception::GetFuncAddrVer(#func, symver))
39 #else
40 #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
41 INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
42 #endif // !defined(__ANDROID__)
44 #endif // INTERCEPTION_LINUX_H
45 #endif // __linux__ || __FreeBSD__