[Dwarf-discuss] strx use in debug_line table

David Blaikie dblaikie@gmail.com
Mon May 20 20:20:13 GMT 2024


On Thu, May 16, 2024 at 10:20 AM Mark Wielaard via Dwarf-discuss <
dwarf-discuss@lists.dwarfstd.org> wrote:

> Hi,
>
> Section 6.2.4.1 Standard Content Descriptions under 1. DW_LNCT_path has
> the following description on using DW_FORM_strx forms:
>
>    In a .debug_line.dwo section, the forms DW_FORM_strx, DW_FORM_strx1,
>    DW_FORM_strx2, DW_FORM_strx3 and DW_FORM_strx4 may also be used.
>    These refer into the .debug_str_offsets.dwo section (and indirectly
>    also the .debug_str.dwo section) because no
>    .debug_line_str_offsets.dwo or .debug_line_str.dwo sections exist or
>    are defined for use in split objects.
>
> This confuses me a little, it is as if the strx forms are only allowed
> when generating split dwarf. But that doesn't seem to be the intent,
> because under 6.2.4.2 Vendor-defined Content Descriptions all DW_FORM_strx
> variants are listed without special exceptions.
>
> So I assume the description under DW_LNCT_path is just to explain that
> there isn't a .debug_line_str_offsets section that the DW_FORM_strx
> forms can refer to. And that DW_FORM_strx forms are resolved as normal
> and can be used in both .debug_line and .debug_line.dwo content
> descriptions.
>
> This leaves the question how to determine the str_offsets_base to use.
> This seems to require to lookup the CU DIE(s) that refers to the line
> table and see if one of them has a DW_AT_str_offsets_base.
>
> While this is possible, it isn't very efficient when just parsing the
> .debug_line table itself.
>
> Would it make sense to add the str_offsets_base to the line table
> header (for DWARF6)?
>
> Or am I missing a better/simpler way to handle DW_FORM_strx in
> .debug_line tables? Or maybe using DW_FORM_strx forms in the
> .debug_line table is not something that is really done (I haven't
> actually found any producer which does).
>

Yeah, I think it's not sometihng that's really done - it'd conflict with
the "strip everything but .debug_line and .debug_line_str" that was enabled
in DWARFv5, with the intent to allow string deduplication of
path/directory/file names, while still ensuring that non-line debug info
could be stripped while keeping the line table in tact/usable. (in DWARFv4
the line table's strings were in the .debug_line section, so they couldn't
be deduplicated, they were moved out to allow deduplication but to a
separate section so they could be preserved by stripping tools while still
stripping all the other strings (which make up a lotl of debug info))

strx in non-dwo is there to reduce the number of relocations when
referencing a string in a string pool many times - but the line table
already has that functionality built in, by numbering the file/directories
and referencing them by number in the line table state machine. So there
isn't any/much motivation to use a strx encoding - and if there was, we'd
want that strx to reference into the line_str section, but we probably
wouldn't want to put the line_str_offsets table in a separate section, so
it'd end up in the .debug_line section, and... we already have that
numbering system in there.

So, yeah, if it's not already clear enough -probably just forbidding strx
in non-dwo line tables would be OK?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dwarfstd.org/pipermail/dwarf-discuss/attachments/20240520/a596d63c/attachment.htm>


More information about the Dwarf-discuss mailing list