Skip to content

Commit

Permalink
native: add address sanitizer make target
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Jul 7, 2015
1 parent 5d18244 commit 17c64b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions boards/native/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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-san-addr: export CFLAGS += -fsanitize=address -fno-omit-frame-pointer -g
all-san-addr: export CFLAGS += -DNATIVE_IN_CALLOC
all-san-addr: export LINKFLAGS += -fsanitize=address -fno-omit-frame-pointer -g

export INCLUDES += $(NATIVEINCLUDES)

Expand Down Expand Up @@ -121,6 +124,8 @@ all-debug: all

all-gprof: all

all-san-addr: all

all-valgrind: all

all-cachegrind: all
Expand Down
6 changes: 5 additions & 1 deletion cpu/native/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -162,7 +166,7 @@ void *calloc(size_t nmemb, size_t size)
}
else {
_native_in_calloc = 1;
*(void **)(&real_calloc) = dlsym(RTLD_NEXT, "calloc");
/* *(void **)(&real_calloc) = dlsym(RTLD_NEXT, "calloc"); */
_native_in_calloc = 0;
}
}
Expand Down

0 comments on commit 17c64b5

Please sign in to comment.