8302599: Extend ASan support to Microsoft Visual C++
Reviewed-by: erikj, stuefe, ihse
This commit is contained in:
parent
c7517b3dec
commit
0bf3a53e01
@ -415,7 +415,8 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER],
|
|||||||
CHECK_AVAILABLE: [
|
CHECK_AVAILABLE: [
|
||||||
AC_MSG_CHECKING([if AddressSanitizer (asan) is available])
|
AC_MSG_CHECKING([if AddressSanitizer (asan) is available])
|
||||||
if test "x$TOOLCHAIN_TYPE" = "xgcc" ||
|
if test "x$TOOLCHAIN_TYPE" = "xgcc" ||
|
||||||
test "x$TOOLCHAIN_TYPE" = "xclang"; then
|
test "x$TOOLCHAIN_TYPE" = "xclang" ||
|
||||||
|
test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
@ -423,11 +424,19 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER],
|
|||||||
fi
|
fi
|
||||||
],
|
],
|
||||||
IF_ENABLED: [
|
IF_ENABLED: [
|
||||||
# ASan is simply incompatible with gcc -Wstringop-truncation. See
|
if test "x$TOOLCHAIN_TYPE" = "xgcc" ||
|
||||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85650
|
test "x$TOOLCHAIN_TYPE" = "xclang"; then
|
||||||
# It's harmless to be suppressed in clang as well.
|
# ASan is simply incompatible with gcc -Wstringop-truncation. See
|
||||||
ASAN_CFLAGS="-fsanitize=address -Wno-stringop-truncation -fno-omit-frame-pointer -fno-common -DADDRESS_SANITIZER"
|
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85650
|
||||||
ASAN_LDFLAGS="-fsanitize=address"
|
# It's harmless to be suppressed in clang as well.
|
||||||
|
ASAN_CFLAGS="-fsanitize=address -Wno-stringop-truncation -fno-omit-frame-pointer -fno-common -DADDRESS_SANITIZER"
|
||||||
|
ASAN_LDFLAGS="-fsanitize=address"
|
||||||
|
elif test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
|
||||||
|
# -Oy- is equivalent to -fno-omit-frame-pointer in GCC/Clang.
|
||||||
|
ASAN_CFLAGS="-fsanitize=address -Oy- -DADDRESS_SANITIZER"
|
||||||
|
# MSVC produces a warning if you pass -fsanitize=address to the linker.
|
||||||
|
ASAN_LDFLAGS=""
|
||||||
|
fi
|
||||||
JVM_CFLAGS="$JVM_CFLAGS $ASAN_CFLAGS"
|
JVM_CFLAGS="$JVM_CFLAGS $ASAN_CFLAGS"
|
||||||
JVM_LDFLAGS="$JVM_LDFLAGS $ASAN_LDFLAGS"
|
JVM_LDFLAGS="$JVM_LDFLAGS $ASAN_LDFLAGS"
|
||||||
CFLAGS_JDKLIB="$CFLAGS_JDKLIB $ASAN_CFLAGS"
|
CFLAGS_JDKLIB="$CFLAGS_JDKLIB $ASAN_CFLAGS"
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#if (defined(__GNUC__) && !defined(__clang__)) || __has_attribute(visibility)
|
#if (defined(__GNUC__) && !defined(__clang__)) || __has_attribute(visibility)
|
||||||
#define ATTRIBUTE_DEFAULT_VISIBILITY __attribute__((visibility("default")))
|
#define ATTRIBUTE_DEFAULT_VISIBILITY __attribute__((visibility("default")))
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
#define ATTRIBUTE_DEFAULT_VISIBILITY __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define ATTRIBUTE_DEFAULT_VISIBILITY
|
#define ATTRIBUTE_DEFAULT_VISIBILITY
|
||||||
#endif
|
#endif
|
||||||
@ -43,12 +45,18 @@
|
|||||||
#define ATTRIBUTE_USED
|
#define ATTRIBUTE_USED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#define CDECL __cdecl
|
||||||
|
#else
|
||||||
|
#define CDECL
|
||||||
|
#endif
|
||||||
|
|
||||||
// Override weak symbol exposed by ASan to override default options. This is called by ASan
|
// Override weak symbol exposed by ASan to override default options. This is called by ASan
|
||||||
// extremely early during library loading, before main is called. We need to override the default
|
// extremely early during library loading, before main is called. We need to override the default
|
||||||
// options because LSan is enabled by default and Hotspot is not yet compatible with it.
|
// options because LSan is enabled by default and Hotspot is not yet compatible with it.
|
||||||
// Additionally we need to prevent ASan from handling SIGSEGV, so that Hotspot's crash handler is
|
// Additionally we need to prevent ASan from handling SIGSEGV, so that Hotspot's crash handler is
|
||||||
// used. You can override these options by setting the environment variable ASAN_OPTIONS.
|
// used. You can override these options by setting the environment variable ASAN_OPTIONS.
|
||||||
ATTRIBUTE_DEFAULT_VISIBILITY ATTRIBUTE_USED const char* __asan_default_options() {
|
ATTRIBUTE_DEFAULT_VISIBILITY ATTRIBUTE_USED const char* CDECL __asan_default_options() {
|
||||||
return
|
return
|
||||||
#ifdef LEAK_SANITIZER
|
#ifdef LEAK_SANITIZER
|
||||||
"leak_check_at_exit=0,"
|
"leak_check_at_exit=0,"
|
||||||
|
Loading…
Reference in New Issue
Block a user