Hi.

Folowing static assert is added as we may potentially adjust 
ASAN_SHADOW_GRANULARITY
(via ASAN_SHADOW_SHIFT). The assert ensures stack variables will have sufficient
alignment.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

gcc/ChangeLog:

2018-01-09  Martin Liska  <mli...@suse.cz>

        PR sanitizer/82517
        * asan.c (shadow_mem_size): Add static assert.
---
 gcc/asan.c | 5 +++++
 1 file changed, 5 insertions(+)


diff --git a/gcc/asan.c b/gcc/asan.c
index 53630088b76..0421d4282a1 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1228,6 +1228,11 @@ asan_function_start (void)
 static unsigned HOST_WIDE_INT
 shadow_mem_size (unsigned HOST_WIDE_INT size)
 {
+  /* It must be possible to align stack variables to granularity
+     of shadow memory.  */
+  STATIC_ASSERT (BITS_PER_UNIT
+		 * ASAN_SHADOW_GRANULARITY <= MAX_SUPPORTED_STACK_ALIGNMENT);
+
   return ROUND_UP (size, ASAN_SHADOW_GRANULARITY) / ASAN_SHADOW_GRANULARITY;
 }
 

Reply via email to