# HG changeset patch # User mbaesken # Date 1557822115 -7200 # Node ID 7e5e0b326ed7dbf072d596cee0f1e5c2742a41b4 # Parent 8c63164bd54020e6a859f167f8adcfdcf5c428b3 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds Reviewed-by: erikj diff -r 8c63164bd540 -r 7e5e0b326ed7 make/autoconf/flags-cflags.m4 --- a/make/autoconf/flags-cflags.m4 Mon May 20 14:42:32 2019 +0530 +++ b/make/autoconf/flags-cflags.m4 Tue May 14 10:21:55 2019 +0200 @@ -300,6 +300,20 @@ C_O_FLAG_DEBUG="-O0" C_O_FLAG_DEBUG_JVM="-O0" C_O_FLAG_NONE="-O0" + # -D_FORTIFY_SOURCE=2 hardening option needs optimization (at least -O1) enabled + # set for lower O-levels -U_FORTIFY_SOURCE to overwrite previous settings + if test "x$OPENJDK_TARGET_OS" = xlinux -a "x$DEBUG_LEVEL" = "xfastdebug"; then + ENABLE_FORTIFY_CFLAGS="-D_FORTIFY_SOURCE=2" + DISABLE_FORTIFY_CFLAGS="-U_FORTIFY_SOURCE" + C_O_FLAG_HIGHEST_JVM="${C_O_FLAG_HIGHEST_JVM} ${ENABLE_FORTIFY_CFLAGS}" + C_O_FLAG_HIGHEST="${C_O_FLAG_HIGHEST} ${ENABLE_FORTIFY_CFLAGS}" + C_O_FLAG_HI="${C_O_FLAG_HI} ${ENABLE_FORTIFY_CFLAGS}" + C_O_FLAG_NORM="${C_O_FLAG_NORM} ${ENABLE_FORTIFY_CFLAGS}" + C_O_FLAG_SIZE="${C_O_FLAG_SIZE} ${DISABLE_FORTIFY_CFLAGS}" + C_O_FLAG_DEBUG="${C_O_FLAG_DEBUG} ${DISABLE_FORTIFY_CFLAGS}" + C_O_FLAG_DEBUG_JVM="${C_O_FLAG_DEBUG_JVM} ${DISABLE_FORTIFY_CFLAGS}" + C_O_FLAG_NONE="${C_O_FLAG_NONE} ${DISABLE_FORTIFY_CFLAGS}" + fi elif test "x$TOOLCHAIN_TYPE" = xclang; then if test "x$OPENJDK_TARGET_OS" = xmacosx; then # On MacOSX we optimize for size, something diff -r 8c63164bd540 -r 7e5e0b326ed7 test/fmw/gtest/src/gtest.cc --- a/test/fmw/gtest/src/gtest.cc Mon May 20 14:42:32 2019 +0530 +++ b/test/fmw/gtest/src/gtest.cc Tue May 14 10:21:55 2019 +0200 @@ -34,6 +34,7 @@ #include "gtest/internal/custom/gtest.h" #include "gtest/gtest-spi.h" +#include #include #include #include @@ -4388,7 +4389,8 @@ // errors are ignored as there's nothing better we can do and we // don't want to fail the test because of this. FILE* pfile = posix::FOpen(premature_exit_filepath, "w"); - fwrite("0", 1, 1, pfile); + size_t cnt= fwrite("0", 1, 1, pfile); + assert(cnt == (size_t)1); fclose(pfile); } }