From aa5bfa8d5d9b5751bc6b1854d663fbf777849711 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 9 Jan 2018 12:47:26 +0100 Subject: [PATCH] Add gcc_assert about stack alignment (PR sanitizer/82517). 2018-01-09 Martin Liska PR sanitizer/82517 * asan.c (shadow_mem_size): Add gcc_assert. From-SVN: r256378 --- gcc/ChangeLog | 5 +++++ gcc/asan.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0def5335339..0d9089b5761 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-01-09 Martin Liska + + PR sanitizer/82517 + * asan.c (shadow_mem_size): Add gcc_assert. + 2018-01-09 Georg-Johann Lay Don't save registers in main(). diff --git a/gcc/asan.c b/gcc/asan.c index 53630088b76..df9bc7b3404 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. */ + gcc_assert (BITS_PER_UNIT + * ASAN_SHADOW_GRANULARITY <= MAX_SUPPORTED_STACK_ALIGNMENT); + return ROUND_UP (size, ASAN_SHADOW_GRANULARITY) / ASAN_SHADOW_GRANULARITY; } -- 2.30.2