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 !defined(_WIN32)
     29 # define ASAN_INTERCEPT_ATOLL_AND_STRTOLL 1
     30 # define ASAN_INTERCEPT__LONGJMP 1
     31 # define ASAN_INTERCEPT_STRDUP 1
     32 # define ASAN_INTERCEPT_STRCASECMP_AND_STRNCASECMP 1
     33 # define ASAN_INTERCEPT_INDEX 1
     34 # define ASAN_INTERCEPT_PTHREAD_CREATE 1
     35 # define ASAN_INTERCEPT_MLOCKX 1
     36 #else
     37 # define ASAN_INTERCEPT_ATOLL_AND_STRTOLL 0
     38 # define ASAN_INTERCEPT__LONGJMP 0
     39 # define ASAN_INTERCEPT_STRDUP 0
     40 # define ASAN_INTERCEPT_STRCASECMP_AND_STRNCASECMP 0
     41 # define ASAN_INTERCEPT_INDEX 0
     42 # define ASAN_INTERCEPT_PTHREAD_CREATE 0
     43 # define ASAN_INTERCEPT_MLOCKX 0
     44 #endif
     45 
     46 #if defined(__linux__)
     47 # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 1
     48 #else
     49 # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 0
     50 #endif
     51 
     52 #if !defined(__APPLE__)
     53 # define ASAN_INTERCEPT_STRNLEN 1
     54 #else
     55 # define ASAN_INTERCEPT_STRNLEN 0
     56 #endif
     57 
     58 #if defined(__linux__) && !defined(ANDROID)
     59 # define ASAN_INTERCEPT_SWAPCONTEXT 1
     60 #else
     61 # define ASAN_INTERCEPT_SWAPCONTEXT 0
     62 #endif
     63 
     64 #if !defined(ANDROID) && !defined(_WIN32)
     65 # define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 1
     66 #else
     67 # define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 0
     68 #endif
     69 
     70 #if !defined(_WIN32)
     71 # define ASAN_INTERCEPT_SIGLONGJMP 1
     72 #else
     73 # define ASAN_INTERCEPT_SIGLONGJMP 0
     74 #endif
     75 
     76 #if ASAN_HAS_EXCEPTIONS && !defined(_WIN32)
     77 # define ASAN_INTERCEPT___CXA_THROW 1
     78 #else
     79 # define ASAN_INTERCEPT___CXA_THROW 0
     80 #endif
     81 
     82 # if defined(_WIN32)
     83 extern "C" {
     84 // Windows threads.
     85 __declspec(dllimport)
     86 void* __stdcall CreateThread(void *sec, uptr st, void* start,
     87                              void *arg, DWORD fl, DWORD *id);
     88 
     89 int memcmp(const void *a1, const void *a2, uptr size);
     90 void memmove(void *to, const void *from, uptr size);
     91 void* memset(void *block, int c, uptr size);
     92 void* memcpy(void *to, const void *from, uptr size);
     93 char* strcat(char *to, const char* from);  // NOLINT
     94 char* strchr(const char *str, int c);
     95 int strcmp(const char *s1, const char* s2);
     96 char* strcpy(char *to, const char* from);  // NOLINT
     97 uptr strlen(const char *s);
     98 char* strncat(char *to, const char* from, uptr size);
     99 int strncmp(const char *s1, const char* s2, uptr size);
    100 char* strncpy(char *to, const char* from, uptr size);
    101 uptr strnlen(const char *s, uptr maxlen);
    102 int atoi(const char *nptr);
    103 long atol(const char *nptr);  // NOLINT
    104 long strtol(const char *nptr, char **endptr, int base);  // NOLINT
    105 void longjmp(void *env, int value);
    106 double frexp(double x, int *expptr);
    107 }
    108 # endif
    109 
    110 #endif  // ASAN_INTERCEPTED_FUNCTIONS_H
    111