Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1058500 - Add MSan support to the build system. r=ted,waldo
Browse files Browse the repository at this point in the history
  • Loading branch information
choller committed Sep 11, 2014
1 parent ec86005 commit d4a8a19
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build/autoconf/frameptr.m4
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ AC_DEFUN([MOZ_SET_FRAMEPTR_FLAGS], [
esac
fi
# if we are debugging, profiling or using ASAN, we want a frame pointer.
# if we are debugging, profiling or using sanitizers, we want a frame pointer.
if test -z "$MOZ_OPTIMIZE" -o \
-n "$MOZ_PROFILING" -o \
-n "$MOZ_DEBUG" -o \
-n "$MOZ_MSAN" -o \
-n "$MOZ_ASAN"; then
MOZ_FRAMEPTR_FLAGS="$MOZ_ENABLE_FRAME_PTR"
else
Expand Down
16 changes: 16 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,22 @@ if test -n "$MOZ_ASAN"; then
MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
fi
AC_SUBST(MOZ_ASAN)

dnl ========================================================
dnl = Use Memory Sanitizer
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(memory-sanitizer,
[ --enable-memory-sanitizer Enable Memory Sanitizer (default=no)],
MOZ_MSAN=1,
MOZ_MSAN= )
if test -n "$MOZ_MSAN"; then
MOZ_LLVM_HACKS=1
AC_DEFINE(MOZ_MSAN)
MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
fi
AC_SUBST(MOZ_MSAN)

# The LLVM symbolizer is used by all sanitizers
AC_SUBST(LLVM_SYMBOLIZER)

dnl ========================================================
Expand Down
16 changes: 16 additions & 0 deletions js/src/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,22 @@ if test -n "$MOZ_ASAN"; then
MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
fi
AC_SUBST(MOZ_ASAN)

dnl ========================================================
dnl = Use Memory Sanitizer
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(memory-sanitizer,
[ --enable-memory-sanitizer Enable Memory Sanitizer (default=no)],
MOZ_MSAN=1,
MOZ_MSAN= )
if test -n "$MOZ_MSAN"; then
MOZ_LLVM_HACKS=1
AC_DEFINE(MOZ_MSAN)
MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
fi
AC_SUBST(MOZ_MSAN)

# The LLVM symbolizer is used by all sanitizers
AC_SUBST(LLVM_SYMBOLIZER)

dnl ========================================================
Expand Down
23 changes: 23 additions & 0 deletions mfbt/MemoryChecking.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,29 @@ __asan_unpoison_memory_region(void const volatile *addr, size_t size);
#define MOZ_MAKE_MEM_DEFINED(addr, size) \
__asan_unpoison_memory_region((addr), (size))
}
#elif defined(MOZ_MSAN)
#include <stddef.h>

#include "mozilla/Types.h"

extern "C" {
/* These definitions are usually provided through the
* sanitizer/msan_interface.h header installed by MSan.
*/
void MOZ_EXPORT
__msan_poison(void const volatile *addr, size_t size);
void MOZ_EXPORT
__msan_unpoison(void const volatile *addr, size_t size);

#define MOZ_MAKE_MEM_NOACCESS(addr, size) \
__msan_poison((addr), (size))

#define MOZ_MAKE_MEM_UNDEFINED(addr, size) \
__msan_poison((addr), (size))

#define MOZ_MAKE_MEM_DEFINED(addr, size) \
__msan_unpoison((addr), (size))
}
#elif defined(MOZ_VALGRIND)
#define MOZ_MAKE_MEM_NOACCESS(addr, size) \
VALGRIND_MAKE_MEM_NOACCESS((addr), (size))
Expand Down

0 comments on commit d4a8a19

Please sign in to comment.