Why do STM32 gcc linker scripts automatically discard all input sections from these standard libraries: libc.a, libm.a, libgcc.a?

ⅰ亾dé卋堺 提交于 2019-12-30 06:50:13

问题


From the bottom of any auto-generated STM32CubeMx-generated linker script:

/* Remove information from the standard libraries */
/DISCARD/ :
{
  libc.a ( * )
  libm.a ( * )
  libgcc.a ( * )
}

From the GNU Binutils ld (linker script) manual, 3.6.7 Output Section Discarding:

The special output section name ‘/DISCARD/’ may be used to discard input sections. Any input sections which are assigned to an output section named ‘/DISCARD/’ are not included in the output file.

What do these 3 input object files contain, and why do we discard everything (all input sections) from them?

Other STM32 linker script topics of interest:

  1. Is accessing the "value" of a linker script variable undefined behavior in C?
  2. How to get value of variable defined in ld linker script from C

来源:https://stackoverflow.com/questions/55621981/why-do-stm32-gcc-linker-scripts-automatically-discard-all-input-sections-from-th

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!