Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2022-12-21 10:53:32 -05:00
commit 8c304d01be
4 changed files with 32 additions and 11 deletions

View file

@ -43,6 +43,11 @@ public class EndInstructionValueSolver extends AbstractExpressionSolver<EndInstr
AssemblyResolvedPatterns cur, Set<SolverHint> hints, String description) {
throw new AssertionError(
"INTERNAL: Should never be asked to solve for " + AssemblyTreeResolver.INST_NEXT);
/**
* I suppose we could instead throw NeedsBackfillExcpeiton(INST_NEXT) here, too, but this
* serves as a sanity check on the SLEIGH spec. I can't think of a good reason to try to
* solve INST_NEXT == const.
*/
}
@Override

View file

@ -19,7 +19,7 @@ import java.util.Map;
import java.util.Set;
import ghidra.app.plugin.assembler.sleigh.sem.*;
import ghidra.app.plugin.processors.sleigh.expression.EndInstructionValue;
import ghidra.app.plugin.processors.sleigh.expression.Next2InstructionValue;
/**
* "Solves" expressions of {@code inst_next2}
@ -32,21 +32,22 @@ import ghidra.app.plugin.processors.sleigh.expression.EndInstructionValue;
* <b>NOTE:</b> This solver requires backfill, since the value of {@code inst_next2} is not known
* until possible prefixes have been considered.
*/
public class Next2InstructionValueSolver extends AbstractExpressionSolver<EndInstructionValue> {
public class Next2InstructionValueSolver extends AbstractExpressionSolver<Next2InstructionValue> {
public Next2InstructionValueSolver() {
super(EndInstructionValue.class);
super(Next2InstructionValue.class);
}
@Override
public AssemblyResolution solve(EndInstructionValue iv, MaskedLong goal, Map<String, Long> vals,
public AssemblyResolution solve(Next2InstructionValue iv, MaskedLong goal,
Map<String, Long> vals,
AssemblyResolvedPatterns cur, Set<SolverHint> hints, String description) {
throw new AssertionError(
"INTERNAL: Should never be asked to solve for " + AssemblyTreeResolver.INST_NEXT2);
}
@Override
public MaskedLong getValue(EndInstructionValue iv, Map<String, Long> vals,
public MaskedLong getValue(Next2InstructionValue iv, Map<String, Long> vals,
AssemblyResolvedPatterns cur) throws NeedsBackfillException {
Long instNext = vals.get(AssemblyTreeResolver.INST_NEXT2);
if (instNext == null) {
@ -56,12 +57,12 @@ public class Next2InstructionValueSolver extends AbstractExpressionSolver<EndIns
}
@Override
public int getInstructionLength(EndInstructionValue iv) {
public int getInstructionLength(Next2InstructionValue iv) {
return 0;
}
@Override
public MaskedLong valueForResolution(EndInstructionValue exp, Map<String, Long> vals,
public MaskedLong valueForResolution(Next2InstructionValue exp, Map<String, Long> vals,
AssemblyResolvedPatterns rc) {
Long instNext = vals.get(AssemblyTreeResolver.INST_NEXT2);
if (instNext == null) {

View file

@ -121,4 +121,19 @@ public class ARMAssemblyTest extends AbstractAssemblyTest {
assertOneCompatRestExact("vmov.i64 d0,simdExpand(0x1,0xe,0xb1)", "83:ff:31:0e", THUMB,
0x00010100, "vmov.i64 d0,simdExpand(0x1,0xe,0xb1)");
}
@Test
public void testAssemble_T_tbb_mr0_r1() {
assertOneCompatRestExact("tbb [r0, r1]", "d0:e8:01:f0", THUMB, 0x00400000, "tbb [r0,r1]");
}
@Test
public void testAssemble_T_tbb_mpc_r0() {
assertOneCompatRestExact("tbb [pc, r1]", "df:e8:01:f0", THUMB, 0x00400000, "tbb [pc,r1]");
}
@Test
public void testAssemble_T_tbb_m0_r0() {
assertAllSyntaxErrors("tbb [0, r0]");
}
}