[Dwarf-Discuss] DWARF2 - Endianity issues for DW_AT_bit_offset fields

Boyapati, Anitha Anitha.Boyapati at atmel.com
Wed Sep 7 06:52:57 PDT 2011


Hello Brender,

Thanks for the attachments. The more I go through the issue, the more confused I am!

To start with I'll stick to simple example. Please help me out.

struct test {
        unsigned char a:1;
        unsigned char b:1;
        unsigned int  k:5;
        unsigned char l:2;
};

On a little-endian machine like x86, what is (are) the expected values for DW_AT_byte_size, DW_AT_bit_offset, DW_AT_data_member_location for member l of test?

That said, with gcc, I see the following output:

Abbrev Number: 3 (DW_TAG_member)
     DW_AT_name        : l
     DW_AT_decl_file   : 1
     DW_AT_decl_line   : 6
     DW_AT_type        : <af>
     DW_AT_byte_size   : 1
     DW_AT_bit_size    : 2
     DW_AT_bit_offset  : 6
     DW_AT_data_member_location: 2 byte block: 23 1     (DW_OP_plus_uconst: 1)


I don't understand how DW_AT_bit_offset turns out to be 6. Following the convention used by Allen:

39    32 31    24 23    16 15     8 7      0
+--------+--------+--------+--------+--------+
| addr+4 | addr+3 | addr+2 | addr+1 | addr+0 |
+--------+--------+--------+--------+--------+
 ..................................L lKkkkkBA

Should not DW_AT_byte_size for 'l' be 2, DW_AT_bit_offset be 7 and DW_AT_data_member_location be 0?

Please correct me if I am going wrong.


Anitha

>-----Original Message-----
>From: Ron Brender [mailto:ron.brender at gmail.com]
>Sent: Tuesday, September 06, 2011 4:05 PM
>To: Boyapati, Anitha; DWARF discussion mailing list
>Subject: RE: [Dwarf-Discuss] DWARF2 - Endianity issues for DW_AT_bit_offset
>fields
>
>The three emails referenced are attached.
>
>Ron Brender
>
>---------------
>Hello All,
>
>In DWARF2, I have some trouble understanding why GCC is generating
>negative offsets for DW_AT_bit_offset field of structure using bitfields
>(C language). The target is little-endian.
>
>Incidentally I happen to come across the endianity issues discussed in
>http://dwarfstd.org/ShowIssue.php?issue=081130.1&type=closed3
>
>
>It mentions the original problem described in three emails -
>
>"
>Brender email of 2008-05-17
>Robinson email of 2008-05-19
>Allen email of 2008-07-07
>"
>
>
>I tried searching them in dwarf-discuss archives but could not find. Can
>someone give me the links to the above conversations?
>
>Thanks
>
>
>Anitha
>_______________________________________________
>Dwarf-Discuss mailing list
>Dwarf-Discuss at lists.dwarfstd.org
>http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org



More information about the Dwarf-Discuss mailing list