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