PR sanitizer/56454
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 28 Feb 2013 21:23:23 +0000 (21:23 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 28 Feb 2013 21:23:23 +0000 (21:23 +0000)
* asan.c (gate_asan): Lookup no_sanitize_address instead of
no_address_safety_analysis attribute.
* doc/extend.texi (no_address_safety_attribute): Rename to
no_sanitize_address attribute, mention no_address_safety_analysis
attribute as deprecated alias.

* c-common.c (handle_no_sanitize_address_attribute): New function.
(c_common_attribute_table): Add no_sanitize_address attribute.
(handle_no_address_safety_analysis_attribute): Add
no_sanitize_address attribute, not no_address_safety_analysis
attribute.

* g++.dg/asan/default-options-1.C (__asan_default_options): Use
no_sanitize_address attribute rather than no_address_safety_analysis.
* g++.dg/asan/sanitizer_test_utils.h
(ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS): Likewise.
* c-c++-common/asan/attrib-1.c: Test no_sanitize_address attribute
in addition to no_address_safety_analysis.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196361 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/asan.c
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/doc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/asan/attrib-1.c
gcc/testsuite/g++.dg/asan/default-options-1.C
gcc/testsuite/g++.dg/asan/sanitizer_test_utils.h

index 833ca4e..5dd088a 100644 (file)
@@ -1,3 +1,13 @@
+2013-02-28  Konstantin Serebryany  <konstantin.s.serebryany@gmail.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/56454
+       * asan.c (gate_asan): Lookup no_sanitize_address instead of
+       no_address_safety_analysis attribute.
+       * doc/extend.texi (no_address_safety_attribute): Rename to
+       no_sanitize_address attribute, mention no_address_safety_analysis
+       attribute as deprecated alias.
+
 2013-02-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/56461
index 67236a9..52a2dbc 100644 (file)
@@ -2277,7 +2277,7 @@ static bool
 gate_asan (void)
 {
   return flag_asan != 0
-         && !lookup_attribute ("no_address_safety_analysis",
+         && !lookup_attribute ("no_sanitize_address",
                                DECL_ATTRIBUTES (current_function_decl));
 }
 
index 50ad101..c1ad40b 100644 (file)
@@ -1,3 +1,13 @@
+2013-02-28  Konstantin Serebryany  <konstantin.s.serebryany@gmail.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/56454
+       * c-common.c (handle_no_sanitize_address_attribute): New function.
+       (c_common_attribute_table): Add no_sanitize_address attribute.
+       (handle_no_address_safety_analysis_attribute): Add
+       no_sanitize_address attribute, not no_address_safety_analysis
+       attribute.
+
 2013-02-18  Aldy Hernandez  <aldyh@redhat.com>
 
        PR target/52555
index a1d47a6..d01de3e 100644 (file)
@@ -307,6 +307,8 @@ static tree handle_common_attribute (tree *, tree, tree, int, bool *);
 static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *);
 static tree handle_hot_attribute (tree *, tree, tree, int, bool *);
 static tree handle_cold_attribute (tree *, tree, tree, int, bool *);
+static tree handle_no_sanitize_address_attribute (tree *, tree, tree,
+                                                 int, bool *);
 static tree handle_no_address_safety_analysis_attribute (tree *, tree, tree,
                                                         int, bool *);
 static tree handle_noinline_attribute (tree *, tree, tree, int, bool *);
@@ -715,6 +717,9 @@ const struct attribute_spec c_common_attribute_table[] =
                              0, 0, true, false, false,
                              handle_no_address_safety_analysis_attribute,
                              false },
