[Dwarf-Discuss] byte vs. octet size
Fri Feb 12 18:49:39 GMT 2010
Jason Sachs wrote:
> Good morning...
> I'm having a bit of a concern with a vendor's implementation (Texas
> Instruments) of DWARF debugging info. The TI C2000 series of processors has
> memory locations each containing 16 bits. TI has chosen to measure the size
> of variables in DWARF debugging information (DW_AT_byte_size) as their size
> in memory locations, so a 16-bit int has DW_AT_byte_size of 1, and a 32-bit
> long has DW_AT_byte_size of 2.
> I can't find anywhere in the DWARF manual (I've read version 2.0 which TI
> implements; not sure if this has been clarified in 3.0 somewhere) where it
> either states definitively that a byte is an 8-bit octet, or that a byte may
> not be 8 bits per the C standard.
You raise a good point. There are two usages of "byte" in the DWARF
specification. One usage is for descriptions of the DWARF format,
where a value is described as having a certain size. When describing
the DWARF data, a byte does mean an 8-bit octet. The other usage
is in representing the sizes of data on the target, for example, as
the value for a DW_AT_byte_size attribute.
The DWARF specification doesn't say how big a byte is on the target
architecture. Perhaps it should mention that this is defined by the
ISA for the target. As far as I know, despite the examples for byte
or bit numbering assuming that a byte is 8 bits, DWARF does not depend
on or imply that a byte on the target must be any certain size.
Perhaps this should be mentioned in some non-normative text.
> Nor can I find anywhere in the DWARF manual where there might be a place for
> implementations to describe any of the following aspects of machine
> - the number of bits in a byte - the endianness of multibyte quantities, e.g.
> in a machine with 8-bit bytes, whether the 16-bit quantity "2" is stored as
> the successive bytes (0x00, 0x02) or as the successive bytes (0x02, 0x00) -
> machine architecture name (e.g. "Intel x86" or "TI C2000" or "8051" or
> [insert your favorite processor type here])
DWARF does not describe machine architecture. That is in an ISA document.
An ELF file (or other object file) contains a specification (but not
description) of the target architecture.
DWARF version 3, section 5.1 contains the following:
A base type entry may also have a DW_AT_endianity attribute as
described in Section 4.1. If omitted, the encoding assumes the
representation that is the default for the target architecture.
The type information does describe endianity, but only if it is different
from the default for the ISA. For that default, you need to consult the
> This information is important in a few key areas, notably translation of bit
> field positions from DW_AT_bit_offset (measured as an offset from the most
> significant end of the variable... but if I don't know how many bits a byte
> is, and my variable size is measured in bytes, I can't handle this properly).
> Any thoughts? I figured I'd get this straight from those of you familiar with
> the DWARF standard. (apologies if this has been asked before, I tried a
> little searching on the mailing list but didn't find anything)
Hope this helps.
Michael Eager eager at eagercon.com
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077
More information about the Dwarf-discuss