blob: 67caca32cd2c0103d1fa4858778abea0a297a5c8 [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
27void *GetFuncAddrVer(const char *func_name, const char *ver) {
28 return dlvsym(RTLD_NEXT, func_name, ver);
29}
30
Alexey Samsonov5b290182012-02-08 19:52:01 +000031} // namespace __interception
32
33
34#endif // __linux__