8

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.

1

1 Answer 1

8

As of 2020.11.13 the 9.2 release is available which includes this feature.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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