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

后端 未结 1 731
别跟我提以往
别跟我提以往 2021-01-02 03:35

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

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


        
相关标签:
1条回答
  • 2021-01-02 04:02

    Looks like in this example, /DISCARD/ removes any other sections, that are not explicitly defined by script. For example, since *(.text), *(.data), *(.bss), *(.init_array) etc, has been defined earlier in the script, they get into the ELF. But libc, libm or libgcc could contain unnecessary sections for firmware (e.g. .foo, .bar, .debug ...), so /DISCARD/ just wipes them out, but NOT all sections!

    0 讨论(0)
提交回复
热议问题