STM32 gcc (arm-none-eabi-gcc) binds printf, although it is not used

I can’t understand why some library functions printfare related to my code from libc_nano.a, although I never use it printf. He steals at least 2 thousand valuable flash memory. I see sections _printf_i, _vfprintf_r, _vfiprintf_retc. In the link builder file.

I tried

  • Wl, - exclude-libs option
  • EXCLUDE_FILE (..) in the script builder

None of them will lead to the disappearance of characters from the map file.

My gcc options:

CFLAGS = -Og -Wall -g3 -Wdouble-promotion -mcpu=cortex-m0 -mthumb -fmessage-length=0 -ffunction-sections -mfloat-abi=soft -DUSE_HAL_DRIVER

LFLAGS = -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -specs=nosys.specs -specs=nano.specs -Wl,--gc-sections 

arm-none-eabi-gcc.exe (GNU Tools for ARM Embedded Processors) 5.2.1 20151202 (rental) [ARM version / embedded-5-branch 231848] Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see source for copy conditions. There is no guarantee; even for COMMERCIAL VALUE OR FITNESS FOR A PARTICULAR PURPOSE.

First of all, why are they related? Is there any way to exclude them?

+4
source share
1 answer

Tell the linker to create the link: -Wl,--cref

- cref

. , . . , script . , . , . , . .

, , .

grep -A5 _printf *.map

, printf .

+5

Source: https://habr.com/ru/post/1656717/


All Articles