This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] ld: add support for LOG2() in linker scripts
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- To: Clemens Lang <clemens dot lang at fau dot de>
- Cc: binutils at sourceware dot org, raimue at cs dot fau dot de
- Date: Tue, 23 Jul 2013 16:01:32 -0400 (EDT)
- Subject: Re: [PATCH] ld: add support for LOG2() in linker scripts
- References: <20130719124523 dot GA4031 at towel dot neverpanic dot de> <alpine dot BSF dot 2 dot 02 dot 1307221813050 dot 42817 at arjuna dot pair dot com> <20130723152628 dot GF4031 at towel dot neverpanic dot de>
On Tue, 23 Jul 2013, Clemens Lang wrote:
> On Mon, Jul 22, 2013 at 06:26:26PM -0400, Hans-Peter Nilsson wrote:
> > But why the floor of the log2; why round towards 0?
> >
> > I'd think rounding against infinity, but with 0 yielding 0,
> > would be more useful, yielding the required power of 2 of the
> > memory size to contain the region. You wouldn't be interested
> > in 75k yielding "16" (as 64k); for anything above 64k up to 128k
> > you'd want "17"; a 128k memory is needed. That seems to match
> > your requirement description as well.
> >
> > How about tweaking this to instead yield the ceiling of the log2
> > (with 0 yielding 0)?
>
> I agree that this is more useful in the context of linker scripts. I
> initially didn't implement it this way, because it seemed uncommon to me
> that a function called "LOG2" returning an integer rounds towards
> infinity.
>
> What about two variants of the funtion, LOG2FLOOR and LOG2CEIL? Or
> should I just ignore the ambiguity and have LOG2 round up?
FWIW, I don't have any particularly strong opinion either way.
Though I think you'd prefer going for the simplest solution and
just have one function, when adding the missing test-cases. ;)
brgds, H-P