1 //===-- interception_linux.cc -----------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of AddressSanitizer, an address sanity checker.
10 // Linux-specific interception methods.
11 //===----------------------------------------------------------------------===//
13 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
14 #include "interception.h"
16 #include <dlfcn.h> // for dlsym() and dlvsym()
19 #include "sanitizer_common/sanitizer_libc.h"
22 namespace __interception
{
23 bool GetRealFunctionAddress(const char *func_name
, uptr
*func_addr
,
24 uptr real
, uptr wrapper
) {
26 // XXX: Find a better way to handle renames
27 if (internal_strcmp(func_name
, "sigaction") == 0) func_name
= "__sigaction14";
29 *func_addr
= (uptr
)dlsym(RTLD_NEXT
, func_name
);
30 return real
== wrapper
;
33 #if !defined(__ANDROID__) // android does not have dlvsym
34 void *GetFuncAddrVer(const char *func_name
, const char *ver
) {
35 return dlvsym(RTLD_NEXT
, func_name
, ver
);
37 #endif // !defined(__ANDROID__)
39 } // namespace __interception
41 #endif // __linux__ || __FreeBSD__ || __NetBSD__