Put gcc libs .data in specific section?

牧云@^-^@ 提交于 2019-12-13 12:31:25

问题


I'm trying to switch to the GNU GCC compiler for our embedded system, but I'm having trouble linking the project as the memory layout of our chip is split:

RAM section 1: 0x10000-0x12FFF
RAM section 2: 0x18000-0x1BFFF

The data from our project can fit in section 1, but the data linked from the gcc libs doesn't. Map file extract:

.data          0x00012974      0x3c4 c:/tools/gnucr16_v1.1.3-elf/cr16-elf/bin/../lib/gcc/cr16-elf/4.5.1-GNUCR16_v1.1.3/../../../../cr16-elf/lib\libc.a(lib_a-impure.o)
               0x00012974                _impure_ptr

.data          0x00012d7c      0x410 c:/tools/gnucr16_v1.1.3-elf/cr16-elf/bin/../lib/gcc/cr16-elf/4.5.1-GNUCR16_v1.1.3/../../../../cr16-elf/lib\libc.a(lib_a-mallocr.o)
               0x00012d7c                __malloc_av_
               0x00013184                __malloc_trim_threshold
               0x00013188                __malloc_sbrk_base

Is it possible to put the .data section from the libs in the 2nd section? I've tried different thing without success... Linker script extract:

MEMORY
{
  SHARED1    : org =   0x10000, len = 0x3000
  SHARED2    : org =   0x18000, len = 0x4000
}

SECTIONS
{
  .data 0x12004 : { *(.data); } >SHARED1
  .data2 0x19000 : { libc*(.data); } >SHARED2
}

回答1:


SECTIONS
{
  .section_name:
  {
    *lib_a-impure.o (.data);  //That is the syntax to access sections of object files
   } >SHARED1
}

More info here: http://www.embedded.com/design/mcus-processors-and-socs/4026080/Building-Bare-Metal-ARM-Systems-with-GNU-Part-3



来源:https://stackoverflow.com/questions/15499006/put-gcc-libs-data-in-specific-section

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