From patchwork Fri Mar 23 03:21:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 889765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-475330-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=axis.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ZecH1Qgm"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 406pj639y8z9s1B for ; Fri, 23 Mar 2018 14:21:14 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:cc:subject:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=PCjlcWBcmQ2NMVMy WtxOxOZWEsSRaKpONLqX7sUapijgyTUKbGtFyAZo8NA3Prd/ctTYfAdBDJriojPT 0ZjQN4mUI4oMbI5K5LE5k9BzioJjIiRupIYQ8aanGMEWaRU27T/kDDR/AqPC/png taqBsKCE8igjGlGPM419wDdpxUo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:cc:subject:mime-version:content-type :content-transfer-encoding; s=default; bh=C/LOO0yy5BfqyxiYfphh96 Z5c4A=; b=ZecH1QgmEUsXDbnlDG7BezUbXc3Aw7e+WhT2G+hOmYSZvck6hCTw0S fdhP8r52fNZe8hjzG0OkjsfbZrWuLsxoUXBdXlb4cfEVHAa5tFXI/Kipr50LA1cm r8kv80s+phyOpAGtxtEhEdtHsbS33yzjNP++KkE7aR6PaLJTTO35A= Received: (qmail 37664 invoked by alias); 23 Mar 2018 03:21:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 37414 invoked by uid 89); 23 Mar 2018 03:21:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: bastet.se.axis.com Received: from bastet.se.axis.com (HELO bastet.se.axis.com) (195.60.68.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Mar 2018 03:21:05 +0000 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id F10AE18552; Fri, 23 Mar 2018 04:21:03 +0100 (CET) Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id cv2kfBFCvQTC; Fri, 23 Mar 2018 04:21:03 +0100 (CET) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bastet.se.axis.com (Postfix) with ESMTPS id 4454C182C1; Fri, 23 Mar 2018 04:21:03 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 33C751E07C; Fri, 23 Mar 2018 04:21:03 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 285711E078; Fri, 23 Mar 2018 04:21:03 +0100 (CET) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder03.se.axis.com (Postfix) with ESMTP; Fri, 23 Mar 2018 04:21:03 +0100 (CET) Received: from ignucius.se.axis.com (ignucius.se.axis.com [10.88.21.50]) by seth.se.axis.com (Postfix) with ESMTP id 1B9FB19AB; Fri, 23 Mar 2018 04:21:03 +0100 (CET) Received: from ignucius.se.axis.com (localhost [127.0.0.1]) by ignucius.se.axis.com (8.12.8p1/8.12.8/Debian-2woody1) with ESMTP id w2N3L2g8005847; Fri, 23 Mar 2018 04:21:02 +0100 Received: (from hp@localhost) by ignucius.se.axis.com (8.12.8p1/8.12.8/Debian-2woody1) id w2N3L2lZ005843; Fri, 23 Mar 2018 04:21:02 +0100 Date: Fri, 23 Mar 2018 04:21:02 +0100 Message-Id: <201803230321.w2N3L2lZ005843@ignucius.se.axis.com> From: Hans-Peter Nilsson To: gcc-patches@gcc.gnu.org CC: xiaoyur347@gmail.com, clm@codesourcery.com, matthew.fortune@imgtec.com Subject: [PATCH 4/4] ASAN for MIPS: Add gcc port bits for MIPS to support -fsanitize=address. MIME-Version: 1.0 X-TM-AS-GCONF: 00 Attribution to Jean Lee for spotting the right shadow-offset for MIPS and for cheering on. :) See xtensa and rs6000 back-ends for the FRAME_GROWS_DOWNWARD construct. gcc: 2018-03-22 Hans-Peter Nilsson Jean Lee * config/mips/mips.c (mips_asan_shadow_offset): New function. (TARGET_ASAN_SHADOW_OFFSET): Define. * config/mips/mips.h (FRAME_GROWS_DOWNWARD): Augment to also be true for -fsanitize=address. diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index aabd4b1..bfe64bb 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -22307,6 +22307,14 @@ mips_constant_alignment (const_tree exp, HOST_WIDE_INT align) return align; } +/* Implement the TARGET_ASAN_SHADOW_OFFSET hook. */ + +static unsigned HOST_WIDE_INT +mips_asan_shadow_offset (void) +{ + return 0x0aaa0000; +} + /* Implement TARGET_STARTING_FRAME_OFFSET. See mips_compute_frame_info for details about the frame layout. */ @@ -22618,6 +22626,9 @@ mips_starting_frame_offset (void) #undef TARGET_CONSTANT_ALIGNMENT #define TARGET_CONSTANT_ALIGNMENT mips_constant_alignment +#undef TARGET_ASAN_SHADOW_OFFSET +#define TARGET_ASAN_SHADOW_OFFSET mips_asan_shadow_offset + #undef TARGET_STARTING_FRAME_OFFSET #define TARGET_STARTING_FRAME_OFFSET mips_starting_frame_offset diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index 84ae675..f290560 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -2289,7 +2289,8 @@ enum reg_class #define STACK_GROWS_DOWNWARD 1 -#define FRAME_GROWS_DOWNWARD flag_stack_protect +#define FRAME_GROWS_DOWNWARD (flag_stack_protect != 0 \ + || (flag_sanitize & SANITIZE_ADDRESS) != 0) /* Size of the area allocated in the frame to save the GP. */