Something related to this that I found makes a big difference for me is the compiler switches:
-ffunction-sections -fdata-sections -Wl,--gc-sections
This puts every function and every data object into its own section. The -gc-sections link option then strips out sections that are not used. This happens even if they are global and appear in the same module (source file) as items that *are* used.
You also need to modify the link control file changing
*(.data) to *(.data.*) and *(.text) to *(.text.*)To pick up the modified section names.
Has anyone managed to make this work ?
I've tried on an FreeRTOS example where a header file [lib_AT91SAM7S256.h] with _MANY_ inline functions was included in a source file. In the MAP file I could see a reference to all of the functions from the header. That section alone took up ~3.5K.
Should'nt GCC be able to remove dead code from the executables ?
Cheers RaceMouse