ghidra
ghidra copied to clipboard
Change default behavior when emulating in new trace to set the current context's stack pointer
Current behavior
When setting registers at an address 0x08049196 in the register manager, the emulator will apply those registers when I Emulate program in new trace at that address. All general purpose registers will be applied except for the stack pointer.
By default the stack pointer will be set to some arbitrary value. In this example, it's set to 0x5000 but my register manager has the stack pointer set to 0xffffd2bc. The address 0xffffd2bc is inside a valid and initialized block in my Memory map.
Desired behavior When starting the emulator at an address that has the stack pointer set in the register manager, I'd like the emulator to use that stack pointer by default, rather than having to manually editing the stack pointer after I start the new trace
That's a decent idea.
FWIW, an alternative is to create an uninitialized block called "STACK" in the Memory Map. The SP should get initialized to the highest address (maybe +1) in that block. Granted, that winds up applying to the entire program rather than just the specific function.