From patchwork Sat Aug 23 14:33:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 382433 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 B46E61400A3 for ; Sun, 24 Aug 2014 00:33:21 +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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=YYuTWFK5n0MEgtUTib1sB1xzPE0KVeJeO2cXp/2gaRDo2A 1mUJcfmUFFu3JHSCyuJBoZcm0XdpHvnZKtF3JWOcozxwe0OalmhilGfLf+cmItRc BhscZsYJ++AF70HN5pro9oxwugW2PVFcD0f6LyqJ5aR3vOG+WajBy0GGAGNOU= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=pv1psf9yNc1ZjsTft1fSVOk24RY=; b=xDvN/XWAMlzAGy4t5AXg m2Re4L/Vw8f/W89g9vfI62gY8ykF+yd3IZmNQZcyEKAW9LDFacOGuEWApC2ocNVt 3MUQM/qKAoRYp2N1ml9btj0N6mhmPebIqMVr7N2txNBiXjcQ5z+BCm7xkwwLcM4w g+81DtV1rty9mf316bRJ5cw= Received: (qmail 9579 invoked by alias); 23 Aug 2014 14:33:13 -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 9568 invoked by uid 89); 23 Aug 2014 14:33:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-we0-f179.google.com Received: from mail-we0-f179.google.com (HELO mail-we0-f179.google.com) (74.125.82.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 23 Aug 2014 14:33:09 +0000 Received: by mail-we0-f179.google.com with SMTP id u57so11757275wes.10 for ; Sat, 23 Aug 2014 07:33:06 -0700 (PDT) X-Received: by 10.180.85.136 with SMTP id h8mr4330123wiz.67.1408804386624; Sat, 23 Aug 2014 07:33:06 -0700 (PDT) Received: from [192.168.44.112] ([94.15.230.197]) by mx.google.com with ESMTPSA id xn12sm9859299wib.13.2014.08.23.07.33.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 23 Aug 2014 07:33:05 -0700 (PDT) Message-ID: <53F8A620.9080300@acm.org> Date: Sat, 23 Aug 2014 15:33:04 +0100 From: Nathan Sidwell User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 To: GCC Patches , Jan Hubicka Subject: fix gfcov regression X-IsSubscribed: yes Hi, this patch fixes a defect Jan found with firefox and its shared objects. We were inadvertently calling an externally visible and overridable symbol, rather than the local shared object's instance. This led to strangely sparse gcov results. I've taken the STRONG_ALIAS #define from glibc. I'm not 100% sure it's valid for all supported targets. Tested in x86_64-linux I've not committed this patch because of that, and (b) I'm about to emmigrate, so likely to be unable to respond to any potential fallout in a timely manner. Jan, if you think this patch is sufficiently safe, please apply. nathan 2014-08-22 Nathan sidwell * libgcov-interface.c (STRONG_ALIAS): New. (__gcov_flush): Call __gcov_reset_int. (__gcov_reset): Strong alias for ... (__gcov_reset_ing): ... this renamed hidden version. * libgcov.h (__gcov_reset_int): New declaration. Index: libgcc/libgcov-interface.c =================================================================== --- libgcc/libgcov-interface.c (revision 214320) +++ libgcc/libgcov-interface.c (working copy) @@ -42,6 +42,12 @@ void __gcov_dump (void) {} #else + +/* Some functions we want to bind in this dynamic object, but have an + overridable global alias. */ +#define STRONG_ALIAS(src,dst) \ + extern __typeof (src) dst __attribute__((alias (#src))) + extern __gthread_mutex_t __gcov_flush_mx ATTRIBUTE_HIDDEN; extern __gthread_mutex_t __gcov_flush_mx ATTRIBUTE_HIDDEN; @@ -77,7 +83,7 @@ __gcov_flush (void) __gthread_mutex_lock (&__gcov_flush_mx); __gcov_dump_one (&__gcov_root); - __gcov_reset (); + __gcov_reset_int (); __gthread_mutex_unlock (&__gcov_flush_mx); } @@ -121,12 +127,14 @@ gcov_clear (const struct gcov_info *list in order to collect profile in region of interest. */ void -__gcov_reset (void) +__gcov_reset_int (void) { gcov_clear (__gcov_root.list); __gcov_root.dumped = 0; } +STRONG_ALIAS (__gcov_reset_int, __gcov_reset); + #endif /* L_gcov_reset */ #ifdef L_gcov_dump Index: libgcc/libgcov.h =================================================================== --- libgcc/libgcov.h (revision 214320) +++ libgcc/libgcov.h (working copy) @@ -225,8 +225,10 @@ extern void __gcov_init (struct gcov_inf /* Called before fork, to avoid double counting. */ extern void __gcov_flush (void) ATTRIBUTE_HIDDEN; -/* Function to reset all counters to 0. */ +/* Function to reset all counters to 0. Both externally visible (and + overridable) and internal version. */ extern void __gcov_reset (void); +extern void __gcov_reset_int (void) ATTRIBUTE_HIDDEN; /* Function to enable early write of profile information so far. */ extern void __gcov_dump (void);