Issue 220708.2: .debug_{c,t}u_index missing/incomplete DWARF64 support

Author: David Blaikie
Champion: David Blaikie
Date submitted: 2022-07-08
Date revised:
Date closed: 2023-01-23
Type: Enhancement
Status: Accepted with modifications
DWARF Version: 6
Section 7.3.5.3, pg 193

The .debug_{c,t}u_indexes aren't compatible with DWARF64 - the 
offsets/sizes of sections use fixed 4 byte values, instead of 
4/8 byte values depending on the encoding of the length field 
indicating the use of the 32 or 64-bit DWARF format.

The current header doesn't have a length (it's not as important, 
since a dwp file is only expected to contain a single index in 
each section - so there's no need to skip over an index to find 
another in the same section), so missed the opportunity to encode 
the 32/64-bit selection there. And without changing the section 
name, one can't be added since it'd change the meaning of the 
first bytes before any version can be determined to decide whether 
those bytes are a length or the version (as it currently is).

Probably worth
 * adding a 32/64 bit field to the header, like the .debug_macro 
   offset_size_flag value
 * on that basis do the usual 4/8 byte selection for contribution 
   offsets and lengths

Currently the offsets table starts with a row that indicates which 
section is encoded in each column and that row uses the same encoding 
size (4 bytes) - it's probably overkill (I doubt we need more than 
1 byte to encode the column kind?) but at least it doesn't need to 
grow for DWARF64 - so keep it fixed at 4 bytes, even though the 
following rows are 4-or-8 byte, or maybe revisit and shrink it to 
1 byte?


Proposed Solution:
  Page 192:
    "2. offset_size_flag (ubyte)
       If the offset_size_flag is zero, the header is for a 32-bit 
       DWARF format unit index section and all offsets and lengths 
       are 4 bytes long; if it is one, the header is for a 64-bit 
       DWARF format unit index section and all offsets and lengths 
       are 8 bytes long.
    3. padding (ubyte)"
    (the rest of the fields as-before, but offset their count by 
    1 to account for the added field)
    
  Page 193:
    "each also containing N fields of 4-byte unsigned integers."
    ->
    "each containing N unsigned integer fields of size specified 
    by the index header offset_size_flag field."

  Page 194:
    "each with N fields of 4-byte unsigned integers."
    "each with N unsigned integer fields of size specified by 
     the by the index header offset_size_flag field."

--
2023-01-23: Accepted. Version number changed to 6 in Sec 7.3.5.3 and
   Appendix G.