[PATCH] debugedit: Handle unused .debug_str_offsets entries
Mark Wielaard
mark@klomp.org
Mon Apr 14 10:03:06 GMT 2025
Hi,
On Tue, Apr 08, 2025 at 07:24:20PM +0200, Mark Wielaard wrote:
> As a sanity check we would assert when rewriting a .debug_str index we
> hadn't seen while processing the DWARF. This relies on the DWARF
> producer/compiler to not emit strings that aren't used. So when
> processing/rewriting the .debug_str_offsets we assume all indexes
> point to .debugstr offsets we have seen before.
>
> This assumption doesn't seem to hold for clang++ at the moment. It
> does put strings in the .debug_str section referenced from the
> .debug_str_offsets section that aren't used anywhere else. So
> debugedit will fail with an assert when processing such files.
>
> We don't want to process the .debug_str_offsets section multiple time
> and possibly have to rewrite other str references in other
> sections. So instead when we encounter an unseen/unused string we
> replace it with a dummy string "<debugedit>".
>
> To help DWARF producers indentify these unused strings we keep a
> reference to the original string table and produce a warning
> explaining which .debug_str_offsets table at which index points to the
> unseen .debug_str offset.
>
> debugedit: Warning, .debug_str_offsets table at offset ce2d0 index
> [4213] .debug_str [48cad9] entry 'CrossThreadCopierBaseHelper' unused,
> replacing with '<debugedit>'
>
> * tools/debugedit.c (debugedit_stridxentry): New static struct
> stridxentry.
> (struct strings): Add new field orig_data.
> (create_dummy_debugedit_stridxentry): New function.
> (string_find_new_entry): Add boolean argument accept_missing.
> Return &debugedit_stridxentry if no existing string index
> could be found.
> (setup_strings): Fill in orig_data field.
> (update_strings): New function to set orig_data field.
> (orig_str): New function returns the original string at index.
> (edit_strp): Call string_find_entry with false.
> (update_str_offsets): Call string_find_entry with true, emit
> warning if entry returned is &debugedit_stridxentry.
> (edit_dwarf2): Call update_strings and
> create_dummy_debugedit_stridxentry.
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=32845
This was tested in Fedora rawhide where it fixed the build issue seen.
Pushed to the main debugedit branch now.
Cheers,
Mark
More information about the Debugedit
mailing list