This is the mail archive of the
mailing list for the binutils project.
Re: ELF octets_per_byte
- From: "Maciej W. Rozycki" <macro at linux-mips dot org>
- To: dgisselq at ieee dot org
- Cc: binutils at sourceware dot org
- Date: Fri, 26 Feb 2016 15:43:44 +0000 (GMT)
- Subject: Re: ELF octets_per_byte
- Authentication-results: sourceware.org; auth=none
- References: <1456242622 dot 30661 dot 448 dot camel at jericho> <alpine dot LFD dot 2 dot 20 dot 1602232312590 dot 7431 at eddie dot linux-mips dot org> <1456368038 dot 21426 dot 29 dot camel at jericho>
> > As to the symbol size I think it needs to be set to whatever the
> > C-language's `sizeof' operator would return for a unit of storage of the
> > same size.
> As I mentioned earlier this evening, the Zip CPU features:
> sizeof(char)=sizeof(short)=sizeof(int)=sizeof(void *)=1 // 32-bits
> It's a ... unique architectural feature. :)
I'm not sure it's that unique, though I do realise it's not that common
these days either.
Anyway, a symbol's size can be seen as an arithmetic difference between
the next available address and the address of the symbol, so with an
architecture defined like yours it looks to me you need to count in 32-bit
quantities here. Symbol sizes are not interpreted by generic ELF tools,
except perhaps from presenting them to the user in dumps, but they may be
processed by software run on the target such as by a dynamic loader for
the purpose of processing copy relocations. So using a data size
measurement unit suitable for the target seems appropriate to me, so as
not to incur unnecessary run-time overhead if nothing else. If similar
processing turns out then to be required in static linking as well, then
the static linker can be adjusted accordingly in a target-specific manner.
FWIW, GAS will set a `foo' symbol's size with an assembly language
construct like this:
# Symbol contents come here.
.size foo, . - foo