From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15342 invoked by alias); 15 Nov 2004 19:27:30 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 15266 invoked from network); 15 Nov 2004 19:27:16 -0000 Received: from unknown (HELO mailapp.tensilica.com) (65.205.227.29) by sourceware.org with SMTP; 15 Nov 2004 19:27:16 -0000 Received: from localhost ([127.0.0.1] ident=amavis) by mailapp.tensilica.com with esmtp (Exim 4.34) id 1CTmVO-0006sq-LR for binutils@sources.redhat.com; Mon, 15 Nov 2004 11:27:14 -0800 Received: from mailapp.tensilica.com ([127.0.0.1]) by localhost (mailapp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26408-02 for ; Mon, 15 Nov 2004 11:27:14 -0800 (PST) Received: from egret.hq.tensilica.com ([192.168.11.80] ident=[3jbQ6ltUgrkSi3vF9nZ9H1DZjDh3ZJVR]) by mailapp.tensilica.com with esmtp (Exim 4.34) id 1CTmVO-0006sj-C7 for binutils@sources.redhat.com; Mon, 15 Nov 2004 11:27:14 -0800 Received: from tensilica.com (IDENT:r15gZZogUMiiFIhe9zOyOWMoZjtMmybK@egret.hq.tensilica.com [192.168.11.80]) by egret.hq.tensilica.com (8.11.6/8.11.6) with ESMTP id iAFJRDw22540 for ; Mon, 15 Nov 2004 11:27:14 -0800 Message-ID: <41990311.3060504@tensilica.com> Date: Mon, 15 Nov 2004 19:27:00 -0000 From: Bob Wilson Organization: Tensilica, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 MIME-Version: 1.0 To: binutils@sources.redhat.com Subject: [PATCH] inconsistent DWARF2 sections generated by --gdwarf2 Content-Type: multipart/mixed; boundary="------------010808070506000805070408" X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at hq.tensilica.com X-SW-Source: 2004-11/txt/msg00225.txt.bz2 This is a multi-part message in MIME format. --------------010808070506000805070408 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1889 The code for dwarf2_finish() in gas/dwarf2dbg.c appears to be inconsistent. If you assemble a file that contains no instructions, e.g., just a symbol declaration: ".global some_symbol", with --gdwarf2, GAS will create a .debug_line section but no corresponding .debug_info section. This is probably harmless for GDB, but it breaks readelf, which expects a one-to-one correspondence between .debug_info and .debug_line sections. Running "readelf -wl" on such a file results in the following error message: readelf: Error: Not enough comp units for .debug_lines section It looks like the problem was introduced by the following change: 2002-08-01 H.J. Lu Daniel Jacobowitz * dwarf2dbg.c (dwarf2_finish): Don't emit unreferenced .debug_line section unless it has line information. I read through the discussions surrounding that patch to try to understand the issues involved, but I'm not sure if I succeeded. I _think_ this patch is correct -- assuming the .debug_info section is needed, it must either be provided in the input or generated later in dwarf2_finish. In the latter case, the test to "do nothing" should be consistent with the test to generate .debug_info, etc. An alternative would be changing GAS to write out a .debug_info section even when no line numbers are specified, but the following comment in out_debug_info() suggests that might not work: "We're not supposed to get called unless at least one line number entry was emitted...." I'll be happy to commit this if someone will confirm that it is the right thing to do and approve the patch. It doesn't cause any gas testsuite regressions for an xtensa-elf target. --Bob gas ChangeLog 2004-11-15 Bob Wilson * dwarf2dbg.c (dwarf2_finish): Don't write a .debug_line section without a corresponding .debug_info section. --------------010808070506000805070408 Content-Type: text/plain; name="dwarf2dbg.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="dwarf2dbg.patch" Content-length: 944 Index: dwarf2dbg.c =================================================================== RCS file: /cvs/src/src/gas/dwarf2dbg.c,v retrieving revision 1.71 diff -u -p -r1.71 dwarf2dbg.c --- dwarf2dbg.c 2 Nov 2004 09:49:25 -0000 1.71 +++ dwarf2dbg.c 15 Nov 2004 18:53:45 -0000 @@ -1356,13 +1356,12 @@ dwarf2_finish (void) struct line_seg *s; /* We don't need to do anything unless: - - Some debug information was recorded via .file/.loc - - or, we are generating DWARF2 information ourself (--gdwarf2) + - Some debug information was recorded via .file/.loc or + generated by GAS (--gdwarf2) - or, there is a user-provided .debug_info section which could reference the file table in the .debug_line section we generate below. */ if (all_segs == NULL - && debug_type != DEBUG_DWARF2 && (bfd_get_section_by_name (stdoutput, ".debug_info") == NULL || files_in_use == 0)) return; --------------010808070506000805070408--