re PR sanitizer/84307 (asan blocks dead-store elimination)
authorPaolo Bonzini <bonzini@gnu.org>
Mon, 12 Feb 2018 12:47:56 +0000 (12:47 +0000)
committerPaolo Bonzini <bonzini@gcc.gnu.org>
Mon, 12 Feb 2018 12:47:56 +0000 (12:47 +0000)
gcc:
2018-02-12  Paolo Bonzini <bonzini@gnu.org>

PR sanitizer/84307
* internal-fn.def (ASAN_CHECK): Fix fnspec to account for return value.
(ASAN_MARK): Fix fnspec to account for return value, change pointer
argument from 'R' to 'W' so that the pointed-to datum is clobbered.

gcc/testsuite:
2018-02-12  Paolo Bonzini  <bonzini@gnu.org>

PR sanitizer/84307
* gcc.dg/asan/pr84307.c: New test.

From-SVN: r257585

gcc/ChangeLog
gcc/internal-fn.def
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/asan/pr84307.c [new file with mode: 0644]

index 6faa322572f134d43634dae5d52fcdc0595e9de3..192712f27e1d0ec5bed093ff7136014f193fdba5 100644 (file)
@@ -1,3 +1,10 @@
+2018-02-12  Paolo Bonzini <bonzini@gnu.org>
+
+       PR sanitizer/84307
+       * internal-fn.def (ASAN_CHECK): Fix fnspec to account for return value.
+       (ASAN_MARK): Fix fnspec to account for return value, change pointer
+       argument from 'R' to 'W' so that the pointed-to datum is clobbered.
+
 2018-02-08  Jan Hubicka  <hubicka@ucw.cz>
 
        PR middle-end/83665
index 5970d0e472cf685b71ec748a17c37940f4d11927..deacc1e67070c71bffd8be4ae60f45fbece9ecc6 100644 (file)
@@ -255,8 +255,8 @@ DEF_INTERNAL_FN (UBSAN_PTR, ECF_LEAF | ECF_NOTHROW, ".R.")
 DEF_INTERNAL_FN (UBSAN_OBJECT_SIZE, ECF_LEAF | ECF_NOTHROW, NULL)
 DEF_INTERNAL_FN (ABNORMAL_DISPATCHER, ECF_NORETURN, NULL)
 DEF_INTERNAL_FN (BUILTIN_EXPECT, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL)
-DEF_INTERNAL_FN (ASAN_CHECK, ECF_TM_PURE | ECF_LEAF | ECF_NOTHROW, ".R...")
-DEF_INTERNAL_FN (ASAN_MARK, ECF_LEAF | ECF_NOTHROW, ".R..")
+DEF_INTERNAL_FN (ASAN_CHECK, ECF_TM_PURE | ECF_LEAF | ECF_NOTHROW, "..R..")
+DEF_INTERNAL_FN (ASAN_MARK, ECF_LEAF | ECF_NOTHROW, "..W.")
 DEF_INTERNAL_FN (ASAN_POISON, ECF_LEAF | ECF_NOTHROW | ECF_NOVOPS, NULL)
 DEF_INTERNAL_FN (ASAN_POISON_USE, ECF_LEAF | ECF_NOTHROW | ECF_NOVOPS, NULL)
 DEF_INTERNAL_FN (ADD_OVERFLOW, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL)
index 677fed9da3f419d7b62c7e053cc915ed1823dbfa..539ff3ec803d27237f9083285a8fda8d248b8277 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-12  Paolo Bonzini  <bonzini@gnu.org>
+
+       PR sanitizer/84307
+       * gcc.dg/asan/pr84307.c: New test.
+
 2018-02-12  Nathan Sidwell  <nathan@acm.org>
 
        * g++.dg/parse/pr84263.C: New.
diff --git a/gcc/testsuite/gcc.dg/asan/pr84307.c b/gcc/testsuite/gcc.dg/asan/pr84307.c
new file mode 100644 (file)
index 0000000..6e1a197
--- /dev/null
@@ -0,0 +1,21 @@
+/* PR middle-end/83185 */
+/* { dg-do link } */
+/* { dg-options "-O1" } */
+
+struct f {
+  void (*func)(void);
+};
+
+extern void link_error(void);
+extern int printf(const char *f, ...);
+
+static inline struct f *gimme_null(struct f *result)
+{
+  return 0;
+}
+
+int main(int argc, char **argv)
+{
+  struct f *x = gimme_null(&(struct f) { .func = link_error });
+  printf("%p", x);
+}