10.STACK FRAME
• When one function calls another, at the very least it needs somewhere to save the return address so the called function can return control when it finishes.
• The function also needs locations to save the parameters to be passed in to the called function and also possibly to save register values that it wishes to continue using when the called function returns.
• The called function also needs locations to save its local variables, somewhere different for every call so that it is possible for a function to call itself either directly or indirectly.
11.STACK FRAME
• One further piece of information then needed is some means of chaining these frames together, so that as a function is exiting it can restore the stack frame for the calling function before transferring control to the return address.
• All of these data are usually saved on the stack in a structure known as a stack frame.
• In most modern languages, including C, local variables are also stored in the function’s stack frame.
12.STACK FRAME
• Because the local variables are placed below the saved frame pointer and return address, the possibility exists of exploiting a local buffer variable overflow vulnerability to overwrite the values of one or both of these key function linkage values.
• This possibility of overwriting the saved frame pointer and return address forms the core of a stack overflow attack.