parent
1632af603d
commit
ba41e8d2c5
|
@ -16,6 +16,7 @@
|
|||
#include "asan_allocator.h"
|
||||
#include "asan_interface.h"
|
||||
#include "asan_internal.h"
|
||||
#include "asan_mac.h"
|
||||
#include "asan_mapping.h"
|
||||
#include "asan_stack.h"
|
||||
#include "asan_stats.h"
|
||||
|
@ -161,59 +162,6 @@ int internal_memcmp(const void* s1, const void* s2, size_t n) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void InitializeAsanInterceptors() {
|
||||
#ifndef __APPLE__
|
||||
INTERCEPT_FUNCTION(index);
|
||||
#else
|
||||
OVERRIDE_FUNCTION(index, WRAP(strchr));
|
||||
#endif
|
||||
INTERCEPT_FUNCTION(memcmp);
|
||||
INTERCEPT_FUNCTION(memcpy);
|
||||
INTERCEPT_FUNCTION(memmove);
|
||||
INTERCEPT_FUNCTION(memset);
|
||||
INTERCEPT_FUNCTION(strcasecmp);
|
||||
INTERCEPT_FUNCTION(strcat); // NOLINT
|
||||
INTERCEPT_FUNCTION(strchr);
|
||||
INTERCEPT_FUNCTION(strcmp);
|
||||
INTERCEPT_FUNCTION(strcpy); // NOLINT
|
||||
INTERCEPT_FUNCTION(strdup);
|
||||
INTERCEPT_FUNCTION(strlen);
|
||||
INTERCEPT_FUNCTION(strncasecmp);
|
||||
INTERCEPT_FUNCTION(strncmp);
|
||||
INTERCEPT_FUNCTION(strncpy);
|
||||
|
||||
INTERCEPT_FUNCTION(sigaction);
|
||||
INTERCEPT_FUNCTION(signal);
|
||||
INTERCEPT_FUNCTION(longjmp);
|
||||
INTERCEPT_FUNCTION(_longjmp);
|
||||
INTERCEPT_FUNCTION_IF_EXISTS(__cxa_throw);
|
||||
INTERCEPT_FUNCTION(pthread_create);
|
||||
|
||||
#ifdef __APPLE__
|
||||
INTERCEPT_FUNCTION(dispatch_async_f);
|
||||
INTERCEPT_FUNCTION(dispatch_sync_f);
|
||||
INTERCEPT_FUNCTION(dispatch_after_f);
|
||||
INTERCEPT_FUNCTION(dispatch_barrier_async_f);
|
||||
INTERCEPT_FUNCTION(dispatch_group_async_f);
|
||||
// We don't need to intercept pthread_workqueue_additem_np() to support the
|
||||
// libdispatch API, but it helps us to debug the unsupported functions. Let's
|
||||
// intercept it only during verbose runs.
|
||||
if (FLAG_v >= 2) {
|
||||
INTERCEPT_FUNCTION(pthread_workqueue_additem_np);
|
||||
}
|
||||
#else
|
||||
// On Darwin siglongjmp tailcalls longjmp, so we don't want to intercept it
|
||||
// there.
|
||||
INTERCEPT_FUNCTION(siglongjmp);
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
INTERCEPT_FUNCTION(strnlen);
|
||||
#endif
|
||||
if (FLAG_v > 0) {
|
||||
Printf("AddressSanitizer: libc interceptors initialized\n");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace __asan
|
||||
|
||||
|
@ -277,8 +225,7 @@ void *WRAP(signal)(int signum, void *handler) {
|
|||
}
|
||||
|
||||
extern "C"
|
||||
int WRAP(sigaction)(int signum, const struct sigaction *act,
|
||||
struct sigaction *oldact) {
|
||||
int WRAP(sigaction)(int signum, const void *act, void *oldact) {
|
||||
if (!AsanInterceptsSignal(signum)) {
|
||||
return real_sigaction(signum, act, oldact);
|
||||
}
|
||||
|
@ -569,4 +516,63 @@ size_t WRAP(strnlen)(const char *s, size_t maxlen) {
|
|||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
// ---------------------- InitializeAsanInterceptors ---------------- {{{1
|
||||
namespace __asan {
|
||||
void InitializeAsanInterceptors() {
|
||||
#ifndef __APPLE__
|
||||
INTERCEPT_FUNCTION(index);
|
||||
#else
|
||||
OVERRIDE_FUNCTION(index, WRAP(strchr));
|
||||
#endif
|
||||
INTERCEPT_FUNCTION(memcmp);
|
||||
INTERCEPT_FUNCTION(memcpy);
|
||||
INTERCEPT_FUNCTION(memmove);
|
||||
INTERCEPT_FUNCTION(memset);
|
||||
INTERCEPT_FUNCTION(strcasecmp);
|
||||
INTERCEPT_FUNCTION(strcat); // NOLINT
|
||||
INTERCEPT_FUNCTION(strchr);
|
||||
INTERCEPT_FUNCTION(strcmp);
|
||||
INTERCEPT_FUNCTION(strcpy); // NOLINT
|
||||
INTERCEPT_FUNCTION(strdup);
|
||||
INTERCEPT_FUNCTION(strlen);
|
||||
INTERCEPT_FUNCTION(strncasecmp);
|
||||
INTERCEPT_FUNCTION(strncmp);
|
||||
INTERCEPT_FUNCTION(strncpy);
|
||||
|
||||
INTERCEPT_FUNCTION(sigaction);
|
||||
INTERCEPT_FUNCTION(signal);
|
||||
INTERCEPT_FUNCTION(longjmp);
|
||||
INTERCEPT_FUNCTION(_longjmp);
|
||||
INTERCEPT_FUNCTION_IF_EXISTS(__cxa_throw);
|
||||
INTERCEPT_FUNCTION(pthread_create);
|
||||
|
||||
#ifdef __APPLE__
|
||||
INTERCEPT_FUNCTION(dispatch_async_f);
|
||||
INTERCEPT_FUNCTION(dispatch_sync_f);
|
||||
INTERCEPT_FUNCTION(dispatch_after_f);
|
||||
INTERCEPT_FUNCTION(dispatch_barrier_async_f);
|
||||
INTERCEPT_FUNCTION(dispatch_group_async_f);
|
||||
// We don't need to intercept pthread_workqueue_additem_np() to support the
|
||||
// libdispatch API, but it helps us to debug the unsupported functions. Let's
|
||||
// intercept it only during verbose runs.
|
||||
if (FLAG_v >= 2) {
|
||||
INTERCEPT_FUNCTION(pthread_workqueue_additem_np);
|
||||
}
|
||||
#else
|
||||
// On Darwin siglongjmp tailcalls longjmp, so we don't want to intercept it
|
||||
// there.
|
||||
INTERCEPT_FUNCTION(siglongjmp);
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
INTERCEPT_FUNCTION(strnlen);
|
||||
#endif
|
||||
if (FLAG_v > 0) {
|
||||
Printf("AddressSanitizer: libc interceptors initialized\n");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace __asan
|
||||
|
||||
#endif
|
||||
|
|
|
@ -66,22 +66,6 @@
|
|||
do { real_##func = (func##_f)dlsym(RTLD_NEXT, #func); } while (0)
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
int WRAP(memcmp)(const void *a1, const void *a2, size_t size);
|
||||
void *WRAP(memcpy)(void *to, const void *from, size_t size);
|
||||
void *WRAP(memmove)(void *to, const void *from, size_t size);
|
||||
void *WRAP(memset)(void *block, int c, size_t size);
|
||||
int WRAP(strcasecmp)(const char *s1, const char *s2);
|
||||
char *WRAP(strcat)(char *to, const char *from); // NOLINT
|
||||
char *WRAP(strchr)(const char *string, int c);
|
||||
int WRAP(strcmp)(const char *s1, const char *s2);
|
||||
char *WRAP(strcpy)(char *to, const char *from); // NOLINT
|
||||
char *WRAP(strdup)(const char *s);
|
||||
size_t WRAP(strlen)(const char *s);
|
||||
int WRAP(strncasecmp)(const char *s1, const char *s2, size_t n);
|
||||
int WRAP(strncmp)(const char *s1, const char *s2, size_t size);
|
||||
char *WRAP(strncpy)(char *to, const char *from, size_t size);
|
||||
#endif
|
||||
|
||||
namespace __asan {
|
||||
|
||||
|
|
Loading…
Reference in New Issue