This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ELF octets_per_byte
- From: "Maciej W. Rozycki" <macro at linux-mips dot org>
- To: Cary Coutant <ccoutant at gmail dot com>
- Cc: dgisselq at ieee dot org, Binutils <binutils at sourceware dot org>
- Date: Thu, 25 Feb 2016 02:03:29 +0000 (GMT)
- Subject: Re: ELF octets_per_byte
- Authentication-results: sourceware.org; auth=none
- References: <1456242622 dot 30661 dot 448 dot camel at jericho> <CAJimCsF_3u-CDXkybODnkTAyZqihS-wdwFwL+qqWnUfHKQ3xnQ at mail dot gmail dot com>
On Wed, 24 Feb 2016, Cary Coutant wrote:
> > While binutils has support for an "octets_per_byte" value other than
> > one, this feature does not appear to be fully supported. Indeed, the
> > "bfd/elflink.c" file contains several "FIXME" lines regarding the
> > insufficiency of the current support.
>
> It doesn't seem to me that having a minimum addressable unit of
> 32-bits necessarily makes your byte size 32 bits. That would actually
> surprise me quite a lot. You've simply described a word-addressed
> machine, and it would be quite sensible to continue to have four 8-bit
> bytes in each of those 32-bit words. Does your C compiler evaluate
> sizeof(void *) to 1 or to 4?
Your understanding of bytes however seems to me contradicted by the C
language standard[1]:
"3.6
byte
addressable unit of data storage large enough to hold any member of the
basic character set of the execution environment
NOTE 1 It is possible to express the address of each individual byte of
an object uniquely.
NOTE 2 A byte is composed of a contiguous sequence of bits, the number of
which is implementation-defined. The least significant bit is called the
low-order bit; the most significant bit is called the high-order bit."
-- notice how the standard explicitly states that a byte is an addressable
unit and that individual bytes have unique addresses. This means that you
cannot squeeze multiple bytes into a single addressable word in a
word-addressed machine, because by doing so -- by definition -- you have
no means to address the individual bytes.
NB this is different from a byte-addressable machine which can only
access memory in larger quantities you could refer to as "words" such as
early DEC Alpha (EV4, EV45) processors. While they could not access
individual bytes addresses were still multiples of 4, so conceptually you
could assign addresses to individual bytes. In fact for many (most?)
modern machines that have their data bus wider than a byte individual byte
addresses are indeed conceptual only as they're never observed in the
address cycle and lane enables are used instead in the data cycle.
References:
[1] "Programming languages -- C", ISO/IEC 9899:201x, Committee Draft --
April 12, 2011, p. 4
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>
Maciej