This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: "AT > region" interpreted as "> region" in linker script
- From: Nick Clifton <nickc at redhat dot com>
- To: "Galit Heller" <Galit dot Heller at nsc dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Tue, 13 Jan 2004 10:41:27 +0000
- Subject: Re: "AT > region" interpreted as "> region" in linker script
- References: <4003BCDC.DB1DD11E@nsc.com>
Hi Galit,
> Any news on this ?
>
> http://sources.redhat.com/ml/binutils/2004-01/msg00034.html
Oops - another one that slipped through, sorry.
> While trying the patch, I noticed a similar problem (not caused by
> the patch). The problem is similar in the sense that a virtual
> address setting is "not taken into account" with relation to a
> memory region setting:
>
> The following scenario results in the error message:
> ld-new: section .data [00000010 -> 0000001b] overlaps section .text
> [00000010 -> 000003a7]
>
> MEMORY {
> ram : ORIGIN = 0x10, LENGTH = 0x1000
> }
>
> SECTIONS { .text 0x10 : { *(.text) }
> .data : { *(.data) } > ram
> }
>
> I.e. the second output section statement allocates the ram region
> from the beginning, without taking into account that this area had
> already been allocated to another output section.
No, this one is pilot error. It is the responsiblity of the linker
script author to make sure that overlapping regions are not created.
The linker manual explicitly states:
The linker will set section addresses based on the
memory regions, and will warn about regions that
become too full. The linker will not shuffle sections
around to fit into the available regions.
Since the script has not set up the attributes for the "ram" region,
it cannot assign the .text section to it, so it has to put it in an
(internally defined) global memory region which covers the entire
address space.
The best way to fix this problem is either to use explicit memory
regions for all sections, or to define the attributes for enough
regions so that all of the not-explicitly-mapped-to-a-region input
sections will be allocated to linker script defined regions. ie:
MEMORY {
ram : ORIGIN = 0x10, LENGTH = 0x1000
rom : ORIGIN = 0x1010, LENGTH = 0x1000
}
SECTIONS { .text : { *(.text) } > ram
.data : { *(.data) } > rom
}
or:
MEMORY {
ram (!r) : ORIGIN = 0x10, LENGTH = 0x1000
}
SECTIONS { .text : { *(.text) }
.data : { *(.data) } > ram
}
Cheers
Nick