【问题标题】:Linker Scripts: Can I specify (*COMMON) in more than one section?链接器脚本:我可以在多个部分中指定 (*COMMON) 吗?
【发布时间】:2021-09-01 14:54:24
【问题描述】:

如果我的链接描述文件中有两个部分,.bss 和 .newsect,我可以像下面那样在两个部分都包含 (*COMMON) 吗?为什么或为什么不?


  .bss :
  {
    /* This is used by the startup in order to initialize the .bss section */
    _sbss = .;         /* define a global symbol at bss start */
    __bss_start__ = _sbss;
    *(.bss)
    *(.bss*)
    *(COMMON)

    . = ALIGN(4);
    _ebss = .;         /* define a global symbol at bss end */
    __bss_end__ = _ebss;
  } >RAM_D1

  .newsect :
  {
    /* This is used by the startup in order to initialize the .bss section */
    _snewsect = .;         /* define a global symbol at bss start */
    __newsect_start__ = _snewsect;
    *(.newsect)
    *(.newsect*)
    *(COMMON)

    . = ALIGN(4);
    _enewsect = .;         /* define a global symbol at bss end */
    __newsect_end__ = _enewsect;
  } >RAM_D1


【问题讨论】:

    标签: gcc stm32 gnu cortex-m linker-scripts


    【解决方案1】:

    这不会造成任何伤害,但是在您第一次指定它们时,所有匹配的输入节都已分配给输出节,因此第二次将不会匹配任何内容,也不会执行任何操作。

    【讨论】:

    • @Ryan Murphy,如果这能解决您的问题,您能否接受带有左侧勾号的答案。
    猜你喜欢
    • 2016-11-26
    • 2011-09-09
    • 1970-01-01
    • 1970-01-01
    • 2021-08-08
    • 2014-08-21
    • 2019-11-28
    • 2023-03-12
    • 2023-03-08
    相关资源
    最近更新 更多