Merge "Enable FORTIFY in unoptimized builds"

This commit is contained in:
Treehugger Robot 2017-08-16 20:43:54 +00:00 committed by Gerrit Code Review
commit 67e7bf137e
2 changed files with 10 additions and 3 deletions

View file

@ -239,7 +239,8 @@
#define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1)
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && \
(defined(__clang__) || (defined(__OPTIMIZE__) && __OPTIMIZE__ > 0))
# define __BIONIC_FORTIFY 1
# if _FORTIFY_SOURCE == 2
# define __bos_level 1
@ -281,8 +282,7 @@
#define __pass_object_size __pass_object_size_n(__bos_level)
#define __pass_object_size0 __pass_object_size_n(0)
/* FIXME: This should be __BIONIC_FORTIFY, but we don't enable FORTIFY in -O0. */
#if (defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0) || defined(__BIONIC_DECLARE_FORTIFY_HELPERS)
#if defined(__BIONIC_FORTIFY) || defined(__BIONIC_DECLARE_FORTIFY_HELPERS)
# define __BIONIC_INCLUDE_FORTIFY_HEADERS 1
#endif

View file

@ -119,7 +119,14 @@ static void generateTargetCC1Flags(llvm::IntrusiveRefCntPtr<clang::vfs::FileSyst
cmd.push_back("-DANDROID");
cmd.push_back("-D__ANDROID_API__="s + std::to_string(type.api_level));
// FIXME: Re-enable FORTIFY properly once our clang in external/ is new enough
// to support diagnose_if without giving us syntax errors.
#if 0
cmd.push_back("-D_FORTIFY_SOURCE=2");
#else
cmd.push_back("-D_FORTIFY_SOURCE=0");
cmd.push_back("-D__BIONIC_DECLARE_FORTIFY_HELPERS");
#endif
cmd.push_back("-D_GNU_SOURCE");
cmd.push_back("-D_FILE_OFFSET_BITS="s + std::to_string(type.file_offset_bits));