| |||
| Home > Using the Basic Linker Functionality > Optimizations and modifications > Unused section elimination | |||
Unused section elimination removes code that is never executed,
or data that is not referred to by the code, from the final image.
This optimization can be controlled by the --remove, --no_remove, --first, --last,
and --keep linker options. Use the --info
unused linker option to instruct the linker to generate
a list of the unused sections that have been eliminated.
Unused section elimination is suppressed in those cases that might result in the removal of all sections.
An input section is retained in the final image under the following conditions:
if it contains an entry point
if it is referred to, directly or indirectly, by a non-weak reference from an input section containing an entry point
if it was specified as the first or last input section
by the --first or --last option (or
a scatter-loading equivalent)
if it has been marked as unremovable by the --keep option.
Unused section elimination is a property of all groups, not just common groups.