ESP32 ESP-IDF 链接脚本机制

ESP-IDF 链接脚本机制

ESP-IDF 从 v3.3 开始,支持在 component 层级控制链接过程,只需要使用Linker Script Generation机制和约定语法,在 component 里添加一个 xx.lf 文件,并在 Makefile 中引用。

COMPONENT_ADD_LDFRAGMENTS += "xx.lf"

按照约定语法填写内容:

\\示例:
[sections:text]
    .text+
    .literal+

[sections:iram]
    .iram1+

[scheme:default]
entries:
    text -> flash_text
    iram -> iram0_text

[scheme:noflash]
entries:
    text -> iram0_text

[mapping:freertos]
archive: libfreertos.a
entries:
    * (noflash)

脚本生成器将 xx.lf 转换成 gcc 链接片段,最终添加到工程的链接脚本中:

\\示例:
.iram0.text :
{
    /* Code marked as runnning out of IRAM */
    _iram_text_start = ABSOLUTE(.);

    /* Placement rules generated from the processed fragments, placed where the marker was in the template */
    *(.iram1 .iram1.*)
    *libfreertos.a:(.literal .text .literal.* .text.*)

    _iram_text_end = ABSOLUTE(.);
} > iram0_0_seg

猜你喜欢

转载自blog.csdn.net/qq_20515461/article/details/108148724