radareorg/r2ghidra

SleightInit Non-existent context variable: TMode

Closed this issue · 2 comments

tried opening an ARM executable in r2 via r2 -a r2ghidra arm-binary and was met with

ERROR: Parse error @ line 171 (Invalid register type)
ERROR: Parse error @ line 171 (Invalid register type)
WARN: Cannot derive CC from reg profile
WARN: Missing calling conventions for 'r2ghidra' 64. Deriving it from the regprofile
ERROR: Parse error @ line 171 (Invalid register type)
WARN: Cannot derive CC from reg profile
WARN: Missing calling conventions for 'r2ghidra' 16. Deriving it from the regprofile
SleightInit Non-existent context variable: TMode
SleightInit Non-existent context variable: TMode
SleightInit Non-existent context variable: TMode

I then tried a simple pd and got stuck in a loop that constantly printed

[0x0000054c]> pd
SleightInit Non-existent context variable: TMode
SleightInit Non-existent context variable: TMode
SleightInit Non-existent context variable: TMode
SleightInit Non-existent context variable: TMode
SleightInit Non-existent context variable: TMode

similiar results happen if you instead just try to open visual mode.

unfortunately I don't think I will be able to shared the binary b/c of work related reasons however I can give you the following info on the binary
image

trufae commented

That's not how to use r2ghidra as a disassembler. Let me ellaborate:

  • -a -> sets asm.arch, this is, if you use r2ghidra asm plugin, it have no way to know which is the real arch unless you also set the asm.cpu configuration variable
  • add -e asm.cpu=arm
  • you are missing the -b32, otherwise it will default to the system bits configuration, which is probably 64.

Also, sleigh is like 100 times slower than capstone, so using r2ghidra as a disassembler is probably not the best to do. it works, but it's very slow and the esil constructions are far from perfect, so the emulation won't be as good as the one you get using the default arm plugin shipped in r2.

r2ghidra is basically 2 plugins

  • core plugin that provides pdg command for decompiling
  • anal plugin that provides disassembler facilities (this will be rewritten to an arch plugin soon)

I will try to take a look at the issue and improve the regprofile derivation function to get rid of the errors and provide a better output

trufae commented

Also, it's also possible to give r2ghidra a full sleigh id string, but r2ghidra should be able to build it by its own