This is the mail archive of the 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: "AT > region" interpreted as "> region" in linker script

Hi Galit,

> Any news on this ?

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]
>         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:

         ram      : ORIGIN = 0x10,     LENGTH = 0x1000
         rom      : ORIGIN = 0x1010,   LENGTH = 0x1000
 SECTIONS { .text : { *(.text) } > ram
            .data : { *(.data) } > rom


         ram (!r) : ORIGIN = 0x10, LENGTH = 0x1000
 SECTIONS { .text :  { *(.text) }
            .data :  { *(.data) } > ram


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