title: STM32 gcc (arm-none-eabi-gcc) links printf even though it is not used
body: <p>I can't seem to figure out why some <code>printf</code> library functions get linked into my code from libc_nano.a even though I never use any <code>printf</code>. It steals at least 2K of valuable flash memory space. I can see the sections <code>_printf_i</code>, <code>_vfprintf_r</code>, <code>_vfiprintf_r</code>, etc. in my linker map file.</p>
  
  <p>I tried </p>
  
  <ul>
  <li>Wl,--exclude-libs option</li>
  <li>EXCLUDE_FILE(..) in linker script</li>
  </ul>
  
  <p>None of these make the symbols disappear from the map file..</p>
  
  <p>My gcc options:</p>
  
  <pre><code>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 
  </code></pre>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>First of all, why do they get linked?
  Is there any method to exclude them?</p>