Unverified Commit 44a194f7 by Melvin Klimke Committed by GitHub

- Fixed issue #169 (#171)

parent 41088680
......@@ -214,11 +214,16 @@ public class PcodeExtractor extends GhidraScript {
*/
protected Boolean iteratePcode() {
int numberOfPcodeOps = PcodeBlockData.ops.length;
int previousPcodeIndex = 0;
Boolean intraInstructionJumpOccured = false;
PcodeBlockData.pcodeIndex = 0;
for(PcodeOp op : PcodeBlockData.ops) {
PcodeBlockData.pcodeOp = op;
String mnemonic = PcodeBlockData.pcodeOp.getMnemonic();
if (previousPcodeIndex < PcodeBlockData.pcodeIndex -1) {
numberOfPcodeOps++;
}
previousPcodeIndex = PcodeBlockData.pcodeIndex;
if (JumpProcessing.jumps.contains(mnemonic) || PcodeBlockData.pcodeOp.getOpcode() == PcodeOp.UNIMPLEMENTED) {
intraInstructionJumpOccured = JumpProcessing.processJump(mnemonic, numberOfPcodeOps);
} else {
......
......@@ -45,7 +45,7 @@ public final class JumpProcessing {
return processJumpInPcodeBlock(mnemonic, numberOfPcodeOps, currentBlock);
}
processJumpAtEndOfPcodeBlocks(mnemonic, numberOfPcodeOps, currentBlock);
processJumpAtEndOfPcodeBlocks(mnemonic, currentBlock);
return false;
}
......@@ -53,13 +53,12 @@ public final class JumpProcessing {
/**
*
* @param mnemonic: pcode mnemonic
* @param numberOfPcodeOps: number of pcode instruction in pcode block
* @param currentBlock: current block term
*
* Process jumps at the end of pcode blocks
* If it is a return block, the call return address is changed to the current block
*/
private static void processJumpAtEndOfPcodeBlocks(String mnemonic, int numberOfPcodeOps, Term<Blk> currentBlock) {
private static void processJumpAtEndOfPcodeBlocks(String mnemonic, Term<Blk> currentBlock) {
// Case 1: jump at the end of pcode group but not end of ghidra generated block. Create a block for the next assembly instruction.
if(PcodeBlockData.instructionIndex < PcodeBlockData.numberOfInstructionsInBlock - 1 && PcodeBlockData.instruction.getDelaySlotDepth() == 0) {
PcodeBlockData.blocks.add(TermCreator.createBlkTerm(PcodeBlockData.instruction.getFallThrough().toString(), null));
......
......@@ -348,8 +348,12 @@ public class TermCreator {
callString = "unimplemented";
call = new Call(null, createLabel(PcodeBlockData.instruction.getFallThrough()), callString);
} else {
if (PcodeBlockData.instruction.getFallThrough() == null) {
call = new Call(createLabel(null));
} else {
call = new Call(createLabel(null), createLabel(PcodeBlockData.instruction.getFallThrough()));
}
}
return call;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment