From patchwork Wed Dec 5 11:39:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 203857 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 528582C00A8 for ; Wed, 5 Dec 2012 22:39:26 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1355312366; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=WrCL+gfOiLxkNnpl7FwZ JSGYLM0=; b=TA7EQxtEjY3YZzZBG3cVVanUmnbVSUBz17pstdR1bgO69stAZ84H kqM1u5dp8GGaf1yoU4X/1JcEwY9ZAQkjO5FwYLYSHjhp45snWSenCPryw9IRYVf4 iqh1hPTYqK264syqeGLuOe8Rd+k0+79g0SchNizHf6A+t0voX3C2Q7c= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=GAN1sIo0FjX9NqVvyTHeW/jEveKQlMginoO/Qa9m9vsdffMyEU8yGvfcicgG3k kf+/NcGlecKPyztpc9Zcj9lPP1OOhZMEo3JeFLKStCZvNccrYKboVII+7zk6Cs2b j1cTJ1j2t4Er5GWyhUr/MQktqjM7MImycsd7Dd26yEfUI=; Received: (qmail 9761 invoked by alias); 5 Dec 2012 11:39:22 -0000 Received: (qmail 9750 invoked by uid 22791); 5 Dec 2012 11:39:21 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Dec 2012 11:39:08 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qB5Bd8sD028742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 5 Dec 2012 06:39:08 -0500 Received: from zalov.redhat.com (vpn1-5-46.ams2.redhat.com [10.36.5.46]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qB5Bd6CF005401 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 5 Dec 2012 06:39:08 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id qB5Bd6uq013027; Wed, 5 Dec 2012 12:39:06 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id qB5Bd591013026; Wed, 5 Dec 2012 12:39:05 +0100 Date: Wed, 5 Dec 2012 12:39:05 +0100 From: Jakub Jelinek To: Richard Biener , Dodji Seketeli , Konstantin Serebryany Cc: gcc-patches@gcc.gnu.org Subject: [asan] Disallow crossjumping of __asan_report_* builtins Message-ID: <20121205113905.GN2315@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! Another problem from the compiler side when working on the asan testsuite is that at higher -O* levels the __asan_report_* noreturn calls are cross-jumped, but the library relies on their locus to print accurrate locations when symbolized. Without it, asan might report an error completely elsewhere in a function. This patch disables cross-jumping of such builtins. Alternatively, I could introduce some attribute (no_cross_jump?), ECF_NO_CROSS_JUMP, add those attributes to those builtins (and let users add those too to functions they wish), and look at ECF_NO_CROSS_JUMP instead during cross-jumping. 2012-12-05 Jakub Jelinek * sanitizer.def: Add comment about importance of ordering of BUILT_IN_ASAN_REPORT* builtins. * cfgcleanup.c (old_insns_match_p): Don't cross-jump __asan_report_* builtins. Jakub --- gcc/sanitizer.def.jj 2012-12-04 14:19:36.000000000 +0100 +++ gcc/sanitizer.def 2012-12-05 09:38:01.205958515 +0100 @@ -29,6 +29,8 @@ along with GCC; see the file COPYING3. /* Address Sanitizer */ DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_INIT, "__asan_init", BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST) +/* Do not reorder the BUILT_IN_ASAN_REPORT* builtins, e.g. cfgcleanup.c + relies on this order. */ DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_LOAD1, "__asan_report_load1", BT_FN_VOID_PTR, ATTR_NORETURN_NOTHROW_LEAF_LIST) DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REPORT_LOAD2, "__asan_report_load2", --- gcc/cfgcleanup.c.jj 2012-11-20 09:37:47.000000000 +0100 +++ gcc/cfgcleanup.c 2012-12-05 09:37:23.389181984 +0100 @@ -1138,6 +1138,28 @@ old_insns_match_p (int mode ATTRIBUTE_UN CALL_INSN_FUNCTION_USAGE (i2)) || SIBLING_CALL_P (i1) != SIBLING_CALL_P (i2)) return dir_none; + + /* For address sanitizer, never crossjump __asan_report_* builtins, + otherwise errors might be reported on incorrect lines. */ + if (flag_asan) + { + rtx call = get_call_rtx_from (i1); + if (call && GET_CODE (XEXP (XEXP (call, 0), 0)) == SYMBOL_REF) + { + rtx symbol = XEXP (XEXP (call, 0), 0); + if (SYMBOL_REF_DECL (symbol) + && TREE_CODE (SYMBOL_REF_DECL (symbol)) == FUNCTION_DECL) + { + if ((DECL_BUILT_IN_CLASS (SYMBOL_REF_DECL (symbol)) + == BUILT_IN_NORMAL) + && DECL_FUNCTION_CODE (SYMBOL_REF_DECL (symbol)) + >= BUILT_IN_ASAN_REPORT_LOAD1 + && DECL_FUNCTION_CODE (SYMBOL_REF_DECL (symbol)) + <= BUILT_IN_ASAN_REPORT_STORE16) + return dir_none; + } + } + } } #ifdef STACK_REGS