【问题标题】:How to convert a GNU linker Script ld to Scatter File (ARM)如何将 GNU 链接器脚本 ld 转换为分散文件 (ARM)
【发布时间】:2015-07-31 15:23:00
【问题描述】:

我想从 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),但没有按预期进行(编译成功,但测试不起作用)。

请问有什么想法吗?

【问题讨论】:

  • 您能分享一下您要切换到 armlink 的原因吗?

标签: gcc linker arm ld


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    armlink 允许读取 GNU LD 链接描述文件,但是有一些限制。 标志是“--linker_script=ld_script”。

    【讨论】:

      猜你喜欢
      • 2010-09-24
      • 2021-01-29
      • 2019-07-31
      • 2013-10-26
      • 2014-12-24
      • 1970-01-01
      • 2018-01-05
      • 2016-11-12
      • 2013-10-16
      相关资源
      最近更新 更多