public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: nick clifton <nickc@redhat.com>
To: "Kaushik, Praveen_Kumar" <Praveen_Kumar.Kaushi@atmel.com>,
	       gdb@sourceware.org
Cc: binutils@sourceware.org
Subject: Re: Debuggin info for unused sections
Date: Fri, 06 Jan 2012 10:27:00 -0000	[thread overview]
Message-ID: <4F06CC32.10102@redhat.com> (raw)
In-Reply-To: <DB7B9DAED0B660469F69536325A1D65A042E0781@penmb01.corp.atmel.com>

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

       reply	other threads:[~2012-01-06 10:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <DB7B9DAED0B660469F69536325A1D65A042E0781@penmb01.corp.atmel.com>
2012-01-06 10:27 ` nick clifton [this message]
2012-01-06 11:39   ` Andrew Burgess
2012-01-06 14:11   ` Tom Tromey
2012-01-06 16:01     ` nick clifton
2012-01-06 23:11       ` Cary Coutant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F06CC32.10102@redhat.com \
    --to=nickc@redhat.com \
    --cc=Praveen_Kumar.Kaushi@atmel.com \
    --cc=binutils@sourceware.org \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).