16

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?

dispatcher
  • 223
  • 3
  • 6

1 Answers1

1

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

Chris Desjardins
  • 2,631
  • 1
  • 23
  • 25
  • 2
    I know this is a very old question, but is there a good way to split it into two sections without manually mapping X into section A and Y into section B? I've got three non-contiguous memories to place an entire program in (.text, .data, and .bss) and it would be a bear to manage keeping them split. – rjp Nov 08 '16 at 21:42
  • 1
    Maybe it's the only way, but it's not easy. A good solution would be one in which the linker automatically fills a section in a memory region, then flows the rest into the next memory region. Even better, if it could do an automatic arrangement of sections to do a best-fit, when memory is tight (which it sometimes is in embedded software). – Craig McQueen Jun 09 '20 at 00:29