load script to load a section at the top of a memory region

房东的猫 提交于 2019-12-11 03:38:51

问题


I'm working on a project for an embedded system, using an ARM M0.

A ROM application has to be created, whose sole purpose is to store stuff in rom, and initialize the data and bss sections whenever needed.

The loadscript so far is this:

MEMORY
{
  rom (rx): ORIGIN = 0, LENGTH = 32K ; 
  ram (!rx): ORIGIN = 0x10000, LENGTH = 8K ; 
}

SECTION
{
  . = ORIGIN(rom) ;

  .text:
  {
    KEEP(*(.text)) ;
  } >.

  .data:
  {
    KEEP(*(.data)) ;
  } >ram AT>.

  .bss:
  {
    KEEP(*(.bss)) ;
  } > ram = 0x00
}

I want to change the loadscript so that the data and bss portions are loaded into ram at the top of the memory region, not at the bottom.

How can I do that?


回答1:


As far as my understanding currently goes, this is simply not possible. One can, however, define a size, and use that calculate the starting address.

e.g.

_ram_data_size = 0x1000 ;
_ram_data_address = ORIGIN(ram) + LENGTH(ram) - _ram_data_size ;
_rom_data_address = 0x100 ;

SECTION
{
  .data _ram_data_address : AT _rom_data_address
  {
    KEEP(*(.data)) ;
  }
  ASSERT( SIZEOF(.data) <= _ram_data_size ) ;
}


来源:https://stackoverflow.com/questions/19096437/load-script-to-load-a-section-at-the-top-of-a-memory-region

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!