I can't seem to figure out why some printf
library functions get linked into my code from libc_nano.a even though I never use any printf
. It steals at least 2K of valuable flash memory space. I can see the sections _printf_i
, _vfprintf_r
, _vfiprintf_r
, etc. in my linker map file.
I tried
- Wl,--exclude-libs option
- EXCLUDE_FILE(..) in linker script
None of these make the symbols disappear 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 (re lease) [ARM/embedded-5-branch revision 231848] Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
First of all, why do they get linked? Is there any method to exclude them?
-nostdinc
and linking with-nostdlib
? – Jean-François Fabre♦