From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49924 invoked by alias); 4 Dec 2017 21:29:31 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 49027 invoked by uid 89); 4 Dec 2017 21:29:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,HK_RANDOM_ENVFROM,HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2109 X-HELO: mail-lf0-f65.google.com Received: from mail-lf0-f65.google.com (HELO mail-lf0-f65.google.com) (209.85.215.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Dec 2017 21:29:29 +0000 Received: by mail-lf0-f65.google.com with SMTP id 94so20831730lfy.10 for ; Mon, 04 Dec 2017 13:29:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=COHCK2c6h6Jy5kOYBxUMMExMuRgvmSkDyRXPDYrhrSs=; b=VUAluIM3rzleP+VcSThpgQOGqBHG+G8ddbgX1VsVTxJrNsY8MZGjPjjxMK0/rmdov1 e52vd2ow+qKyRkHFzU/KEB5+us7UHaWZN5WJvAgHhdGSo46ySBk/qQjiashKDQj4fvpn Z5wVMvnKpVyt7Q+gFCeyA7cp+9nvtl7jMLvTtI6e3A8tkEt75A5rvy2YN0f4ttWk9fbg y98/Kh3H+nNZN0+EARNtBuHUJ9cW0IOKo8YTGQM5kGUQTKy2Ld45RlN1cLT+81MhDtD0 xp4epQx5gb5rUSK1OdRKwlYPa4OZzV11AX/J2E2HfyhsB0SmBSbpI8nYEUa7VKncvgEY 0ejA== X-Gm-Message-State: AJaThX68WH3daCg0AbQgKN05MbobeLbEZ2EEpI6tf/filJjbfjEwDCEv Ml141Dj2ZJqKMJlSATgsqToWqw== X-Google-Smtp-Source: AGs4zMYfWFrOmbOucjChZHiY/QNlyERUol5oFVlX+AdRUkxNbSZnggDGX8Y5qyjsCiQ0I7ZwSmis+g== X-Received: by 10.46.27.24 with SMTP id b24mr9871530ljb.54.1512422967206; Mon, 04 Dec 2017 13:29:27 -0800 (PST) Received: from octofox.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id z1sm3023263lja.8.2017.12.04.13.29.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 13:29:26 -0800 (PST) From: Max Filippov To: gcc-patches@gcc.gnu.org Cc: linux-xtensa@linux-xtensa.org, Sterling Augustine , Max Filippov Subject: [PATCH] gcc: xtensa: enable address sanitizer Date: Mon, 04 Dec 2017 21:29:00 -0000 Message-Id: <1512422933-20575-1-git-send-email-jcmvbkbc@gmail.com> X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg00168.txt.bz2 gcc/ 2017-12-04 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. --- gcc/config/xtensa/xtensa.c | 12 ++++++++++++ gcc/config/xtensa/xtensa.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index 1e73b2f4405d..92b9a600df82 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 b4cf53708b3e..1602fae3d9ea 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.1.4