+  { "no_sanitize_address",    0, 0, true, false, false,
+                             handle_no_sanitize_address_attribute,
+                             false },
   { "warning",               1, 1, true,  false, false,
                              handle_error_attribute, false },
   { "error",                 1, 1, true,  false, false,
@@ -6505,12 +6510,12 @@ handle_cold_attribute (tree *node, tree name, tree ARG_UNUSED (args),
   return NULL_TREE;
 }
 
-/* Handle a "no_address_safety_analysis" attribute; arguments as in
+/* Handle a "no_sanitize_address" attribute; arguments as in
    struct attribute_spec.handler.  */
 
 static tree
-handle_no_address_safety_analysis_attribute (tree *node, tree name, tree, int,
-                                            bool *no_add_attrs)
+handle_no_sanitize_address_attribute (tree *node, tree name, tree, int,
+                                     bool *no_add_attrs)
 {
   if (TREE_CODE (*node) != FUNCTION_DECL)
     {
@@ -6521,6 +6526,23 @@ handle_no_address_safety_analysis_attribute (tree *node, tree name, tree, int,
   return NULL_TREE;
 }
 
+/* Handle a "no_address_safety_analysis" attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_no_address_safety_analysis_attribute (tree *node, tree name, tree, int,
+                                            bool *no_add_attrs)
+{
+  if (TREE_CODE (*node) != FUNCTION_DECL)
+    warning (OPT_Wattributes, "%qE attribute ignored", name);
+  else if (!lookup_attribute ("no_sanitize_address", DECL_ATTRIBUTES (*node)))
+    DECL_ATTRIBUTES (*node)
+      = tree_cons (get_identifier ("no_sanitize_address"),
+                  NULL_TREE, DECL_ATTRIBUTES (*node));
+  *no_add_attrs = true;
+  return NULL_TREE;
+}
+
 /* Handle a "noinline" attribute; arguments as in
    struct attribute_spec.handler.  */
 
index eb84408..2165983 100644 (file)
@@ -2133,7 +2133,8 @@ attributes are currently defined for functions on all targets:
 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
 @code{warn_unused_result}, @code{nonnull}, @code{gnu_inline},
 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
-@code{no_address_safety_analysis}, @code{error} and @code{warning}.
+@code{no_sanitize_address}, @code{no_address_safety_analysis},
+@code{error} and @code{warning}.
 Several other attributes are defined for functions on particular
 target systems.  Other attributes, including @code{section} are
 supported for variables declarations (@pxref{Variable Attributes})
@@ -3432,11 +3433,15 @@ with computed goto or @code{asm goto}.
 The @code{cold} attribute on labels is not implemented in GCC versions
 earlier than 4.8.
 
-@item no_address_safety_analysis
-@cindex @code{no_address_safety_analysis} function attribute
-The @code{no_address_safety_analysis} attribute on functions is used
+@item no_sanitize_address
+@itemx no_address_safety_analysis
+@cindex @code{no_sanitize_address} function attribute
+The @code{no_sanitize_address} attribute on functions is used
 to inform the compiler that it should not instrument memory accesses
 in the function when compiling with the @option{-fsanitize=address} option.
+The @code{no_address_safety_analysis} is a deprecated alias of the
+@code{no_sanitize_address} attribute, new code should use
+@code{no_sanitize_address}.
 
 @item regparm (@var{number})
 @cindex @code{regparm} attribute
index 7c6afc2..527fefb 100644 (file)
@@ -1,3 +1,14 @@
+2013-02-28  Konstantin Serebryany  <konstantin.s.serebryany@gmail.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/56454
+       * g++.dg/asan/default-options-1.C (__asan_default_options): Use
+       no_sanitize_address attribute rather than no_address_safety_analysis.
+       * g++.dg/asan/sanitizer_test_utils.h
+       (ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS): Likewise.
+       * c-c++-common/asan/attrib-1.c: Test no_sanitize_address attribute
+       in addition to no_address_safety_analysis.
+
 2013-02-28  Jason Merrill  <jason@redhat.com>
 
        PR c++/56481
index e633bb6..a2a7f7c 100644 (file)
@@ -1,7 +1,7 @@
 /* PR sanitizer/55435 */
 /* { dg-do compile } */
 
-__attribute__((no_address_safety_analysis)) int
+__attribute__((no_sanitize_address)) int
 f1 (int *p, int *q)
 {
   *p = 42;
@@ -9,8 +9,8 @@ f1 (int *p, int *q)
 }
 
 void f2 (char *);
-void f2 (char *) __attribute__((no_address_safety_analysis));
-void f2 (char *) __attribute__((no_address_safety_analysis));
+void f2 (char *) __attribute__((no_sanitize_address));
+void f2 (char *) __attribute__((no_sanitize_address));
 void f2 (char *);
 
 void
@@ -20,7 +20,7 @@ f2 (char *p)
 }
 
 void f3 (short *);
-__typeof (f3) f3  __attribute__((__no_address_safety_analysis__));
+__typeof (f3) f3  __attribute__((__no_sanitize_address__));
 
 void
 f3 (short *p)
@@ -28,7 +28,35 @@ f3 (short *p)
   *p = 42;
 }
 
-int v __attribute__((no_address_safety_analysis)); /* { dg-warning "attribute ignored" } */
+__attribute__((no_sanitize_address)) int
+f4 (int *p, int *q)
+{
+  *p = 42;
+  return *q;
+}
+
+void f5 (char *);
+void f5 (char *) __attribute__((no_sanitize_address));
+void f5 (char *) __attribute__((no_sanitize_address));
+void f5 (char *);
+
+void
+f5 (char *p)
+{
+  *p = 42;
+}
+
+void f6 (short *);
+__typeof (f6) f6  __attribute__((__no_address_safety_analysis__));
+
+void
+f6 (short *p)
+{
+  *p = 42;
+}
+
+int v __attribute__((no_sanitize_address)); /* { dg-warning "attribute ignored" } */
+int v2 __attribute__((no_address_safety_analysis)); /* { dg-warning "attribute ignored" } */
 
 /* { dg-final { scan-assembler-not "__asan_report_store" } } */
 /* { dg-final { scan-assembler-not "__asan_report_load" } } */
index 42b4164..cdcb370 100644 (file)
@@ -3,7 +3,7 @@
 const char *kAsanDefaultOptions="verbosity=1 foo=bar";
 
 extern "C"
-__attribute__((no_address_safety_analysis))
+__attribute__((no_sanitize_address))
 const char *__asan_default_options() {
   return kAsanDefaultOptions;
 }
index 2184cc7..99720c3 100644 (file)
@@ -36,7 +36,7 @@ typedef __int64          int64_t;
 
 #if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
 # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \
-    __attribute__((no_address_safety_analysis))
+    __attribute__((no_sanitize_address))
 #else
 # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
 #endif