0

我需要将同一个对象放入不同的内存部分。我正在研究具有独立数据和程序存储器的DSP 。这些.text部分通常存储在 P-MEM 内。但我想将相同的代码也存储在数据存储器中。可以在运行时复制它,但我认为在链接时我也应该可以。

这就是我正在寻找的,但它不起作用,因为我找不到允许将相同代码放在不同部分的“复制”或“重复”指令。

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    > VECS
    .text      > PMEM <----- containing ALL code (also including func1.obj(.text) )
    .bss       > DMEM
    .cinit     > DMEM
    .stack     > DMEM
    .far       > DMEM
    .switch    > DMEM
    .data      > DMEM
    .sysmem    > DMEM
    .const     > DMEM
    .cio       > DMEM
    dmem_mirror: 
    {
        func1.obj(.text)
    }        > DMEM_FT

}

如果我使用上面的链接器脚本,它显然将func1.objonly 放在该dmem_FT部分内(这是链接器应该做的!),但这不是我想要的 :-/ 。我正在使用 Texas Instruments 编译器和链接器,但语法与 GCC 链接器相同。

4

1 回答 1

0

A quick look at the GNU ld manual does not give an obvious solution. One possible solution does come to mind. You could do a partial (ld -r) link of func1.obj, sending all the sections except .text to the special section /DISCARD/ and only outputting the .text section to e.g. func1a.obj. Unfortunately, I think you'll see multiple symbol definition errors from the linker when you actually do the final link.

于 2011-05-28T11:57:57.010 回答