Unused section elimination:
To control this optimization use the
--keep linker options.
Unused section elimination requires an entry point. Therefore, if there is no entry point
specified for an image, use the
--entry linker option to specify an entry
point and permit unused section elimination to work, if it is enabled.
--info unused linker option to instruct the linker to generate a
list of the unused sections that it eliminates.
An input section is retained in the final image when:
It contains an entry point.
It is referred to, directly or indirectly, by a non-weak reference from an input
section containing an entry point.
It is specified as the first or last input section by the
--last option (or a scatter-loading equivalent).
It is marked as unremovable by the
Compilers usually collect functions and data together and emit one
section for each category. The linker can only eliminate a section if it is entirely
You can mark a function or variable in source code with the
__attribute__((used)) attribute. This causes
armcc to generate the symbol
__tagsym$$used for each of the functions and variables. A section containing a
__tagsym$$used is not removed by unused
You can also use the
compiler command-line option to instruct the compiler to generate one ELF section for each
function in the source file.