blob: 53f42881016c5389fb745f82cf370b774dc149ac [file] [log] [blame]
Alexey Samsonov5b290182012-02-08 19:52:01 +00001//===-- 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#ifdef __linux__
Alexey Samsonov592d3f72012-08-02 11:19:13 +000016#include "interception.h"
Alexey Samsonov5b290182012-02-08 19:52:01 +000017
Alexander Potapenko92baa8c2012-02-13 17:11:19 +000018#include <dlfcn.h> // for dlsym
Alexey Samsonov5b290182012-02-08 19:52:01 +000019
20namespace __interception {
Alexey Samsonov592d3f72012-08-02 11:19:13 +000021bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
22 uptr real, uptr wrapper) {
23 *func_addr = (uptr)dlsym(RTLD_NEXT, func_name);
Dmitry Vyukov580469d2012-05-24 13:54:31 +000024 return real == wrapper;
Alexey Samsonov5b290182012-02-08 19:52:01 +000025}
Dmitry Vyukovf0615542013-09-02 18:06:28 +000026
Dmitry Vyukov2f913ee2013-09-03 07:53:49 +000027#if !defined(__ANDROID__) // android does not have dlvsym
Dmitry Vyukovf0615542013-09-02 18:06:28 +000028void *GetFuncAddrVer(const char *func_name, const char *ver) {
29 return dlvsym(RTLD_NEXT, func_name, ver);
30}
Dmitry Vyukov2f913ee2013-09-03 07:53:49 +000031#endif // !defined(__ANDROID__)
Dmitry Vyukovf0615542013-09-02 18:06:28 +000032
Alexey Samsonov5b290182012-02-08 19:52:01 +000033} // namespace __interception
34
35
36#endif // __linux__