From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22255 invoked by alias); 18 Apr 2012 23:40:55 -0000 Received: (qmail 22181 invoked by uid 22791); 18 Apr 2012 23:40:53 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-lpp01m010-f47.google.com (HELO mail-lpp01m010-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 18 Apr 2012 23:40:39 +0000 Received: by lagw12 with SMTP id w12so6195726lag.20 for ; Wed, 18 Apr 2012 16:40:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding:x-system-of-record :x-gm-message-state; bh=QkMjyuQbNLmLH224eas37n1oRC4DyNteJLqWAzCgEaQ=; b=IhIjFKIfDws3Yuy9QDzuYa08lXfNUJp877FaUD5CeExczwzj6Fb352+MMOR0bsDXF5 mVM4WnB9R6imfUfC98w/lfe3FRzt9hF1yBOWreEZ14tuWGTbYQ7IOgUT0NBm6x/159ix 35N9hmzBUoqpGXqWo5kIrGGTlnHQG416MWdBBeC6/IF7u1dKAPemAN3XCIYVttok1J19 +5RS6wxBjRr52l863hXp2fqD74crX0sz7XduaqUzPUCEi/5J7LyhnomJsPfaSpbTnKG4 GjBijircD8FKQetRI3TufXcUUcOlYnpgRF8fGvk3xkFPTfGZQtVANosUGSKkA3Gdj+D8 kljg== Received: by 10.152.104.43 with SMTP id gb11mr3917168lab.8.1334792437931; Wed, 18 Apr 2012 16:40:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.152.104.43 with SMTP id gb11mr3917150lab.8.1334792437826; Wed, 18 Apr 2012 16:40:37 -0700 (PDT) Received: by 10.112.22.68 with HTTP; Wed, 18 Apr 2012 16:40:37 -0700 (PDT) In-Reply-To: <4F8EB6F9.9080008@redhat.com> References: <20120418111640.GE16117@tyan-ft48-01.lab.bos.redhat.com> <20120418115314.GO6148@sunsite.ms.mff.cuni.cz> <4F8EB6F9.9080008@redhat.com> Date: Wed, 18 Apr 2012 23:40:00 -0000 Message-ID: Subject: Re: Debug info for comdat functions From: Cary Coutant To: Jason Merrill Cc: Jakub Jelinek , gcc@gcc.gnu.org, binutils@sourceware.org, Roland McGrath , Tom Tromey , Mark Wielaard , Nick Clifton , Alan Modra Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-Gm-Message-State: ALoCoQnIrdIG8UJOdkF6+t6xWiJKOpJeghk7tDaktSZMD8q75PTkI0+/UpIw76A3JWa0N6F9ZI4KkWv63AVgnmfhOk2JxE7BEq4giGt7iz585mRc9CFnJd5gV62FrGE0qWr7GrepeXoy X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2012-04/txt/msg00704.txt.bz2 > This seems clearly wrong to me. =A0A reference to a symbol in a discarded > section should not resolve to an offset into a different section. =A0I th= ought > the linker always resolved such references to 0, and I think that is what= we > want. Even resolving to 0 can cause problems. In the Gnu linker, all references to a discarded symbol get relocated to 0, ignoring any addend. This can result in spurious (0,0) pairs in range lists. In Gold, we treat the discarded symbol as 0, but still apply the addend, and count on GDB to recognize that the function starting at 0 must have been discarded. Neither solution is ideal. That's why debug info for COMDAT functions ought to be in the same COMDAT group as the function... >> When discussed on IRC recently Jason preferred to move the >> DW_TAG_subprogram >> describing a comdat function to a comdat .debug_info DW_TAG_partial_unit >> and just reference all DIEs that need to be referenced from it >> using DW_FORM_ref_addr back to the non-comdat .debug_info. > > I played around with implementing this in the compiler yesterday; my init= ial > patch is attached. =A0It seems that with normal DWARF 4 this can work wel= l, > but I ran into issues with various GNU extensions: Nice -- I've been wanting to do that for a while, but I always thought it would be a lot harder. I see that you've based this on the infrastructure created for -feliminate-dwarf2-dups. I don't think that will play nice with -fdebug-types-section, though, since I basically made those two options incompatible with each other by unioning die_symbol with die_type_node. In the HP-UX compilers, we basically put a complete set of .debug_* sections in each COMDAT group, and treated the group as a compilation unit of its own (not a partial unit). That worked well, and avoided some of the problems you're running into (although clearly is more wasteful in terms of object file size). Readelf and friends will need to be taught how to find the right auxiliary debug sections, though -- they currently have a built-in assumption that there's only one of each. -cary