ghidra icon indicating copy to clipboard operation
ghidra copied to clipboard

Sleigh userop 'LOCK' is not in the library

Open astrelsky opened this issue 9 months ago • 3 comments

Describe the bug Basic x86 instructions such as XCHG cannot be emulated

To Reproduce Steps to reproduce the behavior:

  1. Attempt to step through the x86 XCHG instruction.
  2. See error

Expected behavior Basic instructions should be emulatable in the GUI. Especially ones that are fundamentally a no op as far as emulation is concerned.

Environment (please complete the following information):

  • Ghidra Version: 11.3 and 11.4_DEV

astrelsky avatar Feb 13 '25 12:02 astrelsky

So the more general solution to this problem is currently in progress. At the moment, you can use a script to install a handler for LOCK, at which point the GUI becomes capable of emulating the affected instructions. I believe this is documented in the "Modeling" section of the Debugger course. I can't find the original issue, but I believe this same question was asked of the ARM (maybe AARCH64) emulator, so I imagine this ask is still about making it easier, i.e., no scripts.

As for the upcoming solution, we're essentially re-working the EmulateStateModifier thing. Each pspec file will name one or more PcodeUseropLibraries to incorporate into the emulator by default. We have some existing modifiers to port over first, and then we plan to go after the common processors to ensure their userops all have some default handler.

nsadeveloper789 avatar Feb 13 '25 15:02 nsadeveloper789

Found the other issue: https://github.com/NationalSecurityAgency/ghidra/issues/6089

nsadeveloper789 avatar Feb 13 '25 15:02 nsadeveloper789

So the more general solution to this problem is currently in progress. At the moment, you can use a script to install a handler for LOCK, at which point the GUI becomes capable of emulating the affected instructions. I believe this is documented in the "Modeling" section of the Debugger course. I can't find the original issue, but I believe this same question was asked of the ARM (maybe AARCH64) emulator, so I imagine this ask is still about making it easier, i.e., no scripts.

As for the upcoming solution, we're essentially re-working the EmulateStateModifier thing. Each pspec file will name one or more PcodeUseropLibraries to incorporate into the emulator by default. We have some existing modifiers to port over first, and then we plan to go after the common processors to ensure their userops all have some default handler.

Ok. I took the simplest solution for now and just removed all the LOCK and UNLOCK calls from the sleigh files. So now it just runs up until it fails for an unrelated reason that I can solve so I won't be emulating it anyway.

astrelsky avatar Feb 13 '25 18:02 astrelsky