From patchwork Fri Sep 5 14:49:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 36848 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4FF6C202A1 for ; Fri, 5 Sep 2014 14:49:34 +0000 (UTC) Received: by mail-oi0-f70.google.com with SMTP id u20sf55533093oif.5 for ; Fri, 05 Sep 2014 07:49:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:date:message-id :subject:from:to:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe:content-type; bh=vpl+ltNLb1bN/6Hj6PeoaYCOHLGuNCbHdAHAEIhNS4k=; b=bvlKD/xLQ1Pe+JR6gipd7trLM4+tCB7nN7KfcJgiJvhBaJtbVeMgRa7y2DALTDTVCg 4MBHXCwa6ey5kSAeg599G7G7qt9kcQpjEt3fSNKHqNxwOoNeXyCK1aa0WE3x3vxkVSpY zPYSHoj3VqbWm+K8bWkJdIdwWWaECrhuS89vNqLDuJVwpdBha6Q0IwLljzlw2NOfJfuN ENip26mQJ1GxZpq/jYDL205Nzb5eEZQUgX5fvb0MAZ1iTCsfTujp/g74FVVsALP6+Eqy KjZXC0nqiqD+GlqgExSgGugFJwg54AyGHBZ7Jy6bDl61UfEaxfAWXOgmHne45A8CGiwz tm8g== X-Gm-Message-State: ALoCoQlEsu1SEq4Y+gBif03vttMcfefc3b3gR4yDjNj5kn61wWCVnDVrLcP5dFnqnt26SE2J09cp X-Received: by 10.50.28.68 with SMTP id z4mr2152763igg.2.1409928569922; Fri, 05 Sep 2014 07:49:29 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.44.119 with SMTP id f110ls791861qga.96.gmail; Fri, 05 Sep 2014 07:49:29 -0700 (PDT) X-Received: by 10.221.48.201 with SMTP id ux9mr1321961vcb.68.1409928569752; Fri, 05 Sep 2014 07:49:29 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id l2si1397773vdx.44.2014.09.05.07.49.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 07:49:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id id10so12461868vcb.16 for ; Fri, 05 Sep 2014 07:49:29 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr11180683vcn.16.1409928569638; Fri, 05 Sep 2014 07:49:29 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp93610vcb; Fri, 5 Sep 2014 07:49:28 -0700 (PDT) X-Received: by 10.224.12.134 with SMTP id x6mr18554939qax.1.1409928568607; Fri, 05 Sep 2014 07:49:28 -0700 (PDT) Received: from mail-qg0-f43.google.com (mail-qg0-f43.google.com [209.85.192.43]) by mx.google.com with ESMTPS id c88si1879308qgf.66.2014.09.05.07.49.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 07:49:28 -0700 (PDT) Received-SPF: pass (google.com: domain of christophe.lyon@linaro.org designates 209.85.192.43 as permitted sender) client-ip=209.85.192.43; Received: by mail-qg0-f43.google.com with SMTP id a108so960087qge.30 for ; Fri, 05 Sep 2014 07:49:28 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.229.206.68 with SMTP id ft4mr19314064qcb.28.1409928568215; Fri, 05 Sep 2014 07:49:28 -0700 (PDT) Received: by 10.140.25.227 with HTTP; Fri, 5 Sep 2014 07:49:28 -0700 (PDT) Date: Fri, 5 Sep 2014 16:49:28 +0200 Message-ID: Subject: [Patch, AArch64] Enable Address sanitizer and UB sanitizer From: Christophe Lyon To: "gcc-patches@gcc.gnu.org" , Patch Tracking X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christophe.lyon@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Hi, The attached patch enables the address and undefined behavior sanitizers. I have tested it on AArch64 hardware, and asan.exp tests pass, but a few ubsan.exp tests fail as follows: FAIL: c-c++-common/ubsan/float-cast-overflow-1.c -O3 -g execution test FAIL: c-c++-common/ubsan/float-cast-overflow-1.c -O2 -flto -flto-partition=none execution test FAIL: c-c++-common/ubsan/float-cast-overflow-2.c -O3 -g execution test FAIL: c-c++-common/ubsan/float-cast-overflow-3.c -O3 -g execution test FAIL: c-c++-common/ubsan/float-cast-overflow-4.c -O2 execution test FAIL: c-c++-common/ubsan/float-cast-overflow-4.c -O3 -g execution test FAIL: c-c++-common/ubsan/overflow-int128.c -O0 (internal compiler error) FAIL: c-c++-common/ubsan/overflow-int128.c -O0 (test for excess errors) FAIL: c-c++-common/ubsan/overflow-int128.c -O1 (internal compiler error) FAIL: c-c++-common/ubsan/overflow-int128.c -O1 (test for excess errors) FAIL: c-c++-common/ubsan/overflow-int128.c -O2 (internal compiler error) FAIL: c-c++-common/ubsan/overflow-int128.c -O2 (test for excess errors) FAIL: c-c++-common/ubsan/overflow-int128.c -O3 -fomit-frame-pointer (internal compiler error) FAIL: c-c++-common/ubsan/overflow-int128.c -O3 -fomit-frame-pointer (test for excess errors) FAIL: c-c++-common/ubsan/overflow-int128.c -O3 -g (internal compiler error) FAIL: c-c++-common/ubsan/overflow-int128.c -O3 -g (test for excess errors) FAIL: c-c++-common/ubsan/overflow-int128.c -Os (internal compiler error) FAIL: c-c++-common/ubsan/overflow-int128.c -Os (test for excess errors) FAIL: c-c++-common/ubsan/overflow-int128.c -O2 -flto -flto-partition=none (internal compiler error) FAIL: c-c++-common/ubsan/overflow-int128.c -O2 -flto -flto-partition=none (test for excess errors) FAIL: c-c++-common/ubsan/overflow-int128.c -O2 -flto (internal compiler error) FAIL: c-c++-common/ubsan/overflow-int128.c -O2 -flto (test for excess errors) FAIL: gcc.dg/ubsan/float-cast-overflow-bf.c -O3 -g execution test I think all these failures need to be addressed separately, and should not prevent from adding the functionality since most of them pass. Note that an update of libsanitizer is required, to include at least revision 209641 (which fixes internal_fork for AArch64). OK for trunk? Christophe. 2014-09-05 Christophe Lyon gcc/ * config/aarch64/aarch64-linux.h (ASAN_CC1_SPEC): Define. (CC1_SPEC): Define. * config/aarch64/aarch64.c (aarch64_asan_shadow_offset): New function. (TARGET_ASAN_SHADOW_OFFSET): Define. libsanitizer/ * configure.tgt: Add AArch64 pattern. diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h index 8d20310..2278516 100644 --- a/gcc/config/aarch64/aarch64-linux.h +++ b/gcc/config/aarch64/aarch64-linux.h @@ -23,6 +23,12 @@ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" +#undef ASAN_CC1_SPEC +#define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}" + +#undef CC1_SPEC +#define CC1_SPEC GNU_USER_TARGET_CC1_SPEC ASAN_CC1_SPEC + #define CPP_SPEC "%{pthread:-D_REENTRANT}" #define LINUX_TARGET_LINK_SPEC "%{h*} \ diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index c3c871e..39b9fd2 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -9826,6 +9826,14 @@ aarch64_expand_movmem (rtx *operands) return true; } +/* Implement the TARGET_ASAN_SHADOW_OFFSET hook. */ + +static unsigned HOST_WIDE_INT +aarch64_asan_shadow_offset (void) +{ + return (HOST_WIDE_INT_1 << 36); +} + #undef TARGET_ADDRESS_COST #define TARGET_ADDRESS_COST aarch64_address_cost @@ -10072,6 +10080,9 @@ aarch64_expand_movmem (rtx *operands) #undef TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS #define TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS true +#undef TARGET_ASAN_SHADOW_OFFSET +#define TARGET_ASAN_SHADOW_OFFSET aarch64_asan_shadow_offset + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-aarch64.h" diff --git a/libsanitizer/configure.tgt b/libsanitizer/configure.tgt index 6de4a65..2c302ab 100644 --- a/libsanitizer/configure.tgt +++ b/libsanitizer/configure.tgt @@ -35,6 +35,8 @@ case "${target}" in ;; arm*-*-linux*) ;; + aarch64*-*-linux*) + ;; x86_64-*-darwin[1]* | i?86-*-darwin[1]*) TSAN_SUPPORTED=no ;;