From patchwork Wed Nov 21 19:25:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: What CPP macro should -fsanitize=address define? Date: Wed, 21 Nov 2012 09:25:35 -0000 From: "H.J. Lu" X-Patchwork-Id: 200837 Message-Id: To: Konstantin Serebryany Cc: GCC Patches On Wed, Nov 21, 2012 at 10:47 AM, Konstantin Serebryany wrote: > On Wed, Nov 21, 2012 at 10:42 PM, H.J. Lu wrote: >> Hi, >> >> I am working on ASAN bootstrap support. I need a CPP macro >> for -fsanitize=address. I am learning toward __SANITIZE_ADDRESS__. > > That would be a reasonable option > (some background: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55397) > Here is a patch. OK to install? Thanks. diff --git a/gcc/cppbuiltin.c b/gcc/cppbuiltin.c index 05d82f5..c3ca21a 100644 --- a/gcc/cppbuiltin.c +++ b/gcc/cppbuiltin.c @@ -91,6 +91,9 @@ define_builtin_macros_for_compilation_flags (cpp_reader *pfile) cpp_define_formatted (pfile, "__PIE__=%d", flag_pie); } + if (flag_asan) + cpp_define (pfile, "__SANITIZE_ADDRESS__"); + if (optimize_size) cpp_define (pfile, "__OPTIMIZE_SIZE__");