Skip to main content

How can I reduce my code footprint?

Question: How can I reduce the size of my compiled code?

Answer: Here are some suggestions:

  • Turn on compiler size optimization (for VS: "/O1", for gcc: "-Os").

  • Disable all debug flags: SoTP platform debug and compiler debug (for gcc, remove "-g").

  • Define __ENABLE_MOCANA_SMALL_CODE_FOOTPRINT__.

  • This will trade off some speed for a smaller size.

  • Disable unused ciphers such as 3DES or AES. AES may take about 10 KB because of lookup tables.

  • If supported by the compiler, use the option to link only with symbols that are being used.

  • Strip symbols from the generated binary.

  • Turn on the assembly language optimizations for the architecture, __ASM_*__.

  • For more information, refer to the "Footprint Reduction" and "Disable Certificate Parsing and Key Generation" sections of Building TrustCore SDK Components.