[Dwarf-Discuss] Usage of STRP forms in DWO files.

Igor Kudrin ikudrin@accesssoftek.com
Wed May 20 12:59:56 GMT 2020


Hi all,

It looks like there is an ambiguity in the DWARF standard concerning using STRP forms in DWO files.

On the one hand, they are (conditionally) allowed:
* Section B.2, fig. B.2, p. 278. There are other arcs to ".debug_str.dwo" apart from an arc from ".debug_str_offsets.dwo".
* Section B.2, p. 279, l. 27-29: "(do) .debug_info.dwo to .debug_str.dwo. Attribute values of class string may have form DW_FORM_strp, whose value is an offset in the .debug_str.dwo section of the corresponding string."
* Section F.1, p. 393, l. 1-3: "In a .dwo file, referring to a string using DW_FORM_strp is valid, but such use results in a file that cannot be incorporated into a package file (which involves string merging)."

On the other hand, they are prohibited:
* Section F.2.3, p. 403, l. 4-6: "In a split DWARF object file, all references to strings go through this table (there are no other offsets to .debug_str.dwo in a split DWARF object file). That is, there is no use of DW_FORM_strp in a split DWARF object file."
* Section F.3, p. 409, l. 19-22: "Because all references to these strings use form DW_FORM_strx, the packaging utility only needs to adjust the string offsets in each .debug_str_offsets.dwo contribution after building the new .debug_str.dwo section."

All these excerpts are from informative parts. I cannot find any direct allowance or prohibition in normative sections. There is a very indirect restriction in section 7.3.5, p. 190, l. 24-26: "The string table section in .debug_str.dwo contains all the strings referenced from DWARF attributes using any of the forms DW_FORM_strx, DW_FORM_strx1, DW_FORM_strx2, DW_FORM_strx3 or DW_FORM_strx4." Note that this excerpt does not say anything about referencing strings from a .debug_macro.dwo section.

If STRP forms are allowed only in DWO files which cannot be combined into a DWP file, then a packaging utility should be smart enough to detect such input files and reject them. As there is no simple sign for that, the tool should analyze sections in input files to check if those forms are actually used; that parsing will slow down the processing, but it seems inevitable if we want the tool to be reliable.

I would like to discuss possible ways to avoid that ambiguity in the standard. I see the following variants:

1. Prohibit STRP forms in all DWO files. That would probably be the simplest solution, but maybe it is too restrictive.
2. Allow only STRP or STRX forms in a DWO file, but not both. In that case, a packaging tool can use the absence of a .debug_str_offsets.dwo section with a non-empty .desug_str.dwo section as a sign that the input file uses STRP forms and easily reject it.
3. Allow STRP forms in all DWO files. Consequently, allow STRP forms in DWP files. A packaging tool is expected to be smart enough to merge strings even from such input files and update references in the corresponding sections, not only in .debug_str_offsets.dwo.

Any thoughts?

Best Regards,
Igor Kudrin
C++ Developer, Access Softek, Inc.



More information about the Dwarf-discuss mailing list