【问题标题】:gcc link file for memory map, what syntax is that?内存映射的 gcc 链接文件,那是什么语法?
【发布时间】:2011-05-22 12:36:25
【问题描述】:

当使用 gcc 为 MCU 进行交叉编译时,您需要向链接器提供链接器脚本文件,以便它知道如何创建最终目标文件。

我想了解有关此类文件的更多信息,但找不到关于这些文件如何工作、它们使用何种语法、哪些是最佳做法以及应避免哪些方面的好教程。

这是一个精简链接文件的示例,该文件将通过“-Tlinkfile.ld”选项提供给链接器:

MEMORY
{
    ram    (rwx) : ORIGIN = 0x20000000, LENGTH = 20k
    rom    (rx)  : ORIGIN = 0x00000000, LENGTH = 128K
}
SECTIONS
{
    .  = 0x0;           /* From 0x00000000 */
    .text : 
    {
        *(.nvic_vector)  /* Vector table */
        *(.text.*)      /* Program code */
        *(.text)        /* Program code */
        *(.rodata)      /* Read only data */
    } >rom

    .  = 0x20000000;    /* From 0x20000000 */      
    .data : 
    {
        *(.data)        /* Data memory */
    } >ram AT > rom

    .bss : 
    {
        *(.bss)         /* Zero-filled run time allocate data memory */
    } >ram AT > rom
}  

/谢谢

【问题讨论】:

    标签: gcc linker arm microcontroller cortex-m3


    【解决方案1】:

    GNU binutils ld documentation 中记录了语法 - 这与其说是教程,不如说是参考,但其中散布着各种示例。

    【讨论】:

      猜你喜欢
      • 2014-04-07
      • 2020-08-16
      • 2010-10-13
      • 1970-01-01
      • 2012-06-24
      • 2011-06-23
      • 2020-04-07
      • 2012-02-08
      • 1970-01-01
      相关资源
      最近更新 更多