7

I have been starting to use Ghidra and I find the decompiler view very useful. However, when I rename a variable, the name propagates through all uses of that register or stack pointer throughout the function. In most cases this is good, however often when the variable is stored in a register, the same register will be used to store a different variable later in the function.

My question is: Is there a way to only rename a variable in a function below the current line? This way, later uses of said register will have the correct variable name.

5

This is a feature that isn't in the current (March 2020) release (9.1.2) and requires at least the commit https://github.com/NationalSecurityAgency/ghidra/commit/885402bbc3618b895c4b9b8f09300d3120a9abe8

This will most like be contained in the 9.2 release, for now you would need to build from master.

For registers you can do it:

Right click in the Decompiler → Commit Locals.
Right click on the variable → Split out as New Variable.

as per https://github.com/NationalSecurityAgency/ghidra/issues/975#issuecomment-593425470 in the issue that Jeff Muizelaar mentioned.

According to https://github.com/NationalSecurityAgency/ghidra/issues/1510#issuecomment-582052718 this only really works well for registers currently, but should also work for Stack variables.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.