2

I am newbie to linker script. In my design, RISCV has the code space and data space seperately. The code address is 0~0xFFFF, the data address is 0~0xFFFFFF. Here is my linker scprit:

MEMORY
{
  CODE (rx) : ORIGIN = 0x0000, LENGTH = 0x10000
  DATA (rwx) : ORIGIN = 0x000000, LENGTH = 0x1000000
}

SECTIONS
{
  .text :
  {
    /* Code section */
    *(.text)
  } > CODE

  .data :
  {
    /* Data section */
    *(.data)
    *(.bss)
  } > DATA
}

I got a address conflict issue:section .data LMA [0000000000000000, 0000000000000047] overlpas section .text LMA [0000000000000000, 0000000000001AFF]. So how should I configure a linker script、 thanks

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • Don't put your data and code at the same start address, obviously. If you want .data to start right after .text, I'd guess you can just avoid specifying an ORIGIN for `DATA`. – Peter Cordes Jul 14 '23 at 04:04
  • @PeterCordes thanks for your comments. In my design,data has own independent address space(0~0xffffff), cod has own independent address space(0~0xffff). I don't know how to resolve this issue in linker script. – hyperion007 Jul 14 '23 at 04:27
  • Oh, so you have a fully Harvard RISC-V? I didn't know those existed, but yeah that would do it. – Peter Cordes Jul 14 '23 at 04:56
  • @PeterCordes it's hard to say "Harvard RISC-V". because our riscv will be working in a simple situation. All the needed data and code are their own memory. – hyperion007 Jul 19 '23 at 04:02
  • Harvard implies that code address `0` is a different memory cell from data address `0`. If you don't have that, you can't put two different things at the same numerical address because they're all part of one flat memory address-space, so you'd have conflicting values for the same cell of memory. – Peter Cordes Jul 19 '23 at 04:13

0 Answers0