From patchwork Sat Nov 17 20:00:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 199872 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 E17252C0092 for ; Sun, 18 Nov 2012 07:00:21 +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=1353787222; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Subject:Message-ID: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=PlnKmFdXBBltZvSFg1rXgbGxj9M=; b=q4R9lwcy0f28Ef2Ayt7I8HyEDMOZfrGoBPx8uhPBZonXec5XXCMDzc6uxXuigi fUlls/CC2O7LbUffSWtZDK5+ytFegDKR0k0C7wEbpE80XtJudjaQ0plFb3XdboGj nZmD8dPwauUGXaSk6lBJMcrj0dCYF2t0kCfmRsJuA+Fp4= 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:Subject:Message-ID: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=i18tCAOi+37Js9Ul6h6n65Gp24VEnjCFjKh0dpDyRBMBGjHpisoX2N2L+qSb1t adoAMXGRxBiORv0EVpubtaVSGIraMzC35EAWH+S2yEJRGXGIrcIvBsyN/n02L7v+ PRrPQ1X5l7lqRX/N1ppCIFZHk1/QfZBe6+Q8b8q2L0Xxg=; Received: (qmail 2328 invoked by alias); 17 Nov 2012 20:00:10 -0000 Received: (qmail 2278 invoked by uid 22791); 17 Nov 2012 20:00:09 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-ie0-f175.google.com (HELO mail-ie0-f175.google.com) (209.85.223.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 17 Nov 2012 20:00:03 +0000 Received: by mail-ie0-f175.google.com with SMTP id c13so5447607ieb.20 for ; Sat, 17 Nov 2012 12:00:03 -0800 (PST) Received: by 10.50.41.165 with SMTP id g5mr2577158igl.66.1353182403284; Sat, 17 Nov 2012 12:00:03 -0800 (PST) Received: from gnu-tools-1.localdomain (76-220-57-190.lightspeed.sntcca.sbcglobal.net. [76.220.57.190]) by mx.google.com with ESMTPS id gs6sm3541475igc.11.2012.11.17.12.00.02 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 17 Nov 2012 12:00:02 -0800 (PST) Received: by gnu-tools-1.localdomain (Postfix, from userid 1000) id B56741A0629; Sat, 17 Nov 2012 12:00:00 -0800 (PST) Date: Sat, 17 Nov 2012 12:00:00 -0800 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Subject: PATCH: Add -static-libasan to the GCC driver Message-ID: <20121117200000.GA1016@gmail.com> 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, This patch adds -static-libasan. OK to install? Thanks. H.J. --- 2012-11-17 H.J. Lu * common.opt (static-libasan): New option. * gcc.c (LIBASAN_SPEC): New macro. (LINK_COMMAND_SPEC): Replace -lasan with LIBASAN_SPEC. * doc/invoke.texi: Document -static-libasan. diff --git a/gcc/common.opt b/gcc/common.opt index 0a7c953..be6fe4f 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2516,6 +2516,9 @@ static-libgo Driver ; Documented for Go, but always accepted by driver. +static-libasan +Driver + symbolic Driver diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index b3abc09..885bf66 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -452,8 +452,8 @@ Objective-C and Objective-C++ Dialects}. @xref{Link Options,,Options for Linking}. @gccoptlist{@var{object-file-name} -l@var{library} @gol -nostartfiles -nodefaultlibs -nostdlib -pie -rdynamic @gol --s -static -static-libgcc -static-libstdc++ -shared @gol --shared-libgcc -symbolic @gol +-s -static -static-libgcc -static-libasan -static-libstdc++ @gol +-shared -shared-libgcc -symbolic @gol -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol -u @var{symbol}} @@ -9937,6 +9937,15 @@ for the languages used in the program, or using the option @option{-shared-libgcc}, such that it is linked with the shared @file{libgcc}. +@item -static-libasan +When the @option{-faddress-sanitizer} option is used to link a program, +the GCC driver automatically links against @option{libasan}. If +@file{libasan} is available as a shared library, and the @option{-static} +option is not used, then this links against the shared version of +@file{libasan}. The @option{-static-libasan} option directs the GCC +driver to link @file{libasan} statically, without necessarily linking +other libraries statically. + @item -static-libstdc++ When the @command{g++} program is used to link a C++ program, it normally automatically links against @option{libstdc++}. If diff --git a/gcc/gcc.c b/gcc/gcc.c index e584319..7a275e1 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -544,6 +544,15 @@ proper position among the other output files. */ wrapping. */ #define STACK_SPLIT_SPEC " %{fsplit-stack: --wrap=pthread_create}" +#ifndef LIBASAN_SPEC +#ifdef HAVE_LD_STATIC_DYNAMIC +#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION \ + "} -lasan %{static-libasan:" LD_DYNAMIC_OPTION "}" +#else +#define LIBASAN_SPEC "-lasan" +#endif +#endif + /* config.h can define LIBGCC_SPEC to override how and when libgcc.a is included. */ #ifndef LIBGCC_SPEC @@ -687,7 +696,7 @@ proper position among the other output files. */ %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\ %(mflib) " STACK_SPLIT_SPEC "\ %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\ - %{faddress-sanitizer:-lasan}\ + %{faddress-sanitizer:" LIBASAN_SPEC "}\ %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\ %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}" #endif