• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- interception_mac.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 // Mac-specific interception methods.
13 //===----------------------------------------------------------------------===//
14 
15 #ifdef __APPLE__
16 
17 #define INCLUDED_FROM_INTERCEPTION_LIB
18 #include "interception_mac.h"
19 #undef INCLUDED_FROM_INTERCEPTION_LIB
20 #include "mach_override/mach_override.h"
21 
22 namespace __interception {
OverrideFunction(void * old_func,void * new_func,void ** orig_old_func)23 bool OverrideFunction(void *old_func, void *new_func, void **orig_old_func) {
24   *orig_old_func = NULL;
25   int res = __asan_mach_override_ptr_custom(old_func, new_func,
26                                             orig_old_func,
27                                             __interception_allocate_island,
28                                             __interception_deallocate_island);
29   return (res == 0) && (*orig_old_func != NULL);
30 }
31 }  // namespace __interception
32 
33 #endif  // __APPLE__
34