Issue 140208.1: New classes for DW_AT_str_offsets_base, etc

Author: Ron Brender
Champion: Ron Brender
Date submitted: 2014-02-08
Date revised:
Date closed:
Type: Error
Status: Accepted
DWARF Version: 5
Section 7.5.4, pg 159
Discussion
----------

Cary's original size optimization proposals (130331.*) specified 
the following classes of values for certain new attributes as:

    DW_AT_str_offsets_base  string
    DW_AT_addr_base         address
    DW_AT_ranges_base       rangelistptr

Your editor (masquerading as Ron) "corrected" these to all be class
reference.

When Cary saw this, he wrote:

> In Table 7.3, Attribute Encodings, on page 165, you've listed
> DW_AT_str_offsets_base, addr_base, and ranges_base as having
> "reference" class, while the proposals used "string", "address", and
> "rangelistptr", respectively. Was that deliberate? (I can see it
> either way.)

The editor replied:

>Yes, it was deliberate but I did linger over the issue for quite a bit. It
>is sort of an lvalue/rvalue kind of distinction. In these cases it feels
>like the attribute to acting like an lvalue so that the reference form
>is more appropriate.

Separately, Keith Walker wrote:

>I think that DW_AT_str_offset_base, DW_AT_addr_base and DW_AT_ranges_base 
>having a "reference" class is definitely wrong as a reference is currently 
>defined to be references within a compilation_unit, .debug_info section 
>or to a type unit;   none of which hold for these attributes.
>
>DW_AT_ranges_base being a rangelistptr looks sensible to me.
>
>However I question whether DW_AT_str_offset_base having a "string" class 
>and DW_AT_ranges_base being an "address" class is correct .... neither of 
>theses attributes returns a "string" or "address" (although they may 
>indirectly be used in the evaluation of a "string" or "address" on another 
>attribute).   It currently isn't clear what Form(s) should be used for 
>these attributes.
>
>I would suggest that there be 2 new classes such as "strlistptr" and 
>"addrlistptr" (there may be better names for them) which have definitions 
>similar to the existing loclistptr/rangelistptr/etc classes but which are 
>offsets into the .debug__str_offsets and .debug_addr sections.    Then 
>DW_AT_str_offset_base would have a class of "strlistptr" and DW_AT_addr_base 
>would have a class of "addrlistptr".    This would then mean these attributes 
>are then specified as using the form DW_FORM_sec_offset.

Cary and I now support Keith's suggestion. Following is the formal proposal to
incorporate it into the DWARF document.

Proposal
--------

In Table 2.3, add:

addrptr         Refers to a base location in the DWARF section that holds
                a series of machine address values. Certain attributes refer
                one of these addresses by indexing relative to this base
                location.
                
stroffsetsptr   Refers to a base location in the DWARF section that holds
                a series of offsets in the DWARF section that holds strings.
                Certain attributes refer one of these offets by indexing 
                relative to this base location. The resulting offset is the 
                used to index into the DWARF string section.

In Section 7.5.4, add:

  . addrptr
    This is an offset into the .debug_addr section (DW_FORM_sec_offset). It
    consists of an offset from the beginning of the .debug_addr section to the
    beginning of the list of machine addresses information for the
    referencing entity. It is relocatable in a relocatable object file, and relocated
    in an executable or shared object. In the 32-bit DWARF format, this offset is
    a 4-byte unsigned value; in the 64-bit DWARF format, it is an 8-byte
    unsigned value (see Section 7.4 on page 150).

  . stroffsetsptr
    This is an offset into the .debug_str_offsets section (DW_FORM_sec_offset). It
    consists of an offset from the beginning of the .debug_str_offsets section to the
    beginning of the string offsets information for the
    referencing entity. It is relocatable in a relocatable object file, and relocated
    in an executable or shared object. In the 32-bit DWARF format, this offset is
    a 4-byte unsigned value; in the 64-bit DWARF format, it is an 8-byte
    unsigned value (see Section 7.4 on page 150).
    
In Table 7.3, change the class (set of allowed representations) for these attributes:

    DW_AT_str_offsets_base  stroffsetsptr
    DW_AT_addr_base         addrptr
    DW_AT_ranges_base       rangelistptr
                

--
3/19/2014 -- Accepted.