This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC3551E:链接器命令文件、在存储器范围之间拆分、BSS 拆分安全 (TI Clang)

Guru**** 2864540 points

Other Parts Discussed in Thread: CC3551E

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/1625249/cc3551e-linker-command-file-splitting-across-memory-ranges-bss-split-safety-ti-clang

器件型号: CC3551E

我正在与一位使用 TI Clang 和 CC3551E 的客户合作。 在该器件中、内部 SRAM 分为通用 DRAM (~512K) 和紧密耦合 DRAM (~128K)。 在默认的 Network Terminal 项目中、为这些内存区域分配了一个组分配、如下所示:

    GROUP {
        .sysmem: {} palign(4)   /* This is where the malloc heap goes */
        .bss:    {} palign(4)   /* This is where uninitialized globals go */
        .data:   {} palign(4)   /* This is where initialized globals and static go */
        RUN_START(__BSS_START)
        RUN_END(__BSS_END)
        .stack:  {} palign(4)   /* This is where the main() stack goes */
    } > DRAM_NON_SECURE | TCM_DRAM_NON_SECURE

问题是、这些单独的段(特别是.bss 和.data)实际上并不会在这两个段之间拆分。 假设.sysmem 和.stack 将需要是连续的、因此我们不应该将它们拆分、我们希望将链接器命令文件设置更改为:

    GROUP {
        .sysmem: {} palign(4)   /* This is where the malloc heap goes */
        .stack:  {} palign(4)   /* This is where the main() stack goes */
    } > DRAM_NON_SECURE | TCM_DRAM_NON_SECURE

    GROUP {
        .bss:                   /* This is where uninitialized globals go */
        .data:                  /* This is where initialized globals and static go */
        RUN_START(__BSS_START)
        RUN_END(__BSS_END)
    } >> DRAM_NON_SECURE | TCM_DRAM_NON_SECURE

...note 在具有.bss 和.data 的第二个组中使用“>>"而“而不是“>>"。“。 然而、这就提出了一个问题、即在不连续的存储器区域之间拆分.data 是否安全。 转换器为__bss_start、并且可以使用__bss_end 来迭代该段、例如、使初始化为零。 调查生成的*。map 文件后、看起来这些符号未使用并获得链接。

进一步调查编译器的_c_int_00 ()->_TI_auto_init ()-> run_binit ()-> copy_in () 零初始化启动序列、似乎一个 init 表用于.bss init、因此我期望.bss 跨越两个非连续存储器区域是安全的。

.bss 跨越两个非连续的存储器区域并从链接器命令文件中删除__bss_start 和__bss_end 是否安全。

    GROUP {
        .sysmem: {} palign(4)   /* This is where the malloc heap goes */
        .stack:  {} palign(4)   /* This is where the main() stack goes */
    } > DRAM_NON_SECURE | TCM_DRAM_NON_SECURE

    GROUP {
        .bss:                   /* This is where uninitialized globals go */
        .data:                  /* This is where initialized globals and static go */
    } >> DRAM_NON_SECURE | TCM_DRAM_NON_SECURE

谢谢、

Stuart

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Stuart、

    我会进行深入研究。 我将向您介绍星期一的进度。

    感谢您的耐心。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Stuart、

    删除开头和结尾是关键、因为这些类型的段不能拆分。  

    我也不会使用 GROUP 选项 、因为您会尝试使单个输出段(本例中为.bss)不连续。  

    您最好使用>>、因为这是一个运算符、可让您指示输出段可拆分为不同的存储器范围、但前提是需要如下所述(我相信您已经知道):

    所以要回答您的问题、是的、因为链接器不会拆分这些段的一部分。

    参考资料: https://software-dl.ti.com/codegen/docs/tiarmclang/compiler_tools_user_guide/compiler_manual/ (特别是第 10.5.5 节和第 10.5.7 节)。

    如果有我没有解决的问题、请随时告诉我。