From 8c9ee176a61d7591e666700e41af2aadb60b8f6a Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Tue, 5 Dec 2017 14:17:35 +0000 Subject: [PATCH] gcc: xtensa: enable address sanitizer gcc/ 2017-12-05 Max Filippov * config/xtensa/xtensa.c (xtensa_asan_shadow_offset): New function. (TARGET_ASAN_SHADOW_OFFSET): New macro definition. * config/xtensa/xtensa.h (FRAME_GROWS_DOWNWARD): Set to 1 if ASAN is enabled. From-SVN: r255420 --- gcc/ChangeLog | 8 ++++++++ gcc/config/xtensa/xtensa.c | 12 ++++++++++++ gcc/config/xtensa/xtensa.h | 3 ++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4ddc4801cc2..9097671c09a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-12-05 Max Filippov + + * config/xtensa/xtensa.c (xtensa_asan_shadow_offset): New + function. + (TARGET_ASAN_SHADOW_OFFSET): New macro definition. + * config/xtensa/xtensa.h (FRAME_GROWS_DOWNWARD): Set to 1 if + ASAN is enabled. + 2017-12-05 Richard Biener * timevar.def (TV_TREE_RECIP, TV_TREE_SINCOS, TV_TREE_WIDEN_MUL): diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index 1e73b2f4405..92b9a600df8 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -183,6 +183,7 @@ static bool xtensa_hard_regno_mode_ok (unsigned int, machine_mode); static bool xtensa_modes_tieable_p (machine_mode, machine_mode); static HOST_WIDE_INT xtensa_constant_alignment (const_tree, HOST_WIDE_INT); static HOST_WIDE_INT xtensa_starting_frame_offset (void); +static unsigned HOST_WIDE_INT xtensa_asan_shadow_offset (void); @@ -325,6 +326,9 @@ static HOST_WIDE_INT xtensa_starting_frame_offset (void); #undef TARGET_STARTING_FRAME_OFFSET #define TARGET_STARTING_FRAME_OFFSET xtensa_starting_frame_offset +#undef TARGET_ASAN_SHADOW_OFFSET +#define TARGET_ASAN_SHADOW_OFFSET xtensa_asan_shadow_offset + struct gcc_target targetm = TARGET_INITIALIZER; @@ -4413,4 +4417,12 @@ xtensa_starting_frame_offset (void) return crtl->outgoing_args_size; } +/* Implement TARGET_ASAN_SHADOW_OFFSET. */ + +static unsigned HOST_WIDE_INT +xtensa_asan_shadow_offset (void) +{ + return HOST_WIDE_INT_UC (0x10000000); +} + #include "gt-xtensa.h" diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h index b4cf53708b3..1602fae3d9e 100644 --- a/gcc/config/xtensa/xtensa.h +++ b/gcc/config/xtensa/xtensa.h @@ -430,7 +430,8 @@ enum reg_class #define STACK_GROWS_DOWNWARD 1 -#define FRAME_GROWS_DOWNWARD flag_stack_protect +#define FRAME_GROWS_DOWNWARD (flag_stack_protect \ + || (flag_sanitize & SANITIZE_ADDRESS) != 0) /* The ARG_POINTER and FRAME_POINTER are not real Xtensa registers, so they are eliminated to either the stack pointer or hard frame pointer. */ -- 2.30.2