Patchwork What CPP macro should -fsanitize=address define?

login
register
mail settings
Submitter H.J. Lu
Date Nov. 21, 2012, 7:25 p.m.
Message ID <CAMe9rOrT7qt0c0mYF=BeUhuBNi+az6scXBnvBC=F1nW-37R44A@mail.gmail.com>
Download mbox | patch
Permalink /patch/200837/
State New
Headers show

Comments

H.J. Lu - Nov. 21, 2012, 7:25 p.m.
On Wed, Nov 21, 2012 at 10:47 AM, Konstantin Serebryany
<konstantin.s.serebryany@gmail.com> wrote:
> On Wed, Nov 21, 2012 at 10:42 PM, H.J. Lu <hjl.tools@gmail.com> 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.
Jakub Jelinek - Nov. 21, 2012, 8:12 p.m.
On Wed, Nov 21, 2012 at 11:25:35AM -0800, H.J. Lu wrote:
> 2012-11-21  H.J. Lu  <hongjiu.lu@intel.com>
> 
> 	PR c/55397
> 	* cppbuiltin.c (define_builtin_macros_for_compilation_flags):
> 	Define __SANITIZE_ADDRESS__ for flag_asan.

Ok, thanks.

> --- 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__");
>    if (optimize)

	Jakub

Patch

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__");