interception_linux.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \
  14. SANITIZER_SOLARIS
  15. #if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
  16. # error "interception_linux.h should be included from interception library only"
  17. #endif
  18. #ifndef INTERCEPTION_LINUX_H
  19. #define INTERCEPTION_LINUX_H
  20. namespace __interception {
  21. bool InterceptFunction(const char *name, uptr *ptr_to_real, uptr func,
  22. uptr wrapper);
  23. bool InterceptFunction(const char *name, const char *ver, uptr *ptr_to_real,
  24. uptr func, uptr wrapper);
  25. } // namespace __interception
  26. #define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) \
  27. ::__interception::InterceptFunction( \
  28. #func, \
  29. (::__interception::uptr *) & REAL(func), \
  30. (::__interception::uptr) & (func), \
  31. (::__interception::uptr) & WRAP(func))
  32. // dlvsym is a GNU extension supported by some other platforms.
  33. #if SANITIZER_GLIBC || SANITIZER_FREEBSD || SANITIZER_NETBSD
  34. #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
  35. ::__interception::InterceptFunction( \
  36. #func, symver, \
  37. (::__interception::uptr *) & REAL(func), \
  38. (::__interception::uptr) & (func), \
  39. (::__interception::uptr) & WRAP(func))
  40. #else
  41. #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
  42. INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
  43. #endif // SANITIZER_GLIBC || SANITIZER_FREEBSD || SANITIZER_NETBSD
  44. #endif // INTERCEPTION_LINUX_H
  45. #endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD ||
  46. // SANITIZER_SOLARIS