[Dwarf-Discuss] What is a byte's size?
Mon Jul 21 17:49:44 GMT 2008
Oops. Replied to the wrong mailing list.
Jan van Dongen wrote:
> I've an issue with one of our users about the meaning of the DW_AT_byte_size attribute.
> In my interpretation a value of '1' means '1' minimal addressable unit. On an architecture with 16-bit memory, this
> then means one '16-bit' byte.
> The user (or actually his debugger provider) interprets the value '1' as one '8-bit' byte. Iow: a byte is always
> 8-bit in size. A 16-bit 'short int' then should have a 'DW_AT_byte_size' with value '2'.
> The DWARF3 standard defines: A base type entry has a DW_AT_byte_size attribute, whose value (see Section 2.19) is the
> size in bytes of the storage unit used to represent an object of the given type.
> The phrase 'bytes of the storage unit used' to me explains that the size of a byte depends on the architecture and
> thus is not an 8-bit entity by definition. Unfortunately, the DWARF document nowhere gives an explanation of the term
> Even worse, of course a 'byte' in an object file does not have to match a 'byte' on the architecture, so there can be
> confusion everywhere.
> Can anyone provide me the proper interpretation?
> Kind regards, Jan van Dongen
Section 5.1 of the DWARF 3 Standard has this definition of DW_AT_byte_size:
A base type entry has a DW_AT_byte_size attribute, whose value (see Section 2.19)
is the size in bytes of the storage unit used to represent an object of the given type.
"Storage unit" in this sentence is the container (e.g., memory) which contains
an object of a particular type. "Storage unit" is only used in this section and
in the other two uses it is clear that it is describing a container of arbitrary
size, not referring to an architecture-dependent addressing unit.
Unfortunately, the standard doesn't explicitly define 'byte'. If it did, this
possible ambiguity would not arise. Byte is used with a single consistent
machine-independent fashion throughout the standard.
Michael Eager eager at eagercon.com
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077
More information about the Dwarf-discuss