toolCHAINZ / jingle

SMT Modeling for Ghidra's PCODE
MIT License
8 stars 1 forks source link

Add API for CallOther Name #9

Open toolCHAINZ opened 2 weeks ago

toolCHAINZ commented 2 weeks ago

sleigh has some internal mechanism for querying the name associated with a callother id. Need to find this API and expose it to rust.

chf0x commented 2 weeks ago

Found it here, but I am not sure is it part of sleigh?

https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra/Features/Decompiler/src/decompile/cpp/userop.hh#L339

and it is populated here:

https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra/Features/Decompiler/src/decompile/cpp/sleighbase.cc#L101

can be accessed from:

https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra/Features/Decompiler/src/decompile/cpp/architecture.hh#L209

Locally, I implemented name extraction by retrieving the actual analyzed instruction mnemonic and using it as the callother name. Do you think we still need an API for the callother name when it can be extracted this way?

//I'd like to confirm that the first parameter of the input is indeed the callother ID.

toolCHAINZ commented 2 weeks ago

Poked around at what you found (thanks!) and it looks like the sleigh context has this helper function:

https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra%2FFeatures%2FDecompiler%2Fsrc%2Fdecompile%2Fcpp%2Ftranslate.hh#L391-L399

So we could add that in to the FFI and expose that mapping to rust. It looks like the op ids are assumed to be sequential, without gaps, and are assigned programmatically by sleigh when it parses the user ops from the spec.