Enable -fsanitize-recover for KASan.
authorYury Gribov <y.gribov@samsung.com>
Tue, 28 Oct 2014 10:33:04 +0000 (10:33 +0000)
committerYury Gribov <ygribov@gcc.gnu.org>
Tue, 28 Oct 2014 10:33:04 +0000 (10:33 +0000)
2014-10-28  Yury Gribov  <y.gribov@samsung.com>

gcc/
* asan.c (report_error_func): Add noabort path.
(check_func): Ditto.  Formatting.
(asan_expand_check_ifn): Handle noabort path.
* common.opt (flag_sanitize_recover): Add SANITIZE_KERNEL_ADDRESS
to default value.
* doc/invoke.texi (-fsanitize-recover=): Mention KASan.
* opts.c (finish_options): Reword comment.
* sanitizer.def: Add noabort ASan builtins.

gcc/testsuite/
* c-c++-common/asan/kasan-recover-1.c: New test.
* c-c++-common/asan/kasan-recover-2.c: New test.
* c-c++-common/asan/instrument-with-calls-1.c: Get rid of -save-temps.
* c-c++-common/asan/instrument-with-calls-2.c: Likewise.
* c-c++-common/asan/instrument-with-calls-3.c: Likewise.
* c-c++-common/asan/kasan-recover-1.c: Likewise.
* c-c++-common/asan/kasan-recover-2.c: Likewise.
* c-c++-common/asan/no-asan-globals.c: Likewise.
* c-c++-common/asan/no-instrument-reads.c: Likewise.
* c-c++-common/asan/no-instrument-writes.c: Likewise.
* c-c++-common/asan/no-use-after-return.c: Likewise.

From-SVN: r216778

16 files changed:
gcc/ChangeLog
gcc/asan.c
gcc/common.opt
gcc/doc/invoke.texi
gcc/opts.c
gcc/sanitizer.def
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/asan/instrument-with-calls-1.c
gcc/testsuite/c-c++-common/asan/instrument-with-calls-2.c
gcc/testsuite/c-c++-common/asan/instrument-with-calls-3.c
gcc/testsuite/c-c++-common/asan/kasan-recover-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/asan/kasan-recover-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/asan/no-asan-globals.c
gcc/testsuite/c-c++-common/asan/no-instrument-reads.c
gcc/testsuite/c-c++-common/asan/no-instrument-writes.c
gcc/testsuite/c-c++-common/asan/no-use-after-return.c

index 6076258968d508e650a130cb165ca312cc2115ee..1517a80bac15c9699bff2b6f22f83e33855a8564 100644 (file)
@@ -1,3 +1,14 @@
+2014-10-28  Yury Gribov  <y.gribov@samsung.com>
+
+       * asan.c (report_error_func): Add noabort path.
+       (check_func): Ditto.  Formatting.
+       (asan_expand_check_ifn): Handle noabort path.
+       * common.opt (flag_sanitize_recover): Add SANITIZE_KERNEL_ADDRESS
+       to default value.
+       * doc/invoke.texi (-fsanitize-recover=): Mention KASan.
+       * opts.c (finish_options): Reword comment.
+       * sanitizer.def: Add noabort ASan builtins.
+
 2014-10-28  Yury Gribov  <y.gribov@samsung.com>
 
        * asan.c (set_asan_shadow_offset): New function.
index 9080fc3a373d55359a2c293342db6fcc497861ce..8612655c09d96bd5a0e27b82c70ebafc37907bbf 100644 (file)
@@ -1392,44 +1392,72 @@ asan_protect_global (tree decl)
    IS_STORE is either 1 (for a store) or 0 (for a load).  */
 
 static tree
-report_error_func (bool is_store, HOST_WIDE_INT size_in_bytes, int *nargs)
-{
-  static enum built_in_function report[2][6]
-    = { { BUILT_IN_ASAN_REPORT_LOAD1, BUILT_IN_ASAN_REPORT_LOAD2,
-         BUILT_IN_ASAN_REPORT_LOAD4, BUILT_IN_ASAN_REPORT_LOAD8,
-         BUILT_IN_ASAN_REPORT_LOAD16, BUILT_IN_ASAN_REPORT_LOAD_N },
-       { BUILT_IN_ASAN_REPORT_STORE1, BUILT_IN_ASAN_REPORT_STORE2,
-         BUILT_IN_ASAN_REPORT_STORE4, BUILT_IN_ASAN_REPORT_STORE8,
-         BUILT_IN_ASAN_REPORT_STORE16, BUILT_IN_ASAN_REPORT_STORE_N } };
+report_error_func (bool is_store, bool recover_p, HOST_WIDE_INT size_in_bytes,
+                  int *nargs)
+{
+  static enum built_in_function report[2][2][6]
+    = { { { BUILT_IN_ASAN_REPORT_LOAD1, BUILT_IN_ASAN_REPORT_LOAD2,
+           BUILT_IN_ASAN_REPORT_LOAD4, BUILT_IN_ASAN_REPORT_LOAD8,
+           BUILT_IN_ASAN_REPORT_LOAD16, BUILT_IN_ASAN_REPORT_LOAD_N },
+         { BUILT_IN_ASAN_REPORT_STORE1, BUILT_IN_ASAN_REPORT_STORE2,
+           BUILT_IN_ASAN_REPORT_STORE4, BUILT_IN_ASAN_REPORT_STORE8,
+           BUILT_IN_ASAN_REPORT_STORE16, BUILT_IN_ASAN_REPORT_STORE_N } },
+       { { BUILT_IN_ASAN_REPORT_LOAD1_NOABORT,
+           BUILT_IN_ASAN_REPORT_LOAD2_NOABORT,
+           BUILT_IN_ASAN_REPORT_LOAD4_NOABORT,
+           BUILT_IN_ASAN_REPORT_LOAD8_NOABORT,
+           BUILT_IN_ASAN_REPORT_LOAD16_NOABORT,
+           BUILT_IN_ASAN_REPORT_LOAD_N_NOABORT },
+         { BUILT_IN_ASAN_REPORT_STORE1_NOABORT,
+           BUILT_IN_ASAN_REPORT_STORE2_NOABORT,
+           BUILT_IN_ASAN_REPORT_STORE4_NOABORT,
+           BUILT_IN_ASAN_REPORT_STORE8_NOABORT,
+           BUILT_IN_ASAN_REPORT_STORE16_NOABORT,
+           BUILT_IN_ASAN_REPORT_STORE_N_NOABORT } } };
   if (size_in_bytes == -1)
     {
       *nargs = 2;
-      return builtin_decl_implicit (report[is_store][5]);
+      return builtin_decl_implicit (report[recover_p][is_store][5]);
     }
   *nargs = 1;
-  return builtin_decl_implicit (report[is_store][exact_log2 (size_in_bytes)]);
+  int size_log2 = exact_log2 (size_in_bytes);
+  return builtin_decl_implicit (report[recover_p][is_store][size_log2]);
 }
 
 /* Construct a function tree for __asan_{load,store}{1,2,4,8,16,_n}.
    IS_STORE is either 1 (for a store) or 0 (for a load).  */
 
 static tree
-check_func (bool is_store, int size_in_bytes, int *nargs)
-{
-  static enum built_in_function check[2][6]
-    = { { BUILT_IN_ASAN_LOAD1, BUILT_IN_ASAN_LOAD2,
-      BUILT_IN_ASAN_LOAD4, BUILT_IN_ASAN_LOAD8,
-      BUILT_IN_ASAN_LOAD16, BUILT_IN_ASAN_LOADN },
-       { BUILT_IN_ASAN_STORE1, BUILT_IN_ASAN_STORE2,
-      BUILT_IN_ASAN_STORE4, BUILT_IN_ASAN_STORE8,
-      BUILT_IN_ASAN_STORE16, BUILT_IN_ASAN_STOREN } };
+check_func (bool is_store, bool recover_p, HOST_WIDE_INT size_in_bytes,
+           int *nargs)
+{
+  static enum built_in_function check[2][2][6]
+    = { { { BUILT_IN_ASAN_LOAD1, BUILT_IN_ASAN_LOAD2,
+           BUILT_IN_ASAN_LOAD4, BUILT_IN_ASAN_LOAD8,
+           BUILT_IN_ASAN_LOAD16, BUILT_IN_ASAN_LOADN },
+         { BUILT_IN_ASAN_STORE1, BUILT_IN_ASAN_STORE2,
+           BUILT_IN_ASAN_STORE4, BUILT_IN_ASAN_STORE8,
+           BUILT_IN_ASAN_STORE16, BUILT_IN_ASAN_STOREN } },
+       { { BUILT_IN_ASAN_LOAD1_NOABORT,
+           BUILT_IN_ASAN_LOAD2_NOABORT,
+           BUILT_IN_ASAN_LOAD4_NOABORT,
+           BUILT_IN_ASAN_LOAD8_NOABORT,
+           BUILT_IN_ASAN_LOAD16_NOABORT,
+           BUILT_IN_ASAN_LOADN_NOABORT },
+         { BUILT_IN_ASAN_STORE1_NOABORT,
+           BUILT_IN_ASAN_STORE2_NOABORT,
+           BUILT_IN_ASAN_STORE4_NOABORT,
+           BUILT_IN_ASAN_STORE8_NOABORT,
+           BUILT_IN_ASAN_STORE16_NOABORT,
+           BUILT_IN_ASAN_STOREN_NOABORT } } };
   if (size_in_bytes == -1)
     {
       *nargs = 2;
-      return builtin_decl_implicit (check[is_store][5]);
+      return builtin_decl_implicit (check[recover_p][is_store][5]);
     }
   *nargs = 1;
-  return builtin_decl_implicit (check[is_store][exact_log2 (size_in_bytes)]);
+  int size_log2 = exact_log2 (size_in_bytes);
+  return builtin_decl_implicit (check[recover_p][is_store][size_log2]);
 }
 
 /* Split the current basic block and create a condition statement
@@ -2550,6 +2578,9 @@ asan_expand_check_ifn (gimple_stmt_iterator *iter, bool use_calls)
   gimple g = gsi_stmt (*iter);
   location_t loc = gimple_location (g);
 
+  bool recover_p
+    = (flag_sanitize & flag_sanitize_recover & SANITIZE_KERNEL_ADDRESS) != 0;
+
   HOST_WIDE_INT flags = tree_to_shwi (gimple_call_arg (g, 0));
   gcc_assert (flags < ASAN_CHECK_LAST);
   bool is_scalar_access = (flags & ASAN_CHECK_SCALAR_ACCESS) != 0;
@@ -2578,7 +2609,7 @@ asan_expand_check_ifn (gimple_stmt_iterator *iter, bool use_calls)
       tree base_addr = gimple_assign_lhs (g);
 
       int nargs;
-      tree fun = check_func (is_store, size_in_bytes, &nargs);
+      tree fun = check_func (is_store, recover_p, size_in_bytes, &nargs);
       if (nargs == 1)
        g = gimple_build_call (fun, 1, base_addr);
       else
@@ -2639,7 +2670,7 @@ asan_expand_check_ifn (gimple_stmt_iterator *iter, bool use_calls)
   basic_block then_bb, else_bb;
   gsi = create_cond_insert_point (&gsi, /*before_p*/false,
                                  /*then_more_likely_p=*/false,
-                                 /*create_then_fallthru_edge=*/false,
+                                 /*create_then_fallthru_edge*/recover_p,
                                  &then_bb,
                                  &else_bb);
 
@@ -2748,7 +2779,7 @@ asan_expand_check_ifn (gimple_stmt_iterator *iter, bool use_calls)
   /* Generate call to the run-time library (e.g. __asan_report_load8).  */
   gsi = gsi_start_bb (then_bb);
   int nargs;
-  tree fun = report_error_func (is_store, size_in_bytes, &nargs);
+  tree fun = report_error_func (is_store, recover_p, size_in_bytes, &nargs);
   g = gimple_build_call (fun, nargs, base_addr, len);
   gimple_set_location (g, loc);
   gsi_insert_after (&gsi, g, GSI_NEW_STMT);
index 334d586d2027ebca2de3e20cfa6dedca58c2ea83..b4006367f8832883ce5a3419c5b8144e15aaa064 100644 (file)
@@ -213,7 +213,7 @@ unsigned int flag_sanitize
 
 ; What sanitizers should recover from errors
 Variable
-unsigned int flag_sanitize_recover = SANITIZE_UNDEFINED | SANITIZE_NONDEFAULT
+unsigned int flag_sanitize_recover = SANITIZE_UNDEFINED | SANITIZE_NONDEFAULT | SANITIZE_KERNEL_ADDRESS
 
 ; Flag whether a prefix has been added to dump_base_name
 Variable
index a4901f6fbacbd784494414a83debc92e66f24885..792f25bba45b5308024c750eb83542b0c7da53fb 100644 (file)
@@ -5662,13 +5662,13 @@ and program will exit after that with non-zero exit code.
 
 Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
 except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
-@option{-fsanitize=float-cast-overflow} and @option{-fsanitize=float-divide-by-zero}.
-For these sanitizers error recovery is turned on by default.
+@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero} and
+@option{-fsanitize=kernel-address}.  For these sanitizers error recovery is turned on by default.
 
 Syntax without explicit @var{opts} parameter is deprecated.  It is equivalent to
-@option{-fsanitize-recover=undefined,float-cast-overflow,float-divide-by-zero}.
+@option{-fsanitize-recover=undefined,float-cast-overflow,float-divide-by-zero,kernel-address}.
 Similarly @option{-fno-sanitize-recover} is equivalent to
-@option{-fno-sanitize-recover=undefined,float-cast-overflow,float-divide-by-zero}.
+@option{-fno-sanitize-recover=undefined,float-cast-overflow,float-divide-by-zero,kernel-address}.
 
 @item -fsanitize-undefined-trap-on-error
 @opindex fsanitize-undefined-trap-on-error
index db30b6548fa00ae2e2430d6d2b80906387b2ff92..752cc84473d3893547a04bf2ea0bc6b215eb6465 100644 (file)
@@ -877,7 +877,7 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
   if (opts->x_dwarf_split_debug_info)
     opts->x_debug_generate_pub_sections = 2;
 
-  /* Userspace and kernel ASan conflict with each other and with TSan.  */
+  /* Userspace and kernel ASan conflict with each other.  */
 
   if ((opts->x_flag_sanitize & SANITIZE_USER_ADDRESS)
       && (opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS))
@@ -885,6 +885,8 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
              "-fsanitize=address is incompatible with "
              "-fsanitize=kernel-address");
 
+  /* And with TSan.  */
+
   if ((opts->x_flag_sanitize & SANITIZE_ADDRESS)
       && (opts->x_flag_sanitize & SANITIZE_THREAD))
     error_at (loc,
index 722311a7868d5e5b6e8b0633149719c59fe6613a..cddc5ea4935e065e0c718bf91946cb99eee3a372 100644 (file)
@@ -57,6 +57,44 @@ DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_STORE16, "__asan_report_store16",
 DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_STORE_N, "__asan_report_store_n",
                      BT_FN_VOID_PTR_PTRMODE,
                      ATTR_TMPURE_NORETURN_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_LOAD1_NOABORT,
+                     "__asan_report_load1_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_LOAD2_NOABORT,
+                     "__asan_report_load2_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_LOAD4_NOABORT,
+                     "__asan_report_load4_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_LOAD8_NOABORT,
+                     "__asan_report_load8_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_LOAD16_NOABORT,
+                     "__asan_report_load16_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_LOAD_N_NOABORT,
+                     "__asan_report_load_n_noabort",
+                     BT_FN_VOID_PTR_PTRMODE,
+                     ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_STORE1_NOABORT,
+                     "__asan_report_store1_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_STORE2_NOABORT,
+                     "__asan_report_store2_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_STORE4_NOABORT,
+                     "__asan_report_store4_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_STORE8_NOABORT,
+                     "__asan_report_store8_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_STORE16_NOABORT,
+                     "__asan_report_store16_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_STORE_N_NOABORT,
+                     "__asan_report_store_n_noabort",
+                     BT_FN_VOID_PTR_PTRMODE,
+                     ATTR_TMPURE_NOTHROW_LEAF_LIST)
 DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_LOAD1, "__asan_load1",
                      BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
 DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_LOAD2, "__asan_load2",
@@ -81,6 +119,30 @@ DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_STORE16, "__asan_store16",
                      BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
 DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_STOREN, "__asan_storeN",
                      BT_FN_VOID_PTR_PTRMODE, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_LOAD1_NOABORT, "__asan_load1_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_LOAD2_NOABORT, "__asan_load2_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_LOAD4_NOABORT, "__asan_load4_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_LOAD8_NOABORT, "__asan_load8_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_LOAD16_NOABORT, "__asan_load16_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_LOADN_NOABORT, "__asan_loadN_noabort",
+                     BT_FN_VOID_PTR_PTRMODE, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_STORE1_NOABORT, "__asan_store1_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_STORE2_NOABORT, "__asan_store2_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_STORE4_NOABORT, "__asan_store4_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_STORE8_NOABORT, "__asan_store8_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_STORE16_NOABORT, "__asan_store16_noabort",
+                     BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_STOREN_NOABORT, "__asan_storeN_noabort",
+                     BT_FN_VOID_PTR_PTRMODE, ATTR_TMPURE_NOTHROW_LEAF_LIST)
 DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REGISTER_GLOBALS,
                      "__asan_register_globals",
                      BT_FN_VOID_PTR_PTRMODE, ATTR_NOTHROW_LEAF_LIST)
index 77254a06d783ea39d6bd8fda807de6cb948fb0ae..e0759c3bd04b415c8e71736fa9caf6e1f2e75c37 100644 (file)
@@ -1,3 +1,17 @@
+2014-10-28  Yury Gribov  <y.gribov@samsung.com>
+
+       * c-c++-common/asan/kasan-recover-1.c: New test.
+       * c-c++-common/asan/kasan-recover-2.c: New test.
+       * c-c++-common/asan/instrument-with-calls-1.c: Get rid of -save-temps.
+       * c-c++-common/asan/instrument-with-calls-2.c: Likewise.
+       * c-c++-common/asan/instrument-with-calls-3.c: Likewise.
+       * c-c++-common/asan/kasan-recover-1.c: Likewise.
+       * c-c++-common/asan/kasan-recover-2.c: Likewise.
+       * c-c++-common/asan/no-asan-globals.c: Likewise.
+       * c-c++-common/asan/no-instrument-reads.c: Likewise.
+       * c-c++-common/asan/no-instrument-writes.c: Likewise.
+       * c-c++-common/asan/no-use-after-return.c: Likewise.
+
 2014-10-28  Yury Gribov  <y.gribov@samsung.com>
 
        * c-c++-common/asan/shadow-offset-1.c: New test.
index 80f762057603d4cfe7574cdb14c1e58d6f8c8b6c..a08b98a47db596f4ef59636aa4cdde282b29d46b 100644 (file)
@@ -1,5 +1,5 @@
-/* { dg-do assemble } */
-/* { dg-options "--param asan-instrumentation-with-call-threshold=0 -save-temps" } */
+/* { dg-do compile } */
+/* { dg-options "--param asan-instrumentation-with-call-threshold=0" } */
 
 void f(char *a, int *b) {
   *b = *a;
@@ -7,4 +7,3 @@ void f(char *a, int *b) {
 
 /* { dg-final { scan-assembler "__asan_load1" } } */
 /* { dg-final { scan-assembler "__asan_store4" } } */
-/* { dg-final { cleanup-saved-temps } } */
index 04fdad09d726d921499dfa1d6a614c842d7541e4..217410c32bef246bdbc8a42bfb72dffff9e1feb8 100644 (file)
@@ -1,5 +1,5 @@
-/* { dg-do assemble } */
-/* { dg-options "--param asan-instrumentation-with-call-threshold=1 -save-temps" } */
+/* { dg-do compile } */
+/* { dg-options "--param asan-instrumentation-with-call-threshold=1" } */
 
 int x;
 
@@ -13,4 +13,3 @@ void f(int *a, int *b) {
 /* { dg-final { scan-assembler-not "__asan_report_store4" } } */
 /* { dg-final { scan-assembler "__asan_load4" } } */
 /* { dg-final { scan-assembler-not "__asan_report_load4" } } */
-/* { dg-final { cleanup-saved-temps } } */
index 3712c7a56aa30420044690789489384b63ce676b..6dbd54951db4dbb408bc5f3d6b1b2886bce90672 100644 (file)
@@ -1,5 +1,5 @@
-/* { dg-do assemble } */
-/* { dg-options "--param asan-instrumentation-with-call-threshold=0 -save-temps" } */
+/* { dg-do compile } */
+/* { dg-options "--param asan-instrumentation-with-call-threshold=0" } */
 
 struct A {
   char x[7];
@@ -11,5 +11,4 @@ void f(struct A *x, struct A *y) {
 
 /* { dg-final { scan-assembler "__asan_loadN" } } */
 /* { dg-final { scan-assembler "__asan_storeN" } } */
-/* { dg-final { cleanup-saved-temps } } */
 
diff --git a/gcc/testsuite/c-c++-common/asan/kasan-recover-1.c b/gcc/testsuite/c-c++-common/asan/kasan-recover-1.c
new file mode 100644 (file)
index 0000000..b7d3dda
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-sanitize=address -fsanitize=kernel-address --param asan-instrumentation-with-call-threshold=100" } */
+
+void
+foo (int *p)
+{
+  *p = 0;
+}
+
+/* { dg-final { scan-assembler "__asan_report_store4_noabort" } } */
+
diff --git a/gcc/testsuite/c-c++-common/asan/kasan-recover-2.c b/gcc/testsuite/c-c++-common/asan/kasan-recover-2.c
new file mode 100644 (file)
index 0000000..03f29c1
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-sanitize=address -fsanitize=kernel-address" } */
+
+void
+foo (int *p)
+{
+  *p = 0;
+}
+
+/* { dg-final { scan-assembler "__asan_store4_noabort" } } */
+
index 70a1f95a3a31fa1ce1e182836005f284e142e616..9bed29e5b67394f4a0cdd6a9c8a7a7330355b478 100644 (file)
@@ -1,5 +1,5 @@
-/* { dg-do assemble } */
-/* { dg-options "-save-temps --param asan-globals=0" } */
+/* { dg-do compile } */
+/* { dg-options "--param asan-globals=0" } */
 
 volatile int ten = 10;
 
@@ -10,4 +10,3 @@ int main() {
 }
 
 /* { dg-final { scan-assembler-not "__asan_register_globals" } } */
-/* { dg-final { cleanup-saved-temps } } */
index df75878de2f45d0522256e6219798613df4e6ec8..00e96df054b88a3192335bd016cf3a38309b9741 100644 (file)
@@ -1,5 +1,5 @@
-/* { dg-do assemble } */
-/* { dg-options "--param asan-instrument-reads=0 -save-temps" } */
+/* { dg-do compile } */
+/* { dg-options "--param asan-instrument-reads=0" } */
 
 volatile int ten = 10;
 
@@ -10,4 +10,3 @@ int main() {
 }
 
 /* { dg-final { scan-assembler-not "__asan_load" } } */
-/* { dg-final { cleanup-saved-temps } } */
index c1500b9fb32181c4751ba26f5c449f6a312b96ae..45370a2e56cb3d07c7e9ba71551170c6a930a39e 100644 (file)
@@ -1,5 +1,5 @@
-/* { dg-do assemble } */
-/* { dg-options "--param asan-instrument-writes=0 -save-temps" } */
+/* { dg-do compile } */
+/* { dg-options "--param asan-instrument-writes=0" } */
 
 volatile int ten = 10;
 
@@ -10,4 +10,3 @@ int main() {
 }
 
 /* { dg-final { scan-assembler-not "__asan_store" } } */
-/* { dg-final { cleanup-saved-temps } } */
index f326e0caee4ef62911e89966cf3e57377501f692..afbc112db380e30e5bb19295e6dacdaa803ae30d 100644 (file)
@@ -1,5 +1,5 @@
-/* { dg-do assemble } */
-/* { dg-options "--param asan-use-after-return=0 -save-temps" } */
+/* { dg-do compile } */
+/* { dg-options "--param asan-use-after-return=0" } */
 
 extern void f(char *);
 
@@ -10,4 +10,3 @@ int main() {
 }
 
 /* { dg-final { scan-assembler-not "__asan_option_detect_stack_use_after_return" } } */
-/* { dg-final { cleanup-saved-temps } } */