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