From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12101 invoked by alias); 6 Jan 2012 10:27:17 -0000 Received: (qmail 12083 invoked by uid 22791); 6 Jan 2012 10:27:16 -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, 06 Jan 2012 10:27:01 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q06AQwq0029294 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 6 Jan 2012 05:26:58 -0500 Received: from [10.36.5.143] (vpn1-5-143.ams2.redhat.com [10.36.5.143]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q06AQuAk025803 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 6 Jan 2012 05:26:57 -0500 Message-ID: <4F06CC32.10102@redhat.com> Date: Fri, 06 Jan 2012 10:27:00 -0000 From: nick clifton User-Agent: Mozilla/5.0 (X11; Linux i686; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: "Kaushik, Praveen_Kumar" , gdb@sourceware.org CC: binutils@sourceware.org Subject: Re: Debuggin info for unused sections References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00015.txt.bz2 Hi Praveen, [I have added the GDB list as I now think that this issue affects them.] > While using -gc-sections to remove unused sections, the section is removed but the debug info in not removed. > > In, > > a.c: > int main() > { > return 0; > } > int fun () > { > return 0; > } > gcc -g3 -ffunction-sections -Wl,-gc-sections a.c > readelf -wl a.out > gives > > Line Number Statements: > Extended opcode 2: set Address to 0x4003f6 > Special opcode 6: advance Address by 0 to 0x4003f6 and Line by 1 to 2 > Special opcode 62: advance Address by 4 to 0x4003fa and Line by 1 to 3 > Special opcode 76: advance Address by 5 to 0x4003ff and Line by 1 to 4 > Advance PC by 2 to 0x400401 > Extended opcode 1: End of Sequence > > Extended opcode 2: set Address to 0x0 > Special opcode 11: advance Address by 0 to 0x0 and Line by 6 to 7 > Special opcode 62: advance Address by 4 to 0x4 and Line by 1 to 8 > Special opcode 76: advance Address by 5 to 0x9 and Line by 1 to 9 > Advance PC by 2 to 0xb > Extended opcode 1: End of Sequence Originally I had just thought that this was a missed opportunity for the linker to remove unneeded debug information. But then it occurred to me that leaving the bogus line number information in could cause problems for GDB. As in: % gdb -nw a.out GNU gdb (GDB) 7.4.50.20120106-cvs [...] (gdb) break a.c:6 Bus error (core dumped) So it seems that we really do need to remove it after all. I will look into it when I have the time. Cheers Nick