ghidra icon indicating copy to clipboard operation
ghidra copied to clipboard

[Sleigh, Decompiler (Java)] Maximum number of operands is 8

Open lab313ru opened this issue 2 years ago • 3 comments

My sleigh implementation has pseudo opcodes with 8 and more operands. Decompiler can't deal with that and prints an error:

ERROR Pcode error at ram:00002754: Index 8 out of bounds for length 8 (SleighInstructionPrototype)  

Problematic line is here: https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/PcodeEmit.java#L133

lab313ru avatar Jul 20 '21 19:07 lab313ru

This could probably just be changed to an ArrayList.

astrelsky avatar Jul 22 '21 11:07 astrelsky

~~Unfortunately this seems to be more involved than just changing it to a List. Maybe it has something to do with all the magic numbers in PcodeEmitPacked and this area of code in general?~~

~~I might have missed something that would cause (SleighInstructionPrototype) Pcode error at 1400ec540: Index 0 out of bounds for length 0. I'll probably look again this weekend.~~

Edit: I think I found the problem now that I'm looking at it with a clearer head. I was using List<E>.set(int, E) instead ofList<E>.add(int, E) which would cause an index out of bounds error. I'll fix it and retest tonight since I have a long drive this morning.

Edit edit: that was it.

astrelsky avatar Jul 22 '21 23:07 astrelsky

Any updates? I see many useful solutions, but no one is merged yet!

lab313ru avatar Jun 09 '23 23:06 lab313ru