From patchwork Wed Mar 27 22:09:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 15710 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 49D2123E66 for ; Wed, 27 Mar 2013 22:10:00 +0000 (UTC) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by fiordland.canonical.com (Postfix) with ESMTP id DA4E6A18426 for ; Wed, 27 Mar 2013 22:09:59 +0000 (UTC) Received: by mail-ve0-f169.google.com with SMTP id d10so3822628vea.14 for ; Wed, 27 Mar 2013 15:09:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:mime-version:x-received:date:message-id:subject:from :to:content-type:x-gm-message-state; bh=aYTVag8Vcsl/QfsKCYrr+WLz9BDcXbikWsVgRBQu+2g=; b=kv2MNoe4fLGoQToyNCeEFMR9IeMrEB8AuIpS23URZ1CAjVxLlba0kdU4gv7mx9MOlZ B6aNm6V5mi+y2eIHDmqHdZgQUP1x5uERiA7RMYx+dteHhwRrtv22MqqpcnRt75iI5ppv hzfx7D1PYlljAHzl69i3VNcHUl3ns6/FgjxEyQAfAwJbEdgzHnM5aQxBBB0vDlUXld5U 5F2/xqpKEcrv1eQbuw3l8XXFXj9VivPP44xGpqCWKDSkPQywoCX46/7R81lGBlB47ZL7 EmYnbi7Bav7wcpq2eP2L/FRce70vzgoVbXoYtczYGxmtEkLMBcUWX0sntm4dIRtsyR8C ycgQ== X-Received: by 10.220.225.200 with SMTP id it8mr25084559vcb.39.1364422199334; Wed, 27 Mar 2013 15:09:59 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp135465ved; Wed, 27 Mar 2013 15:09:58 -0700 (PDT) X-Received: by 10.182.129.101 with SMTP id nv5mr3340103obb.56.1364422198607; Wed, 27 Mar 2013 15:09:58 -0700 (PDT) Received: from mail-ob0-x235.google.com (mail-ob0-x235.google.com [2607:f8b0:4003:c01::235]) by mx.google.com with ESMTPS id b2si17541695obn.124.2013.03.27.15.09.58 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 27 Mar 2013 15:09:58 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:4003:c01::235 is neither permitted nor denied by best guess record for domain of christophe.lyon@linaro.org) client-ip=2607:f8b0:4003:c01::235; Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:4003:c01::235 is neither permitted nor denied by best guess record for domain of christophe.lyon@linaro.org) smtp.mail=christophe.lyon@linaro.org Received: by mail-ob0-f181.google.com with SMTP id ni5so8764938obc.12 for ; Wed, 27 Mar 2013 15:09:58 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.60.30.131 with SMTP id s3mr16433987oeh.106.1364422197847; Wed, 27 Mar 2013 15:09:57 -0700 (PDT) Received: by 10.60.62.10 with HTTP; Wed, 27 Mar 2013 15:09:57 -0700 (PDT) Date: Wed, 27 Mar 2013 23:09:57 +0100 Message-ID: Subject: [Patch, ARM] Enable libsanitizer From: Christophe Lyon To: "gcc-patches@gcc.gnu.org" , Patch Tracking X-Gm-Message-State: ALoCoQkLrkx2Qhi6TJgDmkM4GnmWdeF2ecULsbg9jQhHzBXuyH3fhIwgJgReKcpAeDWVHMhnq7BQ Hi, This small patch enables libsanitizer on ARM. It has been tested successfully on cortex-a9 hardware (via the GCC testsuite). I have chosen to bundle -funwind-table with -fsanitize=* so that a useful backtrace can be printed to the user in case of error, otherwise the reporting is limited to one line belonging to libsanitizer.so. Note that the testsuite currently fails when executing under qemu: - support of /proc/self/maps does not conform to the kernel format. One extra space is missing from some lines, which confuses libsanitizer. Patch proposed to upstream qemu: http://lists.gnu.org/archive/html/qemu-devel/2013-02/msg03051.html - qemu reserves some memory space by default, conflicting with libsanitizer needs. Workaround: invoke qemu with -R 0 - libsanitizer detects if its output is a tty, and when GCC testsuite is executed under qemu, libsanitizer concludes that it is actually running under a tty, and adds beautyfying characters which confuse dejanu. OK? Christophe. 2013-03-27 Christophe Lyon gcc/ * config/arm/arm.c (arm_asan_shadow_offset): New function. (TARGET_ASAN_SHADOW_OFFSET): Define. * config/arm/linux-eabi.h (ASAN_CC1_SPEC): Define. (LINUX_OR_ANDROID_CC): Add ASAN_CC1_SPEC. libsanitizer/ * configure.tgt: Add ARM pattern. === modified file 'gcc/config/arm/arm.c' --- gcc/config/arm/arm.c 2013-02-28 10:26:41 +0000 +++ gcc/config/arm/arm.c 2013-03-04 08:39:02 +0000 @@ -280,6 +280,8 @@ static void arm_canonicalize_comparison (int *code, rtx *op0, rtx *op1, bool op0_preserve_value); +static unsigned HOST_WIDE_INT arm_asan_shadow_offset (void); + /* Table of machine attributes. */ static const struct attribute_spec arm_attribute_table[] = @@ -649,6 +651,9 @@ #define TARGET_CANONICALIZE_COMPARISON \ arm_canonicalize_comparison +#undef TARGET_ASAN_SHADOW_OFFSET +#define TARGET_ASAN_SHADOW_OFFSET arm_asan_shadow_offset + struct gcc_target targetm = TARGET_INITIALIZER; /* Obstack for minipool constant handling. */ @@ -27393,4 +27398,12 @@ } +/* Implement the TARGET_ASAN_SHADOW_OFFSET hook. */ + +static unsigned HOST_WIDE_INT +arm_asan_shadow_offset (void) +{ + return (unsigned HOST_WIDE_INT) 1 << 29; +} + #include "gt-arm.h" === modified file 'gcc/config/arm/linux-eabi.h' --- gcc/config/arm/linux-eabi.h 2013-01-10 20:38:27 +0000 +++ gcc/config/arm/linux-eabi.h 2013-03-26 09:59:11 +0000 @@ -84,10 +84,14 @@ LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \ LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC) +#undef ASAN_CC1_SPEC +#define ASAN_CC1_SPEC "%{fsanitize=*:-funwind-tables}" + #undef CC1_SPEC #define CC1_SPEC \ - LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \ - GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC) + LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC " " ASAN_CC1_SPEC, \ + GNU_USER_TARGET_CC1_SPEC " " ASAN_CC1_SPEC " " \ + ANDROID_CC1_SPEC) #define CC1PLUS_SPEC \ LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) === modified file 'libsanitizer/configure.tgt' --- libsanitizer/configure.tgt 2013-02-11 23:13:37 +0000 +++ libsanitizer/configure.tgt 2013-03-04 08:39:02 +0000 @@ -29,6 +29,8 @@ ;; sparc*-*-linux*) ;; + arm*-*-linux*) + ;; x86_64-*-darwin[1]* | i?86-*-darwin[1]*) TSAN_SUPPORTED=no ;;