This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Relative expressions and ASSERT
On Thu, Dec 16, 2010 at 03:14:38PM -0800, H.J. Lu wrote:
> Your patch doesn't work. I got
>
> ./ld: kernel image bigger than KERNEL_IMAGE_SIZE
>
> due to arch/x86/kernel/vmlinux.lds:
>
> ----
> /*
> * Build-time check on the image size:
> */
> . = ASSERT((_end - _text <= (512 * 1024 * 1024)),
> "kernel image bigger than KERNEL_IMAGE_SIZE");
Extracting the relevant parts from the kernel link script:
SECTIONS
{
. = 0xc000;
.text :
{
_text = .;
*(.text)
}
_end = .;
}
ASSERT (_end - _text <= 0x100, "fail");
You'd think that under the new rules, this ought to work. "_end" is
an absolute address, so when evaluating "_end - _text", "_text" ought
to be converted from relative to absolute, the subtraction resuling in
an absolute address. Then 0x100 gets converted from a number to
absolute address before being compared.
The trouble is that "_end" is *not* treated as an absolute address but
as a plain number. That makes ld convert "_end" to a .text relative
address when evaluation "_end - _text", which doesn't cause a problem
at that stage, but the result is a relative address. That means 0x100
is converted to a .text relative address too, which gives the wrong
result.
The underlying problem is that we don't distinguish between plain
numbers and absolute addresses once values are stored in symbols.
--
Alan Modra
Australia Development Lab, IBM