Local variables could be stored on the stack, but not necessarily. If there is only a small number of variables that fit into registers, and the code is optimized, then local variables are never stored on the stack. Depending on the conditional convention used, the final values ββof local variables may be stored in registers.
Parse this function (you can use objdump -dS so you can easily map the source). See how local variables were available. Have they been stored in memory or registers? Have registers already been restored to their value relevant to the caller?
If the original register value was not restored, you can simply examine the register that was used to store the local one. If it has already been restored, it is probably lost.
If local values ββwere saved onto the stack, then the prolog function (first instructions) should tell you how to manipulate the stack pointer and the frame. Taking into account that the call is also saved on the stack (PC saved), you can calculate the value of the stack / frame pointer used in this function. Then use x to view memory locations.
Depending on the function being called, you can also examine its arguments (when called) and recalculate the value of local variables.
source share