1

There are several memory regions

MEMORY
{
  rom1 (rx)   : ORIGIN = 0x00000000,    LENGTH = 256k
  rom2 (rwx)  : ORIGIN = 0x10000000,    LENGTH = 16M
  ram1 (rw!x) : ORIGIN = 0x20000000,    LENGTH = 64k
  ram2 (rwx)  : ORIGIN = 0x21000000,    LENGTH = 16M
}

How to place .text sections of all input files in the memory area of rom1, and if there is not enough space, then the remaining characters to place in rom2? Only one memory region can be specified in the description of the output section.

  .text :
  {
    *(.text)
  } > rom1
  • Depending on which CPU this is, there's likely commercial alternatives with linkers that support having a section in several regions. So that the linker tries to place something in region 1, until it can't fit there any longer, then places it in region 2. This is a somewhat common feature in my experience, I've used it now and then on various microcontroller systems. – Lundin May 29 '20 at 11:51

1 Answers1

0

As far as I know, there is no way to distribute a section over several non-contiguous memory regions.

As suggested here, the section should be divided into several sections and then assigned to the memory regions.

In general this is a very handy documentation about the different possibilities.

Sinic
  • 348
  • 3
  • 10