interception_mac.cc revision 238901
1238901Sandrew//===-- interception_mac.cc -------------------------------------*- C++ -*-===// 2238901Sandrew// 3238901Sandrew// The LLVM Compiler Infrastructure 4238901Sandrew// 5238901Sandrew// This file is distributed under the University of Illinois Open Source 6238901Sandrew// License. See LICENSE.TXT for details. 7238901Sandrew// 8238901Sandrew//===----------------------------------------------------------------------===// 9238901Sandrew// 10238901Sandrew// This file is a part of AddressSanitizer, an address sanity checker. 11238901Sandrew// 12238901Sandrew// Mac-specific interception methods. 13238901Sandrew//===----------------------------------------------------------------------===// 14238901Sandrew 15238901Sandrew#ifdef __APPLE__ 16238901Sandrew 17238901Sandrew#define INCLUDED_FROM_INTERCEPTION_LIB 18238901Sandrew#include "interception_mac.h" 19238901Sandrew#undef INCLUDED_FROM_INTERCEPTION_LIB 20238901Sandrew#include "mach_override/mach_override.h" 21238901Sandrew 22238901Sandrewnamespace __interception { 23238901Sandrewbool OverrideFunction(void *old_func, void *new_func, void **orig_old_func) { 24238901Sandrew *orig_old_func = NULL; 25238901Sandrew int res = __asan_mach_override_ptr_custom(old_func, new_func, 26238901Sandrew orig_old_func, 27238901Sandrew __interception_allocate_island, 28238901Sandrew __interception_deallocate_island); 29238901Sandrew return (res == 0) && (*orig_old_func != NULL); 30238901Sandrew} 31238901Sandrew} // namespace __interception 32238901Sandrew 33238901Sandrew#endif // __APPLE__ 34