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