2012-11-12 16:53:47 +01:00
|
|
|
//===-- interception_linux.h ------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-08-14 10:47:11 +02:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-11-12 16:53:47 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of AddressSanitizer, an address sanity checker.
|
|
|
|
//
|
|
|
|
// Linux-specific interception methods.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2018-10-31 12:14:23 +01:00
|
|
|
#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \
|
2020-11-13 17:03:23 +01:00
|
|
|
SANITIZER_SOLARIS
|
2012-11-12 16:53:47 +01:00
|
|
|
|
|
|
|
#if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
|
|
|
|
# error "interception_linux.h should be included from interception library only"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef INTERCEPTION_LINUX_H
|
|
|
|
#define INTERCEPTION_LINUX_H
|
|
|
|
|
|
|
|
namespace __interception {
|
2019-08-14 10:47:11 +02:00
|
|
|
bool InterceptFunction(const char *name, uptr *ptr_to_real, uptr func,
|
|
|
|
uptr wrapper);
|
|
|
|
bool InterceptFunction(const char *name, const char *ver, uptr *ptr_to_real,
|
|
|
|
uptr func, uptr wrapper);
|
2012-11-12 16:53:47 +01:00
|
|
|
} // namespace __interception
|
|
|
|
|
2019-08-14 10:47:11 +02:00
|
|
|
#define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) \
|
|
|
|
::__interception::InterceptFunction( \
|
|
|
|
#func, \
|
|
|
|
(::__interception::uptr *) & REAL(func), \
|
|
|
|
(::__interception::uptr) & (func), \
|
2014-05-22 09:09:21 +02:00
|
|
|
(::__interception::uptr) & WRAP(func))
|
2012-11-12 16:53:47 +01:00
|
|
|
|
2021-05-12 14:37:22 +02:00
|
|
|
// dlvsym is a GNU extension supported by some other platforms.
|
|
|
|
#if SANITIZER_GLIBC || SANITIZER_FREEBSD || SANITIZER_NETBSD
|
2015-10-21 09:32:45 +02:00
|
|
|
#define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
|
2019-08-14 10:47:11 +02:00
|
|
|
::__interception::InterceptFunction( \
|
|
|
|
#func, symver, \
|
|
|
|
(::__interception::uptr *) & REAL(func), \
|
|
|
|
(::__interception::uptr) & (func), \
|
|
|
|
(::__interception::uptr) & WRAP(func))
|
2013-12-05 10:18:38 +01:00
|
|
|
#else
|
2015-10-21 09:32:45 +02:00
|
|
|
#define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
|
|
|
|
INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
|
2021-05-12 14:37:22 +02:00
|
|
|
#endif // SANITIZER_GLIBC || SANITIZER_FREEBSD || SANITIZER_NETBSD
|
2013-11-04 22:33:31 +01:00
|
|
|
|
2012-11-12 16:53:47 +01:00
|
|
|
#endif // INTERCEPTION_LINUX_H
|
2018-10-31 12:14:23 +01:00
|
|
|
#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD ||
|
2020-11-13 17:03:23 +01:00
|
|
|
// SANITIZER_SOLARIS
|