interception_linux.cc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //===-- interception_linux.cc -----------------------------------*- C++ -*-===//
  2. //
  3. // This file is distributed under the University of Illinois Open Source
  4. // License. See LICENSE.TXT for details.
  5. //
  6. //===----------------------------------------------------------------------===//
  7. //
  8. // This file is a part of AddressSanitizer, an address sanity checker.
  9. //
  10. // Linux-specific interception methods.
  11. //===----------------------------------------------------------------------===//
  12. #if defined(__linux__) || defined(__FreeBSD__)
  13. #include "interception.h"
  14. #include <dlfcn.h> // for dlsym() and dlvsym()
  15. namespace __interception {
  16. bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
  17. uptr real, uptr wrapper) {
  18. *func_addr = (uptr)dlsym(RTLD_NEXT, func_name);
  19. return real == wrapper;
  20. }
  21. #if !defined(__ANDROID__) // android does not have dlvsym
  22. void *GetFuncAddrVer(const char *func_name, const char *ver) {
  23. return dlvsym(RTLD_NEXT, func_name, ver);
  24. }
  25. #endif // !defined(__ANDROID__)
  26. } // namespace __interception
  27. #endif // __linux__ || __FreeBSD__