如何将GNU链接器脚本ld转换为Scatter File(ARM)

时间:2015-05-19 16:57:39

标签: gcc linker arm ld

我想从GCC迁移到新的ARM COMPILER 6。 但我无法将Gnu liker脚本(ld)转换为等效的ARM Scatter文件。

原始代码如下:

arm-none-eabi-ld -T link.ld test.o shared/bootcode.o shared/vertors.o -o test.elf

其中link.ld脚本如下

ENTRY(bootcode)
SECTIONS
{
    . = 0x00000000;

    /* Code starts with vectors, then bootcode, then other code */
    .text :
    {
        *vectors.o(vectors)
        *bootcode.o(boot)
        *(.text) /* remainder of code */
    } =0

    .data : { *(.data) }
    .bss  : { *(.bss)  }

   /* Notes section
    * This is not used so we discard it. Although not used it needs to be
    * explicitly mentioned in the linker script as some toolchains will place
    * the notes section at adderss 0 if it is not explicitly mentioned*/
    /DISCARD/ : { *(.note*) }
    }

我想使用armlink作为链接器:

armlink --cpu=8-A.32 --entry=bootcode test.o shared/bootcode.o shared/vertors.o -o test.elf --scatter=ld.scat

但是我没有成功创建有效的分散文件。我尝试使用armlink选项( - first, - last, - ro_base, - rw_base),但没有按预期进行(我的编译成功但测试无效)。

有什么想法吗?

2 个答案:

答案 0 :(得分:2)

我查看了这里的文档:http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0803d/pge1362065973150.html

您要迁移的GNU链接描述文件可以重写为:

LOAD_ROM 0x0000              
{
    EXEC_ROM_1 0x0000   ; Name of first exec region (EXEC_ROM_1),
                        ; Start address for exec region (0x0000)
    {
        vectors.o(VECTORS)
        * (InRoot$$Sections)  ; All library sections that must be in a
                              ; root region, for example, __main.o,
                              ; __scatter*.o, __dc*.o, and * Region$$Table

    }
    EXEC_ROM_2 +0    ; Name of second exec region (EXEC_ROM_2)
    {
        bootcode.o(BOOT, +FIRST)
        * (+RO)
    }
    SRAM +0      ; Name of third exec region (SRAM)
    {
        * (+RW, +ZI)         ; Place all RW and ZI data into
                             ; this exec region
    }
}

为了指定图像的入口点,您可以使用命令行中指定的命令行选项--entry=bootcode

armlink --cpu=8-A.32 --entry=bootcode test.o shared/bootcode.o shared/vertors.o -o test.elf --scatter=ld.scat

答案 1 :(得分:0)

armlink允许读取GNU LD链接器脚本,但有限制。 标志是" - linker_script = ld_script"。