This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] ld: add support for LOG2() in linker scripts
- From: Clemens Lang <clemens dot lang at fau dot de>
- To: Hans-Peter Nilsson <hp at bitrange dot com>
- Cc: binutils at sourceware dot org, raimue at cs dot fau dot de
- Date: Tue, 23 Jul 2013 17:26:28 +0200
- 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>
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
What about two variants of the funtion, LOG2FLOOR and LOG2CEIL? Or
should I just ignore the ambiguity and have LOG2 round up?