mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
Merge remote-tracking branch
'origin/GP-3962_emteere_FuncBodyBranchIntoDelaySlot' into patch (Closes #5866)
This commit is contained in:
commit
740ed427de
2 changed files with 19 additions and 17 deletions
|
@ -218,6 +218,7 @@ public class InstructionDB extends CodeUnitDB implements Instruction, Instructio
|
|||
if (alignment < 1) {
|
||||
alignment = 1;
|
||||
}
|
||||
|
||||
do {
|
||||
// skip past delay slot instructions
|
||||
try {
|
||||
|
@ -228,8 +229,16 @@ public class InstructionDB extends CodeUnitDB implements Instruction, Instructio
|
|||
catch (AddressOverflowException e) {
|
||||
return null;
|
||||
}
|
||||
// if an instruction is in a delay slot and has references to it,
|
||||
// consider this the fallfrom instruction
|
||||
if (instr != null && instr.isInDelaySlot() && instr.hasFallthrough()) {
|
||||
if (program.getSymbolTable().hasSymbol(instr.getMinAddress())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (instr != null && instr.isInDelaySlot());
|
||||
|
||||
if (instr == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -349,6 +349,10 @@ public class FollowFlow {
|
|||
}
|
||||
}
|
||||
|
||||
// Delay adding instructions in delay slots to the functions body
|
||||
// until the end. This allows for branches into the delay slot to be handled correctly.
|
||||
AddressSet delaySlotSet = new AddressSet();
|
||||
|
||||
while (!monitor.isCancelled() && !instructionStack.isEmpty()) {
|
||||
|
||||
codeUnit = instructionStack.pop();
|
||||
|
@ -368,35 +372,24 @@ public class FollowFlow {
|
|||
continue;
|
||||
}
|
||||
|
||||
// If code unit is a delay-slot instruction, backup to delayed instruction
|
||||
Instruction instr = currentInstr;
|
||||
// while (instr.isInDelaySlot()) {
|
||||
// Address fallFrom = instr.getFallFrom();
|
||||
// if (fallFrom == null) {
|
||||
// // assumes delay slot instructions have no flow
|
||||
// flowAddressSet.addRange(instr.getMinAddress(),
|
||||
// currentInstr.getMaxAddress());
|
||||
// break;
|
||||
// }
|
||||
// instr = program.getListing().getInstructionContaining(fallFrom);
|
||||
// }
|
||||
// if (instr.isInDelaySlot())
|
||||
// continue; // unable to find non-delay-slot instruction
|
||||
// currentInstr = instr;
|
||||
|
||||
// handle instruction - include associated delay slot instructions
|
||||
// handle instruction with delay slot instructions
|
||||
Address end = instr.getMaxAddress();
|
||||
int delaySlotDepth = instr.getDelaySlotDepth();
|
||||
for (int i = 0; i < delaySlotDepth; i++) {
|
||||
instr = instr.getNext();
|
||||
if (instr == null)
|
||||
break;
|
||||
end = instr.getMaxAddress();
|
||||
delaySlotSet.add(instr.getMinAddress(),instr.getMaxAddress());
|
||||
}
|
||||
flowAddressSet.addRange(currentInstr.getMinAddress(), end);
|
||||
followInstruction(instructionStack, flowAddressSet, currentInstr);
|
||||
|
||||
}
|
||||
|
||||
// add in any instructions that were in a delayslot
|
||||
flowAddressSet.add(delaySlotSet);
|
||||
} // followCode
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue