From patchwork Fri Mar 18 13:55:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 87535 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 05012B6FE3 for ; Sat, 19 Mar 2011 00:56:27 +1100 (EST) Received: (qmail 30556 invoked by alias); 18 Mar 2011 13:56:23 -0000 Received: (qmail 30544 invoked by uid 22791); 18 Mar 2011 13:56:21 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Mar 2011 13:56:13 +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 p2IDtojN011344 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 18 Mar 2011 09:55:50 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2IDtn3t011125 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 18 Mar 2011 09:55:49 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p2IDtm2H025411; Fri, 18 Mar 2011 14:55:48 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p2IDtloc025409; Fri, 18 Mar 2011 14:55:47 +0100 Date: Fri, 18 Mar 2011 14:55:47 +0100 From: Jakub Jelinek To: Richard Henderson , Jason Merrill Cc: gcc-patches@gcc.gnu.org, Eric Botcazou Subject: [PATCH] Emit .debug_aranges when needed (PR debug/48176) Message-ID: <20110318135547.GB30899@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek 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! Eric changed dwarf2out_finish in January to fix PR46704, unfortunately that change means we often don't emit .debug_aranges at all even when it should be present and is needed for e.g. elfutils. In PR46704 there were 2 DECL_IGNORED functions with -O2 -g -fkeep-inline-functions, so fde_table_in_use was 2, but .debug_info section wasn't emitted as it was empty and thus .debug_aranges referenced non-existent .Ldebug_info0 symbol. arange_table_in_use is often 0, in particular if all emitted functions are only in .text/.text.unlikely sections. .debug_aranges contains first range of .text the current CU covers, then range of .text.unlikely and only afterwards the other ranges (arange_table_in_use is count of those). The following patch fixes it by emitting .debug_aranges whenever it will be non-empty (and the extra && info_section_emitted is just to make sure .Ldebug_info0 can be used too). If you want, for 4.7+ I think we could just use if (text_section_used || cold_text_section_used || arange_table_in_use) { gcc_assert (info_section_emitted); ... Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.6? 2011-03-18 Jakub Jelinek PR debug/48176 * dwarf2out.c (dwarf2out_finish): Call output_aranges even when arange_table_in_use is 0, but either text_section_used or cold_text_section_used is true. Don't call it if !info_section_emitted. Jakub --- gcc/dwarf2out.c.jj 2011-03-17 21:34:34.000000000 +0100 +++ gcc/dwarf2out.c 2011-03-18 10:50:33.303546024 +0100 @@ -23667,7 +23667,8 @@ dwarf2out_finish (const char *filename) /* Output the address range information. We only put functions in the arange table, so don't write it out if we don't have any. */ - if (arange_table_in_use) + if ((text_section_used || cold_text_section_used || arange_table_in_use) + && info_section_emitted) { switch_to_section (debug_aranges_section); output_aranges ();