mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
ecf196fbea
32 changed files with 1773 additions and 773 deletions
|
@ -26,14 +26,14 @@ public enum TraceMemoryStatePcodeArithmetic implements PcodeArithmetic<TraceMemo
|
|||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public TraceMemoryState unaryOp(UnaryOpBehavior op, int sizeout, int sizein,
|
||||
public TraceMemoryState unaryOp(UnaryOpBehavior op, int sizeout, int sizein1,
|
||||
TraceMemoryState in1) {
|
||||
return in1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraceMemoryState binaryOp(BinaryOpBehavior op, int sizeout, int sizein,
|
||||
TraceMemoryState in1, TraceMemoryState in2) {
|
||||
public TraceMemoryState binaryOp(BinaryOpBehavior op, int sizeout, int sizein1,
|
||||
TraceMemoryState in1, int sizein2, TraceMemoryState in2) {
|
||||
if (in1 == TraceMemoryState.KNOWN && in2 == TraceMemoryState.KNOWN) {
|
||||
return TraceMemoryState.KNOWN;
|
||||
}
|
||||
|
|
|
@ -329,7 +329,6 @@ public class TracePcodeEmulatorTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
@Test
|
||||
public void testBRDS() throws Throwable {
|
||||
try (ToyDBTraceBuilder tb = new ToyDBTraceBuilder("Test", "Toy:BE:64:default")) {
|
||||
Assembler asm = Assemblers.getAssembler(tb.trace.getFixedProgramView(0));
|
||||
TraceThread thread = initTrace(tb,
|
||||
List.of(
|
||||
"pc = 0x00400000;",
|
||||
|
@ -630,4 +629,80 @@ public class TracePcodeEmulatorTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
TraceSleighUtils.evaluate("r1", tb.trace, 1, thread, 0));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test x86's MOVAPS instruction
|
||||
*
|
||||
* <p>
|
||||
* This test hits a SUBPIECE instruction where the two input operands have differing sizes.
|
||||
*/
|
||||
@Test
|
||||
public void testMOVAPS() throws Throwable {
|
||||
try (ToyDBTraceBuilder tb = new ToyDBTraceBuilder("Test", "x86:LE:64:default")) {
|
||||
Register pc = tb.language.getProgramCounter();
|
||||
|
||||
TraceThread thread = initTrace(tb,
|
||||
List.of(
|
||||
"RIP = 0x00400000;",
|
||||
"RSP = 0x00110000;",
|
||||
"*:8 0x00600008:8 = 0x0123456789abcdef;", // LE
|
||||
"*:8 0x00600000:8 = 0xfedcba9876543210;"),
|
||||
List.of(
|
||||
"MOVAPS XMM0, xmmword ptr [0x00600000]"));
|
||||
|
||||
TracePcodeEmulator emu = new TracePcodeEmulator(tb.trace, 0);
|
||||
PcodeThread<byte[]> emuThread = emu.newThread(thread.getPath());
|
||||
emuThread.overrideContextWithDefault();
|
||||
emuThread.stepInstruction();
|
||||
|
||||
assertEquals(tb.addr(0x00400007), emuThread.getCounter());
|
||||
assertArrayEquals(tb.arr(0x07, 0, 0x40, 0, 0, 0, 0, 0),
|
||||
emuThread.getState().getVar(pc));
|
||||
|
||||
try (UndoableTransaction tid = tb.startTransaction()) {
|
||||
emu.writeDown(tb.trace, 1, 1, false);
|
||||
}
|
||||
|
||||
assertEquals(new BigInteger("0123456789abcdeffedcba9876543210", 16),
|
||||
TraceSleighUtils.evaluate("XMM0", tb.trace, 1, thread, 0));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ( Test x86's SAR instruction
|
||||
*
|
||||
* <p>
|
||||
* This test hits an INT_SRIGHT p-code op where the two input operands have differing sizes.
|
||||
*/
|
||||
@Test
|
||||
public void testSAR() throws Throwable {
|
||||
try (ToyDBTraceBuilder tb = new ToyDBTraceBuilder("Test", "x86:LE:64:default")) {
|
||||
Register pc = tb.language.getProgramCounter();
|
||||
|
||||
TraceThread thread = initTrace(tb,
|
||||
List.of(
|
||||
"RIP = 0x00400000;",
|
||||
"RSP = 0x00110000;",
|
||||
"RAX = 0x7fffffff;",
|
||||
"RCX = 4;"),
|
||||
List.of(
|
||||
"SAR EAX, CL"));
|
||||
|
||||
TracePcodeEmulator emu = new TracePcodeEmulator(tb.trace, 0);
|
||||
PcodeThread<byte[]> emuThread = emu.newThread(thread.getPath());
|
||||
emuThread.overrideContextWithDefault();
|
||||
emuThread.stepInstruction();
|
||||
|
||||
assertEquals(tb.addr(0x00400002), emuThread.getCounter());
|
||||
assertArrayEquals(tb.arr(0x02, 0, 0x40, 0, 0, 0, 0, 0),
|
||||
emuThread.getState().getVar(pc));
|
||||
|
||||
try (UndoableTransaction tid = tb.startTransaction()) {
|
||||
emu.writeDown(tb.trace, 1, 1, false);
|
||||
}
|
||||
|
||||
assertEquals(BigInteger.valueOf(0x7ffffff),
|
||||
TraceSleighUtils.evaluate("RAX", tb.trace, 1, thread, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue