Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
RISC-V连接器抛出部分LMA重叠错误,尽管LMA';属于不同的记忆区域_C_Embedded_Ld_Riscv_Linker Scripts - Fatal编程技术网

RISC-V连接器抛出部分LMA重叠错误,尽管LMA';属于不同的记忆区域

RISC-V连接器抛出部分LMA重叠错误,尽管LMA';属于不同的记忆区域,c,embedded,ld,riscv,linker-scripts,C,Embedded,Ld,Riscv,Linker Scripts,我的链接器文件中有以下内存区域描述: /*============================= * Memory region descriptions *=============================*/ MEMORY { /*------------------------------------- * Virtual Memory Address (VMA) regions *-------------------------------------

我的链接器文件中有以下内存区域描述:

/*=============================
 * Memory region descriptions
 *=============================*/

MEMORY
{
  /*-------------------------------------
   * Virtual Memory Address (VMA) regions
   *-------------------------------------*/

  /* Local memory VMA */
  DMEM_VMA (rw) : ORIGIN = 0x1000, LENGTH = 4K

  /* DRAM text VMA */
  DRAM_T_VMA (rx) : ORIGIN = 0x0, LENGTH = 16M

  /* DRAM data VMA */
  DRAM_D_VMA (rw) : ORIGIN = 0x81000000, LENGTH = 2032M /* 2048M - 16M */


  /*----------------------------------
   * Load Memory Address (LMA) regions
   *----------------------------------*/

  /* Local memory LMA */
  DMEM_LMA (rw) : ORIGIN = 0x1000, LENGTH = 4K

  /* DRAM text LMA */
  DRAM_T_LMA (rx) : ORIGIN = 0x0, LENGTH = 16M

  /* DRAM data LMA */
  DRAM_D_LMA (rw) : ORIGIN = 0x01000000, LENGTH = 2032M
}



/*=============================
 * Output section descriptions
 *=============================*/

SECTIONS
{

  /*----------------------------------
   * DMEM output sections
   *----------------------------------*/

  /* data segment */
  .data.dmem : { 
    *(.data) 
  } >DMEM_VMA AT>DMEM_LMA

  .sdata.dmem : {
    _gp = . + 0x800;
    *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata*)
    *(.sdata .sdata.* .gnu.linkonce.s.*)
  } >DMEM_VMA AT>DMEM_LMA


  /* bss segment */
  .sbss.dmem : {
    *(.sbss .sbss.* .gnu.linkonce.sb.*)
    *(.scommon)
  } >DMEM_VMA AT>DMEM_LMA

  .bss.dmem : { 
    *(.bss) 
  } >DMEM_VMA AT>DMEM_LMA


  /* thread-local data segment */
  .tdata.dmem : {
    _tls_data = .;
    *(.tdata)
    *(.tdata*)
  } >DMEM_VMA AT>DMEM_LMA

  .tbss.dmem : {
    *(.tbss)
    *(.tbss*)
  } >DMEM_VMA AT>DMEM_LMA


  /* read-only data */
  .rodata.dmem : { 
    *(.rodata) 
    *(.rodata*) 
  } >DMEM_VMA AT>DMEM_LMA


  .eh_frame.dmem : { 
    *(.eh_frame) 
    *(.eh_frame*) 
  } >DMEM_VMA AT>DMEM_LMA


  /* striped data */
  /* RISC-V 32 has a 4 byte word size */
  .striped.data.dmem ALIGN(bsg_group_size * 4): {
    _bsg_striped_data_start = . ;
    *(.striped.data)
  } >DMEM_VMA AT>DMEM_LMA


  /*----------------------------------
   * DRAM output sections
   *----------------------------------*/

  .text.dram : {
     *crt.o(.text)
     *(.text)
     *(.text.startup)
  } >DRAM_T_VMA AT>DRAM_T_LMA

  .data.dram : {
    *(.dram)
  } >DRAM_D_VMA AT>DRAM_D_LMA
}
我们有两个不同的区域称为DMEM和DRAM,它们在我们的体系结构中是物理上不同的内存。但是,对于我试图与此链接脚本链接的某些程序,我面临以下错误:

riscv32-unknown-elf/bin/ld: section .data.dmem LMA [0000000000001000,000000000000100f] overlaps section .text.dram LMA [0000000000000000,0000000000001e4f]
collect2: error: ld returned 1 exit status

我很困惑为什么链接器会抱怨两个不同LMA区域之间的重叠!任何关于调试的提示都会非常有用……

可能是因为从零开始的16M区域与从4K开始的4K区域明显重叠?@Clifford因为它们是不同的加载内存区域(物理上不同的内存,一个是sram,另一个是dram),我想它们可能有重叠的地址。加载地址是重叠的,但两个内存是不同的。如果您假设,那么您不知道。;-)如果两个存储器的地址相同,处理器如何区分它们?也就是说,在地址0x1000处访问哪个内存?@Clifford,@thebusybee一个是数据内存,另一个是指令内存。在我们的体系结构中,两者都从0开始——哈佛体系结构。甚至处理器内存映射也有重叠!有没有办法为这种体系结构编写链接器脚本?@vb000:但是链接器不知道内存体系结构。通常在这样的设备中,内存(或至少其中一个)在更高的区域进行镜像以适应这种情况-对于链接器,您可以指定备用映射。我不熟悉您的设备,因此无法提供建议。