Home | History | Annotate | Download | only in asan
      1 //===-- asan_intercepted_functions.h ----------------------------*- 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 // ASan-private header containing prototypes for wrapper functions and wrappers
     13 //===----------------------------------------------------------------------===//
     14 #ifndef ASAN_INTERCEPTED_FUNCTIONS_H
     15 #define ASAN_INTERCEPTED_FUNCTIONS_H
     16 
     17 #include "asan_internal.h"
     18 #include "interception/interception.h"
     19 #include "sanitizer_common/sanitizer_platform_interceptors.h"
     20 
     21 #include <stdarg.h>
     22 #include <stddef.h>
     23 
     24 using __sanitizer::uptr;
     25 
     26 // Use macro to describe if specific function should be
     27 // intercepted on a given platform.
     28 #if !SANITIZER_WINDOWS
     29 # define ASAN_INTERCEPT_ATOLL_AND_STRTOLL 1
     30 # define ASAN_INTERCEPT__LONGJMP 1
     31 # define ASAN_INTERCEPT_STRDUP 1
     32 # define ASAN_INTERCEPT_INDEX 1
     33 # define ASAN_INTERCEPT_PTHREAD_CREATE 1
     34 # define ASAN_INTERCEPT_MLOCKX 1
     35 #else
     36 # define ASAN_INTERCEPT_ATOLL_AND_STRTOLL 0
     37 # define ASAN_INTERCEPT__LONGJMP 0
     38 # define ASAN_INTERCEPT_STRDUP 0
     39 # define ASAN_INTERCEPT_INDEX 0
     40 # define ASAN_INTERCEPT_PTHREAD_CREATE 0
     41 # define ASAN_INTERCEPT_MLOCKX 0
     42 #endif
     43 
     44 #if SANITIZER_LINUX
     45 # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 1
     46 #else
     47 # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 0
     48 #endif
     49 
     50 #if !SANITIZER_MAC
     51 # define ASAN_INTERCEPT_STRNLEN 1
     52 #else
     53 # define ASAN_INTERCEPT_STRNLEN 0
     54 #endif
     55 
     56 #if SANITIZER_LINUX && !SANITIZER_ANDROID
     57 # define ASAN_INTERCEPT_SWAPCONTEXT 1
     58 #else
     59 # define ASAN_INTERCEPT_SWAPCONTEXT 0
     60 #endif
     61 
     62 #if !SANITIZER_ANDROID && !SANITIZER_WINDOWS
     63 # define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 1
     64 #else
     65 # define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 0
     66 #endif
     67 
     68 #if !SANITIZER_WINDOWS
     69 # define ASAN_INTERCEPT_SIGLONGJMP 1
     70 #else
     71 # define ASAN_INTERCEPT_SIGLONGJMP 0
     72 #endif
     73 
     74 #if ASAN_HAS_EXCEPTIONS && !SANITIZER_WINDOWS
     75 # define ASAN_INTERCEPT___CXA_THROW 1
     76 #else
     77 # define ASAN_INTERCEPT___CXA_THROW 0
     78 #endif
     79 
     80 #if !SANITIZER_WINDOWS
     81 # define ASAN_INTERCEPT___CXA_ATEXIT 1
     82 #else
     83 # define ASAN_INTERCEPT___CXA_ATEXIT 0
     84 #endif
     85 
     86 # if SANITIZER_WINDOWS
     87 extern "C" {
     88 // Windows threads.
     89 __declspec(dllimport)
     90 void* __stdcall CreateThread(void *sec, uptr st, void* start,
     91                              void *arg, DWORD fl, DWORD *id);
     92 
     93 int memcmp(const void *a1, const void *a2, uptr size);
     94 void memmove(void *to, const void *from, uptr size);
     95 void* memset(void *block, int c, uptr size);
     96 void* memcpy(void *to, const void *from, uptr size);
     97 char* strcat(char *to, const char* from);  // NOLINT
     98 char* strchr(const char *str, int c);
     99 int strcmp(const char *s1, const char* s2);
    100 char* strcpy(char *to, const char* from);  // NOLINT
    101 uptr strlen(const char *s);
    102 char* strncat(char *to, const char* from, uptr size);
    103 int strncmp(const char *s1, const char* s2, uptr size);
    104 char* strncpy(char *to, const char* from, uptr size);
    105 uptr strnlen(const char *s, uptr maxlen);
    106 int atoi(const char *nptr);
    107 long atol(const char *nptr);  // NOLINT
    108 long strtol(const char *nptr, char **endptr, int base);  // NOLINT
    109 void longjmp(void *env, int value);
    110 double frexp(double x, int *expptr);
    111 }
    112 # endif
    113 
    114 #endif  // ASAN_INTERCEPTED_FUNCTIONS_H
    115