1 //===-- interception_linux.h ------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file is a part of AddressSanitizer, an address sanity checker. 10 // 11 // Linux-specific interception methods. 12 //===----------------------------------------------------------------------===// 13 14 #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \ 15 SANITIZER_OPENBSD || SANITIZER_SOLARIS 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 *GetFuncAddr(const char *name); 29 void *GetFuncAddrVer(const char *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##_type)( \ 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 51