Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: binutils@sourceware.org, gdb-patches@sourceware.org
Subject: Re: linker debug info editing
Date: Mon, 13 Mar 2006 04:59:00 -0000	[thread overview]
Message-ID: <20060312181535.GA15023@nevyn.them.org> (raw)
In-Reply-To: <20060310124921.GN6777@bubble.grove.modra.org>

On Fri, Mar 10, 2006 at 11:19:21PM +1030, Alan Modra wrote:
> /* This file implements removal of DIEs for discarded link-once sections.
>    Such DIEs are detected by parsing debug sections to find DIE boundaries,
>    then examining relocations for each DIE.  Any DIE containing a field
>    with a relocation against a symbol in a discarded section is marked for
>    removal.  A removed DIE in .debug_info results in all of its children
>    and associated data in .debug_loc and .debug_ranges being removed too.
>    A removed CIE in .debug_frame results in all FDEs using that CIE
>    being removed, but no attempt is made to remove usused CIEs (as can
>    happen when all of a CIE's FDEs are removed).  Likewise, other unused
>    shared info, ie. .debug_abbrev and .debug_str entries, are not removed.
> 
>    We assume that
>    a) debug section relocations are sorted by r_offset,
>    b) .debug_info location lists (references to .debug_loc) occur
>       in increasing order of offset into .debug_loc,
>    c) .debug_info ranges (references to .debug_ranges) occur
>       in increasing order of offset into .debug_ranges,
>    d) entries in .debug_loc and .debug_ranges are not shared,
>    e) FDEs always occur at higher offsets than their associated CIEs
>       in .debug_frame.
> 
>    ld -r using perverse linker scripts can break the first three
>    assumptions.  */

Jim mentioned references to DIEs.  I'm also concerned by deleting just
the DIEs containing discarded relocations and their children; that's
not necessarily a logical place to cut the DIE tree.  In general, this
will work for you, because the relocations you're interested in are
those on DW_AT_high_pc and DW_AT_low_pc; but if the function uses
.debug_ranges instead I guess you won't find it.  And there's probably
some other cases where this is a problem, e.g. if you are cutting
member functions or static variables out of a class type.  Removing
the children can affect the interpretation of the parent.

All these complications are a shame; I think it would be useful if the
linker could edit DWARF data.  But it may be a bit complicated.

-- 
Daniel Jacobowitz
CodeSourcery


      parent reply	other threads:[~2006-03-12 18:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-10 19:44 Alan Modra
2006-03-10 20:06 ` James E Wilson
2006-03-10 20:16   ` Daniel Jacobowitz
2006-03-12  7:58 ` Jim Blandy
2006-03-13 12:53   ` Daniel Berlin
2006-03-13 20:19     ` Alan Modra
2006-03-14 15:10     ` Daniel Berlin
2006-03-13  4:59 ` Daniel Jacobowitz [this message]

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=20060312181535.GA15023@nevyn.them.org \
    --to=drow@false.org \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@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