From patchwork Fri Feb 22 22:42:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 222690 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 8BB122C02A5 for ; Sat, 23 Feb 2013 09:43:14 +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=1362177796; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:In-Reply-To:References:Date:Message-ID: Subject:From:To:Cc:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=1STY+iKlluqOe3+0foc3D3CjdGg=; b=ezdi3efwRPjmyFr X9a0Aqm8vNfucTnChnU7a+qv6Y1fsvyQCM4qThX3+/WkD32dHPl5R7FlGnchpPgy sFGtGLgNeZyPYg2FB6qXBxsXfzdJWSyU+RO5E9LG6KN6wJXjUqlFQWJMQ0CKT7Ff Mg48h3nNxgh80xyn/YFLsz+hRqXE= 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:MIME-Version:X-Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Sqt5Skt51RvndLDIpfzJdFMbWYuLW49L8RKmgvVVWqxMXsGMdgfm/iGXN3z2XT rH+94mwLtvEmCAD1ql1zHkAckoa1MflTyidSKdAfp1AA0R3xk7jM2nim0RVuIZx0 rMR4RFZj4Um/u5pt0V5xXPT/MVG4skrcVoA0Exu7czkns=; Received: (qmail 24959 invoked by alias); 22 Feb 2013 22:42:56 -0000 Received: (qmail 24868 invoked by uid 22791); 22 Feb 2013 22:42:55 -0000 X-SWARE-Spam-Status: No, hits=-3.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-oa0-f43.google.com (HELO mail-oa0-f43.google.com) (209.85.219.43) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 22 Feb 2013 22:42:44 +0000 Received: by mail-oa0-f43.google.com with SMTP id l10so1095669oag.30 for ; Fri, 22 Feb 2013 14:42:44 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.182.88.103 with SMTP id bf7mr1501727obb.7.1361572964087; Fri, 22 Feb 2013 14:42:44 -0800 (PST) Received: by 10.76.11.106 with HTTP; Fri, 22 Feb 2013 14:42:44 -0800 (PST) In-Reply-To: <20130222125809.GK1215@tucnak.zalov.cz> References: <20130221105711.23596.qmail@sourceware.org> <20130221132136.GZ1215@tucnak.zalov.cz> <20130222125809.GK1215@tucnak.zalov.cz> Date: Fri, 22 Feb 2013 14:42:44 -0800 Message-ID: Subject: Re: r196201 - in /trunk: gcc/ChangeLog gcc/config/i... From: "H.J. Lu" To: Jakub Jelinek Cc: Konstantin Serebryany , "Zamyatin, Igor" , GCC Patches , Dodji Seketeli , Dmitry Vyukov 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 On Fri, Feb 22, 2013 at 4:58 AM, Jakub Jelinek wrote: > On Fri, Feb 22, 2013 at 11:53:39AM +0400, Konstantin Serebryany wrote: >> Jakub, thanks again for cleaning up my mess. >> >> Here is a question regarding your fix: >> > -#if ASAN_USE_PREINIT_ARRAY >> > +#if ASAN_USE_PREINIT_ARRAY && !defined (PIC) >> >> The PIC macro is an artifact of the GCC build system and is not >> directly related the the -fPIC flag? >> As I can see, in the gcc build we compile all of asan sources twice: >> w/ and w/o "-fPIC -DPIC". >> If I move the preinit_array to a separate file (asan_preinit.cc), will >> we need to have two builds? >> I think we can just build all objects once with -fPIC and then not >> link asan_preinit.o into libasan.so >> In clang we build the static libasan with -fPIC, it doesn't hurt. >> Anyway, I've just committed >> http://llvm.org/viewvc/llvm-project?rev=175871&view=rev with >> asan_preinit.cc > > Here is corresponding gcc patch to use it. > libasan_preinit.o is installed alongside with libasan.a and libasan.so*, > and linked into executables (but not shared libraries). > > Additionally, I've added __attribute__((constructor)) to __asan_init, > to make it more likely that asan will be initialized properly even when > the executable isn't instrumented. Shared libraries linked with > -fsanitize=address will depend on libasan.so.0, and the dynamic linker first > runs constructors of dependencies before running constructors of the > libraries that have those dependencies (unless there are dependency cycles, but that > is a user bug). > > 2013-02-22 Jakub Jelinek > > PR sanitizer/56393 > * config/gnu-user.h (LIBASAN_EARLY_SPEC): Link in libasan_preinit.o > if not linking a shared library. > > * lib/asan-dg.exp (asan_link_flags): Add > -B${gccpath}/libsanitizer/asan/ to flags. > > * asan/Makefile.am (nodist_toolexeclib_HEADERS): Set to > libasan_preinit.o. > (libasan_preinit.o): Depend on asan_preinit.o. > * asan/Makefile.in: Regenerated. > * asan/asan_preinit.cc: New file, synced from upstream. > * asan/asan_rtl.cc: Remove preinit stuff, synced from upstream. > Add __attribute__((constructor)) to __asan_init. > We also need this patch. OK to install? Thanks. H.J. --- 2013-02-22 H.J. Lu * bootstrap-asan.mk (POSTSTAGE1_LDFLAGS): Add -B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/asan/. diff --git a/config/bootstrap-asan.mk b/config/bootstrap-asan.mk index d37a9da..e3f34f5 100644 --- a/config/bootstrap-asan.mk +++ b/config/bootstrap-asan.mk @@ -3,4 +3,5 @@ STAGE2_CFLAGS += -fsanitize=address STAGE3_CFLAGS += -fsanitize=address POSTSTAGE1_LDFLAGS += -fsanitize=address -static-libasan \ + -B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/asan/ \ -B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/asan/.libs