Issue 161031.2: Remove useless padding from unit headers

Author: Jakub Jelinek
Champion: Jakub Jelinek
Date submitted: 2016-10-31
Date revised:
Date closed:
Type: Improvement
Status: Accepted
DWARF Version: 5
Section 7.5.1, pg 199
In 7.5.1 we have
"All unit headers in a compilation have the same size. Some header types 
include padding bytes to achieve this."  and then padding1 and/or padding2 
fields in various unit headers.

As we have unit_type field, I don't see any point in requiring all the unit 
headers be the same size and wasting thus a lot of space (especially for 
partial units which are usually very small and extra 12 bytes mean a lot - 
for dwarf size reduction it will be often boundary between when it is 
desirable to create the partial unit or not at all.

I think it is fine if the unit header size and fields depend on the version 
field and unit_type fields.  The question is if we add any padding for 
DW_UT_lo_user..DW_UT_hi_user - if it makes any sense for consumers which 
have no idea what is such a unit good for to be able to find the DIEs in 
it, or not.

Also, in 7.5.1.1 (3.) we say that the unit_type field is new in DWARF 
Version 5, but don't have similar comment for (4.) and (5.) - those two 
fields aren't new, but swapped order in DWARF Version 5, and the padding
1/2 fields (though see above, I'd like them to go).

Another question is in 7.5.1.2, we say that (3.) is new in DWARF Version 5,
but in reality the whole skeleton unit header is new in DWARF Version 5 
(together with the split DWARF support); or we should also note that (4.) 
and (5.) were swapped and the dwo_id field is new.

--

Accepted 1/3/2017.

The first three fields in unit headers are all identical.  No additional 
padding is used.  Each different unit type may add fields after the three
common fields.