Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* linker debug info editing
@ 2006-03-10 19:44 Alan Modra
  2006-03-10 20:06 ` James E Wilson
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Alan Modra @ 2006-03-10 19:44 UTC (permalink / raw)
  To: binutils, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2272 bytes --]

This is a first pass at debug info editing to remove bogus entries for
link-once functions.  I'm not going to commit it just yet as the only
testing I've done is linking a current libstdc++ and examining the
results with readelf, and there are some as yet unresolved issues.

I'm posting now because I'd like some feedback/review, particularly on
the overall design assumptions as detailed in the following comment.
Another thing I'm unsure of at this point is whether I should remove
the CU header when all following info is removed in .debug_info,
.debug_line, and .debug_aranges sections.  I know one consumer (readelf)
became confused when .debug_aranges had an empty unit.  Perhaps other
consumers expect some relationship between the number of CUs in
different debug sections?

One known issue is that .debug_pubnames and .debug_pubtypes have a
debug_info_length field, and I guess I need to edit this when shrinking
.debug_info.

/* 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.  */

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

[-- Attachment #2: debug.diff.gz --]
[-- Type: application/x-gunzip, Size: 15823 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-03-13 20:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-10 19:44 linker debug info editing 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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox