keep directive
Syntax
keep { [ {section-selectors| blockname} [ , {section-selectors| blockname}... ] ] } [ except {section-selectors} ];
For information about selectors and except clauses, see Section selection.
Description
The keep directive can be used for including blocks, overlays, or sections in the executable image that would otherwise be discarded because no references to them exist in the included parts of the application. Note that this directive always causes entire input sections to be included, and not just the relevant section fragment, when matching against a symbol name.
Furthermore, only sections from included modules are considered. The keep directive does not cause any additional modules to be included in your application.
To cause a module that defines a specific symbol to be included, or only the section fragment that defines a symbol, use the Keep symbols linker option (or the ‑‑keep option on the command line), or the linker directive keep symbol.
Example
keep { section .keep* } except {section .keep};