[Dwarf-Discuss] DWARF2 - Endianity issues for DW_AT_bit_offsetfields

David Earlam David.Earlam at csr.com
Thu Sep 8 03:27:35 PDT 2011


> Hello David,
> 
> Thanks for the explanation.
> 
> There is one more little-endian architecture - AVR on which I work. I get
> this output for 'l' of test. (gcc 4.5.1)
> 
> <2><5e>: Abbrev Number: 4 (DW_TAG_member)
>     <5f>   DW_AT_name        : l
>     <61>   DW_AT_decl_file   : 1
>     <62>   DW_AT_decl_line   : 6
>     <63>   DW_AT_type        : <0x75>
>     <67>   DW_AT_byte_size   : 1
>     <68>   DW_AT_bit_size    : 2
>     <69>   DW_AT_bit_offset  : 0xffffffff 0xffffffff
>     <71>   DW_AT_data_member_location: 2 byte block: 23 0
> (DW_OP_plus_uconst: 0)
> 
Hi Anitha,

Yes, it's valid.

If I use gcc 4.4.4 (x86 mingw tdm) with '-g -fpack-struct' arguments

firstly, the compiler reports
  dwarfbits.c:6: note: Offset of packed bit-field 'l' has changed in GCC 4.4
  - since an earlier gcc version I guess -

then secondly, 'objdump -W' of the produced Dwarf2 also says 

<2><80>: Abbrev Number: 4 (DW_TAG_member)
    <81>   DW_AT_name        : l	
    <83>   DW_AT_decl_file   : 1	
    <84>   DW_AT_decl_line   : 5	
    <85>   DW_AT_type        : <0x93>	
    <89>   DW_AT_byte_size   : 1	
    <8a>   DW_AT_bit_size    : 2	
    <8b>   DW_AT_bit_offset  : 0xffffffff	
    <8f>   DW_AT_data_member_location: 2 byte block: 23 0 	(DW_OP_plus_uconst: 0)

The debug_abbrev for DW_AT_bit_offset is DW_FORM_data4, I assume it is DW_FORM_data8 for you. (I didn't actually know AVR's could address that much memory, or just maybe there's a problem around here in GCC4.5.3 or the AVR port.)

It'd be easier to understand if the compiler were to use DW_FORM_sdata for 'signed constant' class of DW_AT_bit_offset then it is clearly signed for the DWARF consumer.

However if you interpret that DW_AT_bit_offset value as signed the 2 bit-field 'l' straddles addr+1 and addr+0. It all makes sense.

In Dwarf v4 the new DW_AT_data_bit_offset (alternative to Dwarf2 or Dwarf3 style DW_AT_data_member_location +or- DW_AT_bit_offset)
"must be greater than or equal to zero" so it is unsigned.

David 






Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog



More information about the Dwarf-Discuss mailing list