3.3.5.2 How Do I Stop An Unused Function Being Removed?

The __attribute__((keep,used)) may be applied to a function. The keep attribute tells the compiler to put the function into a section that won't be removed by the linker, even if the --gc-sections option is used to perform garbage collection. The used attribute stops the compiler from applying optimizations that would remove the function. It also suppresses warnings related to unused functions.