Hi.
This is a bit forgotten patch. It handles volatile arguments, which should
not be attempted copied into a function local variable.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
Ready to be installed?
Martin
gcc/ChangeLog:
2017-10-11 Martin Liska <[email protected]>
PR sanitizer/82484
* sanopt.c (sanitize_rewrite_addressable_params): Do not handle
volatile arguments.
gcc/testsuite/ChangeLog:
2017-10-11 Martin Liska <[email protected]>
PR sanitizer/82484
* gcc.dg/asan/pr82484.c: New test.
---
gcc/sanopt.c | 4 +++-
gcc/testsuite/gcc.dg/asan/pr82484.c | 5 +++++
2 files changed, 8 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/asan/pr82484.c
diff --git a/gcc/sanopt.c b/gcc/sanopt.c
index cd94638c869..43743130a35 100644
--- a/gcc/sanopt.c
+++ b/gcc/sanopt.c
@@ -1143,7 +1143,9 @@ sanitize_rewrite_addressable_params (function *fun)
arg; arg = DECL_CHAIN (arg))
{
tree type = TREE_TYPE (arg);
- if (TREE_ADDRESSABLE (arg) && !TREE_ADDRESSABLE (type)
+ if (TREE_ADDRESSABLE (arg)
+ && !TREE_ADDRESSABLE (type)
+ && !TREE_THIS_VOLATILE (arg)
&& TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
{
TREE_ADDRESSABLE (arg) = 0;
diff --git a/gcc/testsuite/gcc.dg/asan/pr82484.c b/gcc/testsuite/gcc.dg/asan/pr82484.c
new file mode 100644
index 00000000000..f8051bd300c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/pr82484.c
@@ -0,0 +1,5 @@
+/* PR sanitizer/82484 */
+/* { dg-do compile } */
+
+void foo(volatile int *ptr);
+void a (volatile int b) { foo(&b); }