This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Relative expressions and ASSERT


On Thu, Dec 16, 2010 at 4:01 PM, Alan Modra <amodra@gmail.com> wrote:
> 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.
>

I am putting this into the Linux binutils.


-- 
H.J.
---
ld/

2010-12-16  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/12327
	* ldexp.c (exp_fold_tree_1): Only make absolute symbol value
	absolute.

ld/testsuite/

2010-12-16  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/12327
	* ld-scripts/defined.exp: Run defined4.

	* ld-scripts/defined4.d: New.
	* ld-scripts/defined4.s: Likewise.
	* ld-scripts/defined4.t: Likewise.

Attachment: binutils-pr12327-1.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]