Alexey Samsonov | 8489f2a | 2012-02-08 19:52:01 +0000 | [diff] [blame] | 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 | #ifdef __linux__ |
Alexey Samsonov | 0f840bd | 2012-08-02 11:19:13 +0000 | [diff] [blame] | 16 | #include "interception.h" |
Alexey Samsonov | 8489f2a | 2012-02-08 19:52:01 +0000 | [diff] [blame] | 17 | |
Alexander Potapenko | 234d8c2 | 2012-02-13 17:11:19 +0000 | [diff] [blame] | 18 | #include <stddef.h> // for NULL |
| 19 | #include <dlfcn.h> // for dlsym |
Alexey Samsonov | 8489f2a | 2012-02-08 19:52:01 +0000 | [diff] [blame] | 20 | |
| 21 | namespace __interception { |
Alexey Samsonov | 0f840bd | 2012-08-02 11:19:13 +0000 | [diff] [blame] | 22 | bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, |
| 23 | uptr real, uptr wrapper) { |
| 24 | *func_addr = (uptr)dlsym(RTLD_NEXT, func_name); |
Dmitry Vyukov | 7fb7330 | 2012-05-24 13:54:31 +0000 | [diff] [blame] | 25 | return real == wrapper; |
Alexey Samsonov | 8489f2a | 2012-02-08 19:52:01 +0000 | [diff] [blame] | 26 | } |
| 27 | } // namespace __interception |
| 28 | |
| 29 | |
| 30 | #endif // __linux__ |