From patchwork Sat Apr 5 17:36:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 337216 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0032214009C for ; Sun, 6 Apr 2014 03:36:49 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=uC4hAD8XkfO2rxvls cFdugEAqhlIaU0ZKRPxj11R0cNzmMKYA0HTahY1YuNYvWI8vJw76OhtTekwLNLZk psdK0xlvUK1cTjF8qgvtgEGUlu+R3k4ItoUAuPpFL35fwqQ+/XLl4ElZg/7TW6/y 6l7o6ItT56lxSHBaeqgsO4kgs4= 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 :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=B1qxuCX59EaUo8kaMlWhY77 MKVk=; b=EH9B4zgpM4+MbZffVJ3aBwoXmWw3bY15zEGzoYG0J2Q4iTVwdw5+qu+ Mk8jR7pLoNi1wQzqlz9qTpuMFUuzpNv7L2vN2vM7yNTg9RmirJNU4PVzRdVCHR8q 1HBm7eUqLl5rNN4HS0MvKcYhmuMUw1x41r9My9xrws23WRfU3Unk= Received: (qmail 20581 invoked by alias); 5 Apr 2014 17:36:42 -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 20564 invoked by uid 89); 5 Apr 2014 17:36:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 05 Apr 2014 17:36:40 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s35HacS1015778 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 5 Apr 2014 13:36:38 -0400 Received: from redhat.com (ovpn-116-95.ams2.redhat.com [10.36.116.95]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s35HaYYd000664 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Sat, 5 Apr 2014 13:36:37 -0400 Date: Sat, 5 Apr 2014 19:36:34 +0200 From: Marek Polacek To: Jeff Law Cc: Jonathan Wakely , GCC Patches , Jakub Jelinek Subject: Re: [PATCH] Initialize sanitizer builtins (PR sanitizer/60745) Message-ID: <20140405173634.GJ24603@redhat.com> References: <20140403165630.GE24603@redhat.com> <533ECD26.2000504@redhat.com> <20140404154848.GT13192@redhat.com> <20140404171427.GG24603@redhat.com> <533EF0CC.2020904@redhat.com> <20140404194552.GH24603@redhat.com> <533F1BCC.5070408@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <533F1BCC.5070408@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) On Fri, Apr 04, 2014 at 02:53:32PM -0600, Jeff Law wrote: > Presumably when we wrote out the PCH -fsanitize wasn't being used > and thus those builtins are not initialized. Right? Right. I put a local hack into c_common_write_pch and that said: wrote x86_64-unknown-linux-gnu/bits/stdc++.h.gch/O2g.gch, sanitize flag: 0 so builtins weren't initialized (see #define DEF_SANITIZER_BUILTIN for why). O2g.gch is the file that is then read by c_common_read_pch. > Assuming that's correct, your patch is fine with a comment to that effect. Thanks. I'll wait a day or two for possible comments. 2014-04-05 Marek Polacek PR sanitizer/60745 * c-ubsan.c: Include asan.h. (ubsan_instrument_return): Call initialize_sanitizer_builtins. Marek diff --git gcc/c-family/c-ubsan.c gcc/c-family/c-ubsan.c index dc4d981..e89ebc1 100644 --- gcc/c-family/c-ubsan.c +++ gcc/c-family/c-ubsan.c @@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see #include "ubsan.h" #include "c-family/c-common.h" #include "c-family/c-ubsan.h" +#include "asan.h" /* Instrument division by zero and INT_MIN / -1. If not instrumenting, return NULL_TREE. */ @@ -185,6 +186,10 @@ ubsan_instrument_vla (location_t loc, tree size) tree ubsan_instrument_return (location_t loc) { + /* It is possible that PCH zapped table with definitions of sanitizer + builtins. Reinitialize them if needed. */ + initialize_sanitizer_builtins (); + tree data = ubsan_create_data ("__ubsan_missing_return_data", &loc, NULL, NULL_TREE); tree t = builtin_decl_explicit (BUILT_IN_UBSAN_HANDLE_MISSING_RETURN);