[Bug debugedit/32845] assert triggers for missing debug_str_offsets entry

mark at klomp dot org sourceware-bugzilla@sourceware.org
Mon Apr 14 10:04:25 GMT 2025


https://sourceware.org/bugzilla/show_bug.cgi?id=32845

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Mark Wielaard <mark at klomp dot org> ---
commit 1a2cef32e5face9fc943c0b11759c6e8c7e0c765
Author: Mark Wielaard <mark@klomp.org>
Date:   Mon Apr 7 16:27:11 2025 +0200

    debugedit: Handle unused .debug_str_offsets entries

    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

    Signed-off-by: Mark Wielaard <mark@klomp.org>

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Debugedit mailing list