-Wl,
--gc-sections
Garbage collects unused sections.
Enable garbage collection of unused input sections. It is ignored on targets that do not support this option.
The default behavior (of not performing this garbage
collection) can be restored by specifying −−no−gc−sections
on
the command-line. --gc-sections
decide which input sections are
used by examining symbols and relocations. The section containing the entry
symbol and all sections containing symbols undefined on the command-line will be
kept, as will sections containing symbols referenced by dynamic
objects.