From d8881440285723742002c5a51954dc0c9af72a8c Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Tue, 5 Dec 2017 14:31:41 +0000 Subject: [PATCH] xtensa: enable address sanitizer 2017-12-05 Max Filippov Backport from mainline 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: r255422 --- gcc/ChangeLog | 10 ++++++++++ gcc/config/xtensa/xtensa.c | 12 ++++++++++++ gcc/config/xtensa/xtensa.h | 3 ++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d9d00ed7f35..984d70297c7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2017-12-05 Max Filippov + + Backport from mainline + 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 Max Filippov Backport from mainline diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index cbbead0fa95..9bdf870a0fd 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -176,6 +176,7 @@ static bool xtensa_member_type_forces_blk (const_tree, machine_mode mode); static void xtensa_conditional_register_usage (void); +static unsigned HOST_WIDE_INT xtensa_asan_shadow_offset (void); @@ -304,6 +305,9 @@ static void xtensa_conditional_register_usage (void); #undef TARGET_CONDITIONAL_REGISTER_USAGE #define TARGET_CONDITIONAL_REGISTER_USAGE xtensa_conditional_register_usage +#undef TARGET_ASAN_SHADOW_OFFSET +#define TARGET_ASAN_SHADOW_OFFSET xtensa_asan_shadow_offset + struct gcc_target targetm = TARGET_INITIALIZER; @@ -4337,4 +4341,12 @@ enum reg_class xtensa_regno_to_class (int regno) return regno_to_class[regno]; } +/* 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 08457a435a2..ec9ee59b092 100644 --- a/gcc/config/xtensa/xtensa.h +++ b/gcc/config/xtensa/xtensa.h @@ -460,7 +460,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) /* Offset within stack frame to start allocating local variables at. */ #define STARTING_FRAME_OFFSET \