Clearing all temporary variables of functions after execution

Akif Ozkan
  • Akif Ozkan
    Akif Ozkan


    I want to clear all temporary and local variables after execution of a function so as not to leave a trace.

    I think clearing registers, local variables could easily be done by assigning them to 0.

    Hovewer, Althhough I use these linker options
    #pragma nogcse
    #pragma noinduction
    ASM produces some temporary variables like:

    Also, I ask the solution to temporary variables.

    Do I miss anything else that a function could use?
    How can I be sure that function clears everything it used?

    Thanks in advance.

  • Maarten Brock
    Maarten Brock

    You can clear the registers by using inline assembly.
    And if you make the function __reentrant all local and temporary variables will be placed on the stack. Again in assembly you can clear everything between BP+1 and SP.