title: How link the same object into both data and program memory of a DSP?
body: <p>I need to put the same object into different memory sections. I'm working on a <a href="http://en.wikipedia.org/wiki/Digital_signal_processor" rel="nofollow">DSP</a> with separate data and program memory. The <code>.text</code> sections are normally stored inside the P-MEM. But I want to store the same code also inside the data memory. It is possible to copy it during run-time, but I think I should also be possible during link time.</p>
  
  <p>This is what I'm looking for, but it's not working since I could not find a "copy" or "duplicate" instruction that would allow to put the same code in different sections.</p>
  
  <pre><code>MEMORY
  {
  /* MAP 1*/
  
      VECS:     org=0x00000000 len=0x00000400
  
      PMEM:     org=0x00000400 len=0x0000FC00 
  
      DMEM:     org=0x80000000 len=0x0000F800
      DMEM_FT:  org=0x8000F800 len=0x00000800 
  
  }
  
  SECTIONS
  {
  
      vectors    &gt; VECS
      .text      &gt; PMEM &lt;----- containing ALL code (also including func1.obj(.text) )
      .bss       &gt; DMEM
      .cinit     &gt; DMEM
      .stack     &gt; DMEM
      .far       &gt; DMEM
      .switch    &gt; DMEM
      .data      &gt; DMEM
      .sysmem    &gt; DMEM
      .const     &gt; DMEM
      .cio       &gt; DMEM
      dmem_mirror: 
      {
          func1.obj(.text)
      }        &gt; DMEM_FT
  
  }
  </code></pre>
  
  <p>If I'm using the linker script above, it's clearly putting the <code>func1.obj</code> only inside the <code>dmem_FT</code> section (that`s what the linker is supposed to do!), but that is not what I want :-/ . I'm working with the Texas Instruments compiler and linker, but the syntax is the same as on a GCC linker.</p>