From 8a33a629144374b03d97a4265f7948ee7d54a0df Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 7 Jul 2015 14:37:56 +0200 Subject: [PATCH] native: add address sanitizer make target --- boards/native/Makefile.include | 5 +++++ cpu/native/syscalls.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include index efa7ccaef07d..75e729250ab0 100644 --- a/boards/native/Makefile.include +++ b/boards/native/Makefile.include @@ -90,6 +90,9 @@ all-debug: export CFLAGS += -g all-cachegrind: export CFLAGS += -g all-gprof: export CFLAGS += -pg all-gprof: export LINKFLAGS += -pg +all-asan: export CFLAGS += -fsanitize=address -fno-omit-frame-pointer -g +all-asan: export CFLAGS += -DNATIVE_IN_CALLOC +all-asan: export LINKFLAGS += -fsanitize=address -fno-omit-frame-pointer -g export INCLUDES += $(NATIVEINCLUDES) @@ -121,6 +124,8 @@ all-debug: all all-gprof: all +all-asan: all + all-valgrind: all all-cachegrind: all diff --git a/cpu/native/syscalls.c b/cpu/native/syscalls.c index a9852dc8be44..4c5b9df870c4 100644 --- a/cpu/native/syscalls.c +++ b/cpu/native/syscalls.c @@ -149,7 +149,11 @@ void free(void *ptr) _native_syscall_leave(); } +#ifdef NATIVE_IN_CALLOC +int _native_in_calloc = 1; +#else int _native_in_calloc = 0; +#endif void *calloc(size_t nmemb, size_t size) { /* dynamically load calloc when it's needed - this is necessary to