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.

genghiskhan
  • 378
  • 2
  • 10

1 Answers1

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.

Florian Magin
  • 1,444
  • 6
  • 22