From patchwork Mon Nov 18 13:59:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 292101 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D4FC12C00B9 for ; Tue, 19 Nov 2013 01:01:08 +1100 (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:reply-to:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=soFyGwZLY72sYfJtb KjZe6uVVlRGvvysxoF2LOK2P7KYJId3o26niw4hhGwVjRUUqrOSedo+KxoRzENxm CNwZEukMmDvITHIzRoIeyIQXOR3OrkYtCaqiaOHILzOpRM87Zi7o7s3hFmSt4DCn 3W2eLSkCJiS+IGZBpnk3uSTtQ4= 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:reply-to:references:mime-version :content-type:in-reply-to; s=default; bh=bCtfbYO+oytS9vhKVoSBi5g Q70M=; b=Xc2uhLCZTHTHBXAKpTIvvJ1uY4ayyN8kcG8WBdZyKe/d4eEiZDW2UZo Rn5j6JipMay0P+/O8BM11zNdlgFeLiEGFRdE3j6hHnaGb3i+wtxpkNPLxW5ZeLNQ afcAt41XpBgGdfO0psg1RFl5Ej0nvzjWwfZiyFmLC0emM0aRUYGU= Received: (qmail 20565 invoked by alias); 18 Nov 2013 14:00:55 -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 20496 invoked by uid 89); 18 Nov 2013 14:00:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Nov 2013 13:59:28 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAIDxK6c016692 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 18 Nov 2013 08:59:20 -0500 Received: from tucnak.zalov.cz (vpn1-5-186.ams2.redhat.com [10.36.5.186]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rAIDxIFi001608 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 18 Nov 2013 08:59:19 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.7/8.14.7) with ESMTP id rAIDxHGj016054; Mon, 18 Nov 2013 14:59:17 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.7/8.14.7/Submit) id rAIDxHkl016053; Mon, 18 Nov 2013 14:59:17 +0100 Date: Mon, 18 Nov 2013 14:59:17 +0100 From: Jakub Jelinek To: Ian Lance Taylor Cc: Konstantin Serebryany , Dodji Seketeli , Marek Polacek , gcc-patches Subject: Re: [PATCH] Support -fsanitize=leak Message-ID: <20131118135917.GD892@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20131115194138.GQ892@tucnak.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On Fri, Nov 15, 2013 at 12:34:14PM -0800, Ian Lance Taylor wrote: > On Fri, Nov 15, 2013 at 11:41 AM, Jakub Jelinek wrote: > > > > This patch adds support for -fsanitize=leak and -static-liblsan options. > > If combined with -fsanitize=address, it does nothing, otherwise it links > > in liblsan, a new shared+static library (on x86_64-linux only so far, > > the code isn't 32-bit ready apparently). > > > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > Documentation? Here it is, as incremental patch: 2013-11-18 Jakub Jelinek * doc/invoke.texi (-static-liblsan, -fsanitize=leak): Document. Jakub --- gcc/doc/invoke.texi.jj 2013-11-18 09:59:09.000000000 +0100 +++ gcc/doc/invoke.texi 2013-11-18 14:57:12.240073775 +0100 @@ -454,7 +454,7 @@ Objective-C and Objective-C++ Dialects}. @gccoptlist{@var{object-file-name} -l@var{library} @gol -nostartfiles -nodefaultlibs -nostdlib -pie -rdynamic @gol -s -static -static-libgcc -static-libstdc++ @gol --static-libasan -static-libtsan -static-libubsan @gol +-static-libasan -static-libtsan -static-liblsan -static-libubsan @gol -shared -shared-libgcc -symbolic @gol -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol -u @var{symbol}} @@ -5259,6 +5259,13 @@ Memory access instructions will be instr data race bugs. See @uref{http://code.google.com/p/data-race-test/wiki/ThreadSanitizer} for more details. +@item -fsanitize=leak +Enable LeakSanitizer, a memory leak detector. +This option only matters for linking of executables and if neither +@option{-fsanitize=address} nor @option{-fsanitize=thread} is used. In that +case it will link the executable against a library that overrides @code{malloc} +and other allocator functions. + @item -fsanitize=undefined Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector Various computations will be instrumented to detect undefined behavior @@ -10181,6 +10188,15 @@ option is not used, then this links agai driver to link @file{libtsan} statically, without necessarily linking other libraries statically. +@item -static-liblsan +When the @option{-fsanitize=leak} option is used to link a program, +the GCC driver automatically links against @option{liblsan}. If +@file{liblsan} is available as a shared library, and the @option{-static} +option is not used, then this links against the shared version of +@file{liblsan}. The @option{-static-liblsan} option directs the GCC +driver to link @file{liblsan} statically, without necessarily linking +other libraries statically. + @item -static-libubsan When the @option{-fsanitize=undefined} option is used to link a program, the GCC driver automatically links against @option{libubsan}. If