Issue 221114.1: DW_FORM_implicit_const and DW_FORM_indirect
| Author: | David Anderson |
|---|---|
| Champion: | David Anderson |
| Date submitted: | 2022-11-14 |
| Date revised: | 2023-07-08 |
| Date closed: | 2023-06-26 |
| Type: | Error |
| Status: | Accepted with editorial changes |
| DWARF version: | 6 |
DWARF5 Section 7.5.3, pg 207
BACKGROUND
DW_FORM_indirect and DW_FORM_implicit_const
are not described correctly and this can lead to
an abbreviation section being impossible to read.
Because the standard says to put the implicit_const
in .debug_abbrev but in a DW_FORM_indirect leading
to .debug_abbrev DW_FORM_implicit_const
there is nothing in .debug_abbrev
that would allow the abbrev reader to understand
.debug_abbrev when searching for a particular
abbrev code.
A simple clarification/generalization resolves all the issues while keeping compatibility with DWARF5 wording.
From the index:
DW_FORM_implicit_const, pages 9,209,214,221
DW_FORM_indirect, pages 207,220,288.
the descriptions are in section 7.5.3 page 207:
(DWARF 5 page 207 starting at line 6:)
The attribute formDW_FORM_indirectis a special case. For attributes with this form, the attribute value itself in the.debug_infosection begins with an unsigned LEB128 number that represents its form. This allows producers to choose forms for particular attributes dynamically, without having to add a new entry to the abbreviations table.The attribute form
DW_FORM_implicit_constis another special case. For attributes with this form, the attribute specification contains a third part, which is a signed LEB128 number. The value of this number is used as the value of the attribute, and no value is stored in the.debug_infosection.
Add to the first paragraph:
A sequence of form
DW_FORM_indirectin.debug_infois allowed.
Revise the second paragraph to read:
The attribute form
DW_FORM_implicit_constis another special case. For attributes with this form, the attribute specification contains a third part which follows theDW_FORM_implicit_constunsigned LEB128 and is a signed LEB128 number. The value of this number is used as the value of the attribute.
Revised Proposal (2023-07-08)
DW5: page 207 lines 1-16
In DWARF6, replace those lines with proper latex saying:
Finally, the child encoding is followed by a series of attribute specifications. Each attribute specification consists of two parts (except for
DW_FORM_implicit_const,DW_FORM_addrx_offsetandDW_FORM_indirect, see below). The first part is an unsigned LEB128 number representing the attribute’s name. The second part is an unsigned LEB128 number representing the attribute’s form. The series of attribute specifications ends with an entry containing 0 for the name and 0 for the form.For attributes with the form
DW_FORM_implicit_const, in addition to the attribute name and form values, the attribute specification contains a third part, which is a signed LEB128 number. The value of this number is used as the value of the attribute.For attributes with the form
DW_FORM_addrx_offset, following the attribute name, the attribute specification contains two unsigned LEB128 numbers, each representing a form. The first form must be of class address and the second of class constant. Values using this form in the.debug_infosection contain a value for the first form followed by a value for the second form. The total value of theDW_FORM_addrx_offsetis then computed by adding those two values together (if the first value is an indirect address, that is resolved first before adding it to the second value).For attributes with the form
DW_FORM_indirect, the actual attribute form value itself is in the.debug_infosection which begins with an unsigned LEB128 number that specifies the actual form, followed by the value according to that form. This allows producers to choose forms for particular attributes dynamically, without having to add a new entry to the abbreviations table.If the actual attribute form is
DW_FORM_implicit_const, the form is (still) followed by a signed LEB128 number.If the actual attribute form is itself
DW_FORM_indirect, the indirection repeats. There may be one or more occurrences ofDW_FORM_indirectin sequence until a non-DW_FORM_indirectform is reached. The sequence ofDW_FORM_indirectforms does not have any effect other than to use up space.The abbreviations for a given compilation unit end with an entry consisting of a 0 byte for the abbreviation code.
2022-11-21: Revised
2023-04-10: Revised
2023-06-26: Accepted with editorial changes
2023-07-08: Editorial changes finalized