3.3.5.2 How Do I Stop An Unused Function Being Removed?
If a C function’s symbol is referenced in hand-written assembly code, the function will never be removed, even if it is not called or has never had its address taken in C code.
To include a reference, create an assembly source file and add this file to your project. You only have to reference the symbol in this file; so the file can contain the following
GLOBAL _myFunc
where myFunc
is the C name of the function in question
(note the leading underscore in the assembly name, see 5.12.3.3 Equivalent Assembly Symbols). This is sufficient to
prevent the function removal optimization from being performed.