Reputation: 233
I'm trying to write a linker script to write one section content into two non-contiguous memory regions.
I have found an old thread in this mail list about this: "ld linker script and non-contiguous memory region" http://sourceware.org/ml/binutils/2012-01/msg00188.html
I know a feature from the C28x Compiler for this problem is spliting the sections across multiple memory segments: (with an or function)
SECTIONS { .text: { *(.text) } >> FLASH1| FLASH3 }
described here: http://processors.wiki.ti.com/index.php/C28x_Compiler_-_Understanding_Linking
I have try it without success. At the moment I have to manually fill the fist memory region. but is a difficult to search parts of code witch I will not change in the future and fit and fill completely the first memory region.
Is such feature in the GNU linker implemented? Or does anyone has a better idea how can I solve this problem?
Upvotes: 17
Views: 5710
Reputation: 11
it seems that newer versions of the GNU LD support this feature now:
--enable-non-contiguous-regions
This option avoids generating an error if an input section does not fit a matching output section.
The linker tries to allocate the input section to subseque nt matching output sections, and generates an error
only if no output section is large enough. This is useful when several non-contiguous memory regions are available
and the input section does not require a particular one. The order in which input sections are evaluated
does not change, for instance:
MEMORY {
MEM1 (rwx) : ORIGIN = 0x1000, LENGTH = 0x14
MEM2 (rwx) : ORIGIN = 0x1000, LENGTH = 0x40
MEM3 (rwx) : ORIGIN = 0x2000, LENGTH = 0x40
}
SECTIONS {
mem1 : { *(.data.*); } > MEM1
mem2 : { *(.data.*); } > MEM2
mem3 : { *(.data.*); } > MEM3
}
with input sections:
.data.1: size 8
.data.2: size 0x10
.data.3: size 4
results in .data.1 affected to mem1, and .data.2 and .data.3
affected to mem2, even though .data.3 would fit in mem3.
This option is incompatible with INSERT statements because it changes the way input sections are mapped to output sections.
The flag that has to be added is: -Wl,--enable-non-contiguous-regions
Documentation to be found:
Excerpt from the Documentation
Upvotes: 1
Reputation: 2720
I think the easiest way (and maybe the only way) would be to split your section up into two sections, then assign one section to the first memory region, and the second section to the second memory region.
You have probably already seen this, but it is a pretty concise description of link scripts: http://www.math.utah.edu/docs/info/ld_3.html
Upvotes: 1