linker debug info editing
Alan Modra
amodra@bigpond.net.au
Fri Mar 10 19:44:00 GMT 2006
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: debug.diff.gz
Type: application/x-gunzip
Size: 15823 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20060310/9923ab25/attachment.bin>
More information about the Gdb-patches
mailing list