Hello,
I've observed a difference in DWARF output for the same input source code
between GCC 5 and GCC 6, specifically in the DW_AT_data_member_location values
for bitfield members of structs. For example,
s.c:
struct s {
unsigned int shutdown:2,
no_check_tx:1,
no_check_rx:1,
userlocks:4,
protocol:8,
type:16;
};
int main() {
struct s s;
return 0;
}
GCC 5 reports DW_AT_data_member_location for all the fields as 0, which is
expected.
GCC 6 reports DW_AT_data_member_location for the "type" and "protocol" fields
as 2 and 1 respectively, all other fields 0 as expected. The DW_AT_bt_offset
fields for "type" and "protocol" change as well.
Am I wrong to expect that for the given struct above, that the member location
offset for all fields should be 0 across both compilers?
GCC 5.4.0 readelf --debug-dump:
<2><64>: Abbrev Number: 3 (DW_TAG_member)
<65> DW_AT_name: (indirect string, offset: 0x0): userlocks
<69> DW_AT_decl_file : 1
<6a> DW_AT_decl_line : 5
<6b> DW_AT_type: <0x92>
<6f> DW_AT_byte_size : 4
<70> DW_AT_bit_size: 4
<71> DW_AT_bit_offset : 24
<72> DW_AT_data_member_location: 0
<2><73>: Abbrev Number: 3 (DW_TAG_member)
<74> DW_AT_name: (indirect string, offset: 0x1c): protocol
<78> DW_AT_decl_file : 1
<79> DW_AT_decl_line : 6
<7a> DW_AT_type: <0x92>
<7e> DW_AT_byte_size : 4
<7f> DW_AT_bit_size: 8
<80> DW_AT_bit_offset : 16
<81> DW_AT_data_member_location: 0
<2><82>: Abbrev Number: 3 (DW_TAG_member)
<83> DW_AT_name: (indirect string, offset: 0x17): type
<87> DW_AT_decl_file : 1
<88> DW_AT_decl_line : 7
<89> DW_AT_type: <0x92>
<8d> DW_AT_byte_size : 4
<8e> DW_AT_bit_size: 16
<8f> DW_AT_bit_offset : 0
<90> DW_AT_data_member_location: 0
GCC 6.1.0 readelf --debug-dump:
<2><64>: Abbrev Number: 3 (DW_TAG_member)
<65> DW_AT_name: (indirect string, offset: 0x0): userlocks
<69> DW_AT_decl_file : 1
<6a> DW_AT_decl_line : 5
<6b> DW_AT_type: <0x92>
<6f> DW_AT_byte_size : 4
<70> DW_AT_bit_size: 4
<71> DW_AT_bit_offset : 24
<72> DW_AT_data_member_location: 0
<2><73>: Abbrev Number: 3 (DW_TAG_member)
<74> DW_AT_name: (indirect string, offset: 0x4a): protocol
<78> DW_AT_decl_file : 1
<79> DW_AT_decl_line : 6
<7a> DW_AT_type: <0x92>
<7e> DW_AT_byte_size : 4
<7f> DW_AT_bit_size: 8
<80> DW_AT_bit_offset : 24
<81> DW_AT_data_member_location: 1
<2><82>: Abbrev Number: 3 (DW_TAG_member)
<83> DW_AT_name: (indirect string, offset: 0x17): type
<87> DW_AT_decl_file : 1
<88> DW_AT_decl_line : 7
<89> DW_AT_type: <0x92>
<8d> DW_AT_byte_size : 4
<8e> DW_AT_bit_size: 16
<8f> DW_AT_bit_offset : 16
<90> DW_AT_data_member_location: 2