asan.c (asan_finish_file): Disable __asan_init calls for KASan; don't emit empty...
authorYury Gribov <y.gribov@samsung.com>
Fri, 3 Oct 2014 14:17:28 +0000 (14:17 +0000)
committerYury Gribov <ygribov@gcc.gnu.org>
Fri, 3 Oct 2014 14:17:28 +0000 (14:17 +0000)
2014-10-03  Yury Gribov  <y.gribov@samsung.com>

* asan.c (asan_finish_file): Disable __asan_init calls for KASan;
don't emit empty ctors.

From-SVN: r215851

gcc/ChangeLog
gcc/asan.c

index 56add5bffc1b9f81a8c1452b1ab80ac1cac19397..3ed527741e52152bef9dbd3d002623e1fc3d5aab 100644 (file)
@@ -1,3 +1,8 @@
+2014-10-03  Yury Gribov  <y.gribov@samsung.com>
+
+       * asan.c (asan_finish_file): Disable __asan_init calls for KASan;
+       don't emit empty ctors.
+
 2014-10-03  Eric Botcazou  <ebotcazou@adacore.com>
 
        * convert.c (convert_to_integer): Do not introduce useless conversions
index f520eab4c547d70d43b98ab8514e01e0b4dbee73..247661a528da9eb92c286014add584d84a1638e6 100644 (file)
@@ -2400,8 +2400,11 @@ asan_finish_file (void)
      nor after .LASAN* array.  */
   flag_sanitize &= ~SANITIZE_ADDRESS;
 
-  tree fn = builtin_decl_implicit (BUILT_IN_ASAN_INIT);
-  append_to_statement_list (build_call_expr (fn, 0), &asan_ctor_statements);
+  if (flag_sanitize & SANITIZE_USER_ADDRESS)
+    {
+      tree fn = builtin_decl_implicit (BUILT_IN_ASAN_INIT);
+      append_to_statement_list (build_call_expr (fn, 0), &asan_ctor_statements);
+    }
   FOR_EACH_DEFINED_VARIABLE (vnode)
     if (TREE_ASM_WRITTEN (vnode->decl)
        && asan_protect_global (vnode->decl))
@@ -2438,7 +2441,7 @@ asan_finish_file (void)
       DECL_INITIAL (var) = ctor;
       varpool_node::finalize_decl (var);
 
-      fn = builtin_decl_implicit (BUILT_IN_ASAN_REGISTER_GLOBALS);
+      tree fn = builtin_decl_implicit (BUILT_IN_ASAN_REGISTER_GLOBALS);
       tree gcount_tree = build_int_cst (pointer_sized_int_node, gcount);
       append_to_statement_list (build_call_expr (fn, 2,
                                                 build_fold_addr_expr (var),
@@ -2453,8 +2456,9 @@ asan_finish_file (void)
       cgraph_build_static_cdtor ('D', dtor_statements,
                                 MAX_RESERVED_INIT_PRIORITY - 1);
     }
-  cgraph_build_static_cdtor ('I', asan_ctor_statements,
-                            MAX_RESERVED_INIT_PRIORITY - 1);
+  if (asan_ctor_statements)
+    cgraph_build_static_cdtor ('I', asan_ctor_statements,
+                              MAX_RESERVED_INIT_PRIORITY - 1);
   flag_sanitize |= SANITIZE_ADDRESS;
 }