Path: blob/main/contrib/llvm-project/compiler-rt/lib/interception/interception_linux.h
35262 views
//===-- interception_linux.h ------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file is a part of AddressSanitizer, an address sanity checker.9//10// Linux-specific interception methods.11//===----------------------------------------------------------------------===//1213#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \14SANITIZER_SOLARIS1516#if !defined(INCLUDED_FROM_INTERCEPTION_LIB)17# error interception_linux.h should be included from interception library only18#endif1920#ifndef INTERCEPTION_LINUX_H21#define INTERCEPTION_LINUX_H2223namespace __interception {24bool InterceptFunction(const char *name, uptr *ptr_to_real, uptr func,25uptr trampoline);26bool InterceptFunction(const char *name, const char *ver, uptr *ptr_to_real,27uptr func, uptr trampoline);28} // namespace __interception2930// Cast func to type of REAL(func) before casting to uptr in case it is an31// overloaded function, which is the case for some glibc functions when32// _FORTIFY_SOURCE is used. This disambiguates which overload to use.33#define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) \34::__interception::InterceptFunction( \35#func, (::__interception::uptr *)&REAL(func), \36(::__interception::uptr)(decltype(REAL(func)))&(func), \37(::__interception::uptr) &TRAMPOLINE(func))3839// dlvsym is a GNU extension supported by some other platforms.40#if SANITIZER_GLIBC || SANITIZER_FREEBSD || SANITIZER_NETBSD41#define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \42::__interception::InterceptFunction( \43#func, symver, \44(::__interception::uptr *)&REAL(func), \45(::__interception::uptr)(decltype(REAL(func)))&(func), \46(::__interception::uptr)&TRAMPOLINE(func))47#else48#define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \49INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)50#endif // SANITIZER_GLIBC || SANITIZER_FREEBSD || SANITIZER_NETBSD5152#endif // INTERCEPTION_LINUX_H53#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD ||54// SANITIZER_SOLARIS555657