From: Paolo Bonzini Date: Mon, 12 Feb 2018 12:47:56 +0000 (+0000) Subject: re PR sanitizer/84307 (asan blocks dead-store elimination) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=74a5138a61291275fc5a509f33f427b3fa51bef4;p=gcc.git re PR sanitizer/84307 (asan blocks dead-store elimination) gcc: 2018-02-12 Paolo Bonzini 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 PR sanitizer/84307 * gcc.dg/asan/pr84307.c: New test. From-SVN: r257585 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6faa322572f..192712f27e1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-02-12 Paolo Bonzini + + 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 PR middle-end/83665 diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def index 5970d0e472c..deacc1e6707 100644 --- a/gcc/internal-fn.def +++ b/gcc/internal-fn.def @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 677fed9da3f..539ff3ec803 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-12 Paolo Bonzini + + PR sanitizer/84307 + * gcc.dg/asan/pr84307.c: New test. + 2018-02-12 Nathan Sidwell * 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 index 00000000000..6e1a1979c47 --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr84307.c @@ -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); +}