It does not delete dead code unless you say it. To do this, you need to compile everything with:
-fdata-sections -ffunction-sections
to mark all data and functions. And when you contact GCC, you need to pass:
-Wl, - gc-sections
so that garbage collects all unused partitions.
source share