thumbMode test must happen before expectedPC test. the other way around and some strongarm
functions do not work as expected
This commit is contained in:
JetSetIlly 2024-04-30 17:29:39 +01:00
parent ed8f7d6318
commit 545caefbfa

View file

@ -957,6 +957,18 @@ func (arm *ARM) decodeThumbHiRegisterOps(opcode uint16) decodeFunction {
}
}
// if we're still in thumb mode the instruction has ended
//
// the position of this test is important, particularly for ELF
// binaries and how the BLX instruction at the end of strongarm
// functions have been constructed
if thumbMode {
// "7.6 Data Operations" in "ARM7TDMI-S Technical Reference Manual r4p3"
// - fillPipeline() will be called if necessary
arm.state.registers[rPC] = newPC
return nil
}
// if the PC is now the same as the expected return address then the
// ARM program has ended and we can yield with the YieldProgramEnded
// type
@ -970,14 +982,6 @@ func (arm *ARM) decodeThumbHiRegisterOps(opcode uint16) decodeFunction {
return nil
}
// if we're still in thumb mode the instruction has ended
if thumbMode {
// "7.6 Data Operations" in "ARM7TDMI-S Technical Reference Manual r4p3"
// - fillPipeline() will be called if necessary
arm.state.registers[rPC] = newPC
return nil
}
// NOTE: the remainder of the instruction handles ARM interrupts.
// note that this hasn't been tested with ARMv7_M processor types.
// this type of processor does not have 32bit instructions so may