sanitizer_platform_interceptors.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. //===-- sanitizer_platform_interceptors.h -----------------------*- C++ -*-===//
  2. //
  3. // This file is distributed under the University of Illinois Open Source
  4. // License. See LICENSE.TXT for details.
  5. //
  6. //===----------------------------------------------------------------------===//
  7. //
  8. // This file defines macro telling whether sanitizer tools can/should intercept
  9. // given library functions on a given platform.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H
  13. #define SANITIZER_PLATFORM_INTERCEPTORS_H
  14. #include "sanitizer_internal_defs.h"
  15. #if !SANITIZER_WINDOWS
  16. # define SI_NOT_WINDOWS 1
  17. # include "sanitizer_platform_limits_posix.h"
  18. #else
  19. # define SI_NOT_WINDOWS 0
  20. #endif
  21. #if SANITIZER_LINUX && !SANITIZER_ANDROID
  22. # define SI_LINUX_NOT_ANDROID 1
  23. #else
  24. # define SI_LINUX_NOT_ANDROID 0
  25. #endif
  26. #if SANITIZER_FREEBSD
  27. # define SI_FREEBSD 1
  28. #else
  29. # define SI_FREEBSD 0
  30. #endif
  31. #if SANITIZER_LINUX
  32. # define SI_LINUX 1
  33. #else
  34. # define SI_LINUX 0
  35. #endif
  36. #if SANITIZER_MAC
  37. # define SI_MAC 1
  38. #else
  39. # define SI_MAC 0
  40. #endif
  41. #if SANITIZER_IOS
  42. # define SI_IOS 1
  43. #else
  44. # define SI_IOS 0
  45. #endif
  46. #define SANITIZER_INTERCEPT_STRCMP 1
  47. #define SANITIZER_INTERCEPT_TEXTDOMAIN SI_LINUX_NOT_ANDROID
  48. #define SANITIZER_INTERCEPT_STRCASECMP SI_NOT_WINDOWS
  49. #define SANITIZER_INTERCEPT_MEMCHR 1
  50. #define SANITIZER_INTERCEPT_MEMRCHR SI_LINUX
  51. #define SANITIZER_INTERCEPT_READ SI_NOT_WINDOWS
  52. #define SANITIZER_INTERCEPT_PREAD SI_NOT_WINDOWS
  53. #define SANITIZER_INTERCEPT_WRITE SI_NOT_WINDOWS
  54. #define SANITIZER_INTERCEPT_PWRITE SI_NOT_WINDOWS
  55. #define SANITIZER_INTERCEPT_PREAD64 SI_LINUX_NOT_ANDROID
  56. #define SANITIZER_INTERCEPT_PWRITE64 SI_LINUX_NOT_ANDROID
  57. #define SANITIZER_INTERCEPT_READV SI_NOT_WINDOWS
  58. #define SANITIZER_INTERCEPT_WRITEV SI_NOT_WINDOWS
  59. #define SANITIZER_INTERCEPT_PREADV SI_LINUX_NOT_ANDROID
  60. #define SANITIZER_INTERCEPT_PWRITEV SI_LINUX_NOT_ANDROID
  61. #define SANITIZER_INTERCEPT_PREADV64 SI_LINUX_NOT_ANDROID
  62. #define SANITIZER_INTERCEPT_PWRITEV64 SI_LINUX_NOT_ANDROID
  63. #define SANITIZER_INTERCEPT_PRCTL SI_LINUX
  64. #define SANITIZER_INTERCEPT_LOCALTIME_AND_FRIENDS SI_NOT_WINDOWS
  65. #define SANITIZER_INTERCEPT_STRPTIME SI_NOT_WINDOWS
  66. #define SANITIZER_INTERCEPT_SCANF SI_NOT_WINDOWS
  67. #define SANITIZER_INTERCEPT_ISOC99_SCANF SI_LINUX_NOT_ANDROID
  68. #ifndef SANITIZER_INTERCEPT_PRINTF
  69. # define SANITIZER_INTERCEPT_PRINTF SI_NOT_WINDOWS
  70. # define SANITIZER_INTERCEPT_ISOC99_PRINTF SI_LINUX_NOT_ANDROID
  71. #endif
  72. #define SANITIZER_INTERCEPT_FREXP 1
  73. #define SANITIZER_INTERCEPT_FREXPF_FREXPL SI_NOT_WINDOWS
  74. #define SANITIZER_INTERCEPT_GETPWNAM_AND_FRIENDS SI_NOT_WINDOWS
  75. #define SANITIZER_INTERCEPT_GETPWNAM_R_AND_FRIENDS \
  76. SI_MAC || SI_LINUX_NOT_ANDROID
  77. #define SANITIZER_INTERCEPT_GETPWENT SI_MAC || SI_LINUX_NOT_ANDROID
  78. #define SANITIZER_INTERCEPT_FGETPWENT SI_LINUX_NOT_ANDROID
  79. #define SANITIZER_INTERCEPT_GETPWENT_R SI_LINUX_NOT_ANDROID
  80. #define SANITIZER_INTERCEPT_SETPWENT SI_MAC || SI_LINUX_NOT_ANDROID
  81. #define SANITIZER_INTERCEPT_CLOCK_GETTIME SI_LINUX
  82. #define SANITIZER_INTERCEPT_GETITIMER SI_NOT_WINDOWS
  83. #define SANITIZER_INTERCEPT_TIME SI_NOT_WINDOWS
  84. #define SANITIZER_INTERCEPT_GLOB SI_LINUX_NOT_ANDROID
  85. #define SANITIZER_INTERCEPT_WAIT SI_NOT_WINDOWS
  86. #define SANITIZER_INTERCEPT_INET SI_NOT_WINDOWS
  87. #define SANITIZER_INTERCEPT_PTHREAD_GETSCHEDPARAM SI_NOT_WINDOWS
  88. #define SANITIZER_INTERCEPT_GETADDRINFO SI_NOT_WINDOWS
  89. #define SANITIZER_INTERCEPT_GETNAMEINFO SI_NOT_WINDOWS
  90. #define SANITIZER_INTERCEPT_GETSOCKNAME SI_NOT_WINDOWS
  91. #define SANITIZER_INTERCEPT_GETHOSTBYNAME SI_NOT_WINDOWS
  92. #define SANITIZER_INTERCEPT_GETHOSTBYNAME_R SI_LINUX
  93. #define SANITIZER_INTERCEPT_GETHOSTBYNAME2_R SI_LINUX_NOT_ANDROID
  94. #define SANITIZER_INTERCEPT_GETHOSTBYADDR_R SI_LINUX_NOT_ANDROID
  95. #define SANITIZER_INTERCEPT_GETHOSTENT_R SI_LINUX_NOT_ANDROID
  96. #define SANITIZER_INTERCEPT_GETSOCKOPT SI_NOT_WINDOWS
  97. #define SANITIZER_INTERCEPT_ACCEPT SI_NOT_WINDOWS
  98. #define SANITIZER_INTERCEPT_ACCEPT4 SI_LINUX_NOT_ANDROID
  99. #define SANITIZER_INTERCEPT_MODF SI_NOT_WINDOWS
  100. #define SANITIZER_INTERCEPT_RECVMSG SI_NOT_WINDOWS
  101. #define SANITIZER_INTERCEPT_GETPEERNAME SI_NOT_WINDOWS
  102. #define SANITIZER_INTERCEPT_IOCTL SI_NOT_WINDOWS
  103. #define SANITIZER_INTERCEPT_INET_ATON SI_NOT_WINDOWS
  104. #define SANITIZER_INTERCEPT_SYSINFO SI_LINUX
  105. #define SANITIZER_INTERCEPT_READDIR SI_NOT_WINDOWS
  106. #define SANITIZER_INTERCEPT_READDIR64 SI_LINUX_NOT_ANDROID
  107. #define SANITIZER_INTERCEPT_PTRACE SI_LINUX_NOT_ANDROID && \
  108. (defined(__i386) || defined (__x86_64)) // NOLINT
  109. #define SANITIZER_INTERCEPT_SETLOCALE SI_NOT_WINDOWS
  110. #define SANITIZER_INTERCEPT_GETCWD SI_NOT_WINDOWS
  111. #define SANITIZER_INTERCEPT_GET_CURRENT_DIR_NAME SI_LINUX_NOT_ANDROID
  112. #define SANITIZER_INTERCEPT_STRTOIMAX SI_NOT_WINDOWS
  113. #define SANITIZER_INTERCEPT_MBSTOWCS SI_NOT_WINDOWS
  114. #define SANITIZER_INTERCEPT_MBSNRTOWCS SI_MAC || SI_LINUX_NOT_ANDROID
  115. #define SANITIZER_INTERCEPT_WCSTOMBS SI_NOT_WINDOWS
  116. #define SANITIZER_INTERCEPT_WCSNRTOMBS SI_MAC || SI_LINUX_NOT_ANDROID
  117. #define SANITIZER_INTERCEPT_TCGETATTR SI_LINUX_NOT_ANDROID
  118. #define SANITIZER_INTERCEPT_REALPATH SI_NOT_WINDOWS
  119. #define SANITIZER_INTERCEPT_CANONICALIZE_FILE_NAME SI_LINUX_NOT_ANDROID
  120. #define SANITIZER_INTERCEPT_CONFSTR SI_MAC || SI_LINUX_NOT_ANDROID
  121. #define SANITIZER_INTERCEPT_SCHED_GETAFFINITY SI_LINUX_NOT_ANDROID
  122. #define SANITIZER_INTERCEPT_STRERROR SI_NOT_WINDOWS
  123. #define SANITIZER_INTERCEPT_STRERROR_R SI_NOT_WINDOWS
  124. #define SANITIZER_INTERCEPT_XPG_STRERROR_R SI_LINUX_NOT_ANDROID
  125. #define SANITIZER_INTERCEPT_SCANDIR SI_LINUX_NOT_ANDROID
  126. #define SANITIZER_INTERCEPT_SCANDIR64 SI_LINUX_NOT_ANDROID
  127. #define SANITIZER_INTERCEPT_GETGROUPS SI_NOT_WINDOWS
  128. #define SANITIZER_INTERCEPT_POLL SI_NOT_WINDOWS
  129. #define SANITIZER_INTERCEPT_PPOLL SI_LINUX_NOT_ANDROID
  130. #define SANITIZER_INTERCEPT_WORDEXP (SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID
  131. #define SANITIZER_INTERCEPT_SIGWAIT SI_NOT_WINDOWS
  132. #define SANITIZER_INTERCEPT_SIGWAITINFO SI_LINUX_NOT_ANDROID
  133. #define SANITIZER_INTERCEPT_SIGTIMEDWAIT SI_LINUX_NOT_ANDROID
  134. #define SANITIZER_INTERCEPT_SIGSETOPS \
  135. SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID
  136. #define SANITIZER_INTERCEPT_SIGPENDING SI_NOT_WINDOWS
  137. #define SANITIZER_INTERCEPT_SIGPROCMASK SI_NOT_WINDOWS
  138. #define SANITIZER_INTERCEPT_BACKTRACE SI_LINUX_NOT_ANDROID
  139. #define SANITIZER_INTERCEPT_GETMNTENT SI_LINUX
  140. #define SANITIZER_INTERCEPT_GETMNTENT_R SI_LINUX_NOT_ANDROID
  141. #define SANITIZER_INTERCEPT_STATFS SI_MAC || SI_LINUX_NOT_ANDROID
  142. #define SANITIZER_INTERCEPT_STATFS64 \
  143. (SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID
  144. #define SANITIZER_INTERCEPT_STATVFS SI_LINUX_NOT_ANDROID
  145. #define SANITIZER_INTERCEPT_STATVFS64 SI_LINUX_NOT_ANDROID
  146. #define SANITIZER_INTERCEPT_INITGROUPS SI_NOT_WINDOWS
  147. #define SANITIZER_INTERCEPT_ETHER_NTOA_ATON SI_NOT_WINDOWS
  148. #define SANITIZER_INTERCEPT_ETHER_HOST SI_MAC || SI_LINUX_NOT_ANDROID
  149. #define SANITIZER_INTERCEPT_ETHER_R SI_LINUX_NOT_ANDROID
  150. #define SANITIZER_INTERCEPT_SHMCTL \
  151. (SI_LINUX_NOT_ANDROID && SANITIZER_WORDSIZE == 64)
  152. #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID
  153. #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_NOT_WINDOWS
  154. #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GETINHERITSCHED \
  155. SI_MAC || SI_LINUX_NOT_ANDROID
  156. #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GETAFFINITY_NP SI_LINUX_NOT_ANDROID
  157. #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETPSHARED SI_NOT_WINDOWS
  158. #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETTYPE SI_NOT_WINDOWS
  159. #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETPROTOCOL \
  160. SI_MAC || SI_LINUX_NOT_ANDROID
  161. #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETPRIOCEILING \
  162. SI_MAC || SI_LINUX_NOT_ANDROID
  163. #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETROBUST SI_LINUX_NOT_ANDROID
  164. #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETROBUST_NP SI_LINUX_NOT_ANDROID
  165. #define SANITIZER_INTERCEPT_PTHREAD_RWLOCKATTR_GETPSHARED SI_NOT_WINDOWS
  166. #define SANITIZER_INTERCEPT_PTHREAD_RWLOCKATTR_GETKIND_NP SI_LINUX_NOT_ANDROID
  167. #define SANITIZER_INTERCEPT_PTHREAD_CONDATTR_GETPSHARED SI_NOT_WINDOWS
  168. #define SANITIZER_INTERCEPT_PTHREAD_CONDATTR_GETCLOCK SI_LINUX_NOT_ANDROID
  169. #define SANITIZER_INTERCEPT_PTHREAD_BARRIERATTR_GETPSHARED SI_LINUX_NOT_ANDROID
  170. #define SANITIZER_INTERCEPT_TMPNAM SI_NOT_WINDOWS
  171. #define SANITIZER_INTERCEPT_TMPNAM_R SI_LINUX_NOT_ANDROID
  172. #define SANITIZER_INTERCEPT_TEMPNAM SI_NOT_WINDOWS
  173. #define SANITIZER_INTERCEPT_SINCOS SI_LINUX
  174. #define SANITIZER_INTERCEPT_REMQUO SI_NOT_WINDOWS
  175. #define SANITIZER_INTERCEPT_LGAMMA SI_NOT_WINDOWS
  176. #define SANITIZER_INTERCEPT_LGAMMA_R SI_LINUX
  177. #define SANITIZER_INTERCEPT_LGAMMAL_R SI_LINUX_NOT_ANDROID
  178. #define SANITIZER_INTERCEPT_DRAND48_R SI_LINUX_NOT_ANDROID
  179. #define SANITIZER_INTERCEPT_RAND_R SI_MAC || SI_LINUX_NOT_ANDROID
  180. #define SANITIZER_INTERCEPT_ICONV SI_LINUX_NOT_ANDROID
  181. #define SANITIZER_INTERCEPT_TIMES SI_NOT_WINDOWS
  182. // FIXME: getline seems to be available on OSX 10.7
  183. #define SANITIZER_INTERCEPT_GETLINE SI_LINUX_NOT_ANDROID
  184. #define SANITIZER_INTERCEPT__EXIT SI_LINUX || SI_FREEBSD
  185. #define SANITIZER_INTERCEPT_PHTREAD_MUTEX SI_NOT_WINDOWS
  186. #define SANITIZER_INTERCEPT_PTHREAD_SETNAME_NP \
  187. SI_FREEBSD || SI_LINUX_NOT_ANDROID
  188. #define SANITIZER_INTERCEPT_TLS_GET_ADDR SI_LINUX_NOT_ANDROID
  189. #define SANITIZER_INTERCEPT_LISTXATTR SI_LINUX
  190. #define SANITIZER_INTERCEPT_GETXATTR SI_LINUX
  191. #define SANITIZER_INTERCEPT_GETRESID SI_LINUX
  192. #define SANITIZER_INTERCEPT_GETIFADDRS SI_LINUX_NOT_ANDROID || SI_MAC
  193. #define SANITIZER_INTERCEPT_IF_INDEXTONAME SI_LINUX_NOT_ANDROID || SI_MAC
  194. #define SANITIZER_INTERCEPT_CAPGET SI_LINUX_NOT_ANDROID
  195. #define SANITIZER_INTERCEPT_AEABI_MEM SI_LINUX && defined(__arm__)
  196. #define SANITIZER_INTERCEPT___BZERO SI_MAC
  197. #define SANITIZER_INTERCEPT_FTIME SI_NOT_WINDOWS
  198. #define SANITIZER_INTERCEPT_XDR SI_LINUX_NOT_ANDROID
  199. #define SANITIZER_INTERCEPT_TSEARCH SI_LINUX_NOT_ANDROID || SI_MAC
  200. #define SANITIZER_INTERCEPT_LIBIO_INTERNALS SI_LINUX_NOT_ANDROID
  201. #define SANITIZER_INTERCEPT_FOPEN SI_NOT_WINDOWS
  202. #define SANITIZER_INTERCEPT_FOPEN64 SI_LINUX_NOT_ANDROID
  203. #define SANITIZER_INTERCEPT_OPEN_MEMSTREAM SI_LINUX_NOT_ANDROID
  204. #define SANITIZER_INTERCEPT_OBSTACK SI_LINUX_NOT_ANDROID
  205. #define SANITIZER_INTERCEPT_FFLUSH SI_NOT_WINDOWS
  206. #define SANITIZER_INTERCEPT_FCLOSE SI_NOT_WINDOWS
  207. #define SANITIZER_INTERCEPT_DLOPEN_DLCLOSE \
  208. SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_MAC
  209. #define SANITIZER_INTERCEPT_GETPASS SI_LINUX_NOT_ANDROID || SI_MAC
  210. #define SANITIZER_INTERCEPT_TIMERFD SI_LINUX_NOT_ANDROID
  211. #define SANITIZER_INTERCEPT_MLOCKX SI_NOT_WINDOWS
  212. #endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H