1 //===-- asan_interceptors_dynamic.cc --------------------------------------===//
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 // __DATA,__interpose section of the dynamic runtime library for Mac OS.
11 //===----------------------------------------------------------------------===//
13 #if defined(__APPLE__)
15 #include "../asan_interceptors.h"
16 #include "../asan_intercepted_functions.h"
20 #define INTERPOSE_FUNCTION(function) \
21 { reinterpret_cast<const uptr>(WRAP(function)), \
22 reinterpret_cast<const uptr>(function) }
24 #define INTERPOSE_FUNCTION_2(function, wrapper) \
25 { reinterpret_cast<const uptr>(wrapper), \
26 reinterpret_cast<const uptr>(function) }
28 struct interpose_substitution
{
29 const uptr replacement
;
34 const interpose_substitution substitutions
[]
35 __attribute__((section("__DATA, __interpose"))) = {
36 INTERPOSE_FUNCTION(strlen
),
37 INTERPOSE_FUNCTION(memcmp
),
38 INTERPOSE_FUNCTION(memcpy
),
39 INTERPOSE_FUNCTION(memmove
),
40 INTERPOSE_FUNCTION(memset
),
41 INTERPOSE_FUNCTION(strchr
),
42 INTERPOSE_FUNCTION(strcat
),
43 INTERPOSE_FUNCTION(strncat
),
44 INTERPOSE_FUNCTION(strcpy
),
45 INTERPOSE_FUNCTION(strncpy
),
46 INTERPOSE_FUNCTION(pthread_create
),
47 INTERPOSE_FUNCTION(longjmp
),
48 #if ASAN_INTERCEPT__LONGJMP
49 INTERPOSE_FUNCTION(_longjmp
),
51 #if ASAN_INTERCEPT_SIGLONGJMP
52 INTERPOSE_FUNCTION(siglongjmp
),
54 #if ASAN_INTERCEPT_STRDUP
55 INTERPOSE_FUNCTION(strdup
),
57 #if ASAN_INTERCEPT_STRNLEN
58 INTERPOSE_FUNCTION(strnlen
),
60 #if ASAN_INTERCEPT_INDEX
61 INTERPOSE_FUNCTION_2(index
, WRAP(strchr
)),
63 INTERPOSE_FUNCTION(strcmp
),
64 INTERPOSE_FUNCTION(strncmp
),
65 #if ASAN_INTERCEPT_STRCASECMP_AND_STRNCASECMP
66 INTERPOSE_FUNCTION(strcasecmp
),
67 INTERPOSE_FUNCTION(strncasecmp
),
69 INTERPOSE_FUNCTION(atoi
),
70 INTERPOSE_FUNCTION(atol
),
71 INTERPOSE_FUNCTION(strtol
),
72 #if ASAN_INTERCEPT_ATOLL_AND_STRTOLL
73 INTERPOSE_FUNCTION(atoll
),
74 INTERPOSE_FUNCTION(strtoll
),
76 #if ASAN_INTERCEPT_MLOCKX
77 INTERPOSE_FUNCTION(mlock
),
78 INTERPOSE_FUNCTION(munlock
),
79 INTERPOSE_FUNCTION(mlockall
),
80 INTERPOSE_FUNCTION(munlockall
),
82 INTERPOSE_FUNCTION(dispatch_async_f
),
83 INTERPOSE_FUNCTION(dispatch_sync_f
),
84 INTERPOSE_FUNCTION(dispatch_after_f
),
85 INTERPOSE_FUNCTION(dispatch_barrier_async_f
),
86 INTERPOSE_FUNCTION(dispatch_group_async_f
),
87 #ifndef MISSING_BLOCKS_SUPPORT
88 INTERPOSE_FUNCTION(dispatch_group_async
),
89 INTERPOSE_FUNCTION(dispatch_async
),
90 INTERPOSE_FUNCTION(dispatch_after
),
91 INTERPOSE_FUNCTION(dispatch_source_set_event_handler
),
92 INTERPOSE_FUNCTION(dispatch_source_set_cancel_handler
),
94 INTERPOSE_FUNCTION(signal
),
95 INTERPOSE_FUNCTION(sigaction
),
97 INTERPOSE_FUNCTION(malloc_create_zone
),
98 INTERPOSE_FUNCTION(malloc_default_zone
),
99 INTERPOSE_FUNCTION(malloc_default_purgeable_zone
),
100 INTERPOSE_FUNCTION(malloc_make_purgeable
),
101 INTERPOSE_FUNCTION(malloc_make_nonpurgeable
),
102 INTERPOSE_FUNCTION(malloc_set_zone_name
),
103 INTERPOSE_FUNCTION(malloc
),
104 INTERPOSE_FUNCTION(free
),
105 INTERPOSE_FUNCTION(realloc
),
106 INTERPOSE_FUNCTION(calloc
),
107 INTERPOSE_FUNCTION(valloc
),
108 INTERPOSE_FUNCTION(malloc_good_size
),
109 INTERPOSE_FUNCTION(posix_memalign
),
112 } // namespace __asan