A mechanism is provided, where a post-build utility is used to store stack
and call tree information within a section of an executable program or
separate file. The stack information aids an authentication module during
the execution of the program in walking up a stack in order to obtain
return addresses on the stack. In one aspect of the invention, by
comparing the return address sequence to the call tree sequence, which
specifies the allowed function call sequence of the program, a
determination can be made whether the program is executing (as evidenced
by the stack) the way it should be executing (as required by the call
tree). If the call tree sequence differs from the return address
sequence, a suspicion is raised that a hacker is attempting to jump from
foreign code into sensitive code of the program by changing the function
calling sequence.