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

4

我想从GCC迁移到新的ARM编译器6。

但是我无法将Gnu链接器脚本(ld)很好地转换为ARM Scatter文件的等效文件。

以下是原始代码:

arm-none-eabi-ld -T link.ld test.o shared/bootcode.o shared/vertors.o -o test.elf
脚本如下:
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

但我没有成功创建有效的scatter文件。我尝试使用armlink选项(--first,--last,--ro_base,--rw_base)进行操作,但是什么都不如预期(编译成功但测试无法运行)。

有什么想法吗?


你能分享一下你想要转换到armlink的原因吗? - rox
2个回答

3

我查看了这里的文档: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

0

armlink允许读取GNU LD链接器脚本,但有限制。

标志是“--linker_script=ld_script”。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接