From: Sebastian Poeplau <[email protected]>

Address sanitizer requires the memory region configured via sigaltstack to be
8-byte aligned (see ASAN_SHADOW_GRANULARITY and ASAN_SHADOW_SCALE).

gcc/ada/ChangeLog:

        * init.c (__gnat_alternate_stack): add alignment attribute.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/init.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/init.c b/gcc/ada/init.c
index 7aced7fe813..68f37480920 100644
--- a/gcc/ada/init.c
+++ b/gcc/ada/init.c
@@ -594,8 +594,10 @@ __gnat_error_handler (int sig, siginfo_t *si 
ATTRIBUTE_UNUSED, void *ucontext)
 
 #ifndef __ia64__
 #define HAVE_GNAT_ALTERNATE_STACK 1
-/* This must be in keeping with System.OS_Interface.Alternate_Stack_Size.  */
-char __gnat_alternate_stack[32 * 1024];
+/* Address sanitizer requires the alternate stack to be 8-byte aligned,
+   regardless of any extra alignment added by the operating system.  The size
+   must be in keeping with System.OS_Interface.Alternate_Stack_Size.  */
+char __gnat_alternate_stack[32 * 1024] __attribute__ ((aligned (8)));
 #endif
 
 #ifdef __XENO__
-- 
2.53.0

Reply via email to