From: Martin Liska Date: Tue, 11 Apr 2017 13:08:08 +0000 (+0200) Subject: Do not instrument register variables in object-size sanitizer (PR sanitizer/70878). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9f679370006ed036fb1545ebc272d4f1b39641a3;p=gcc.git Do not instrument register variables in object-size sanitizer (PR sanitizer/70878). 2017-04-11 Martin Liska PR sanitizer/70878 * ubsan.c (instrument_object_size): Do not instrument register variables. 2017-04-11 Martin Liska PR sanitizer/70878 * gcc.dg/ubsan/pr70878.c: New test. From-SVN: r246837 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c56b4505a35..71894ec9b4c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-04-11 Martin Liska + + PR sanitizer/70878 + * ubsan.c (instrument_object_size): Do not instrument register + variables. + 2017-04-11 Jakub Jelinek PR target/80381 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ebfe7392a98..116b5b2707d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-04-11 Martin Liska + + PR sanitizer/70878 + * gcc.dg/ubsan/pr70878.c: New test. + 2017-04-11 Jakub Jelinek PR target/80381 diff --git a/gcc/testsuite/gcc.dg/ubsan/pr70878.c b/gcc/testsuite/gcc.dg/ubsan/pr70878.c new file mode 100644 index 00000000000..acd7fb05e4c --- /dev/null +++ b/gcc/testsuite/gcc.dg/ubsan/pr70878.c @@ -0,0 +1,9 @@ +/* PR sanitizer/80878 */ +/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */ +/* { dg-options "-fsanitize=object-size" } */ + +void * sbrk () +{ + volatile register unsigned int sp_r1 __asm__ ("ebx"); + return __builtin_strcat ((char*)sp_r1, 0); /* { dg-warning "cast to pointer from integer of different size" } */ +} diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 323c1ccdb49..c01d63318c2 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -1806,7 +1806,11 @@ instrument_object_size (gimple_stmt_iterator *gsi, bool is_lhs) bool decl_p = DECL_P (inner); tree base; if (decl_p) - base = inner; + { + if (DECL_REGISTER (inner)) + return; + base = inner; + } else if (TREE_CODE (inner) == MEM_REF) base = TREE_OPERAND (inner, 0); else