mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-21 14:45:07 +08:00
Merge remote-tracking branch 'origin/GP-0_d-millar_test_fixes--SQUASHED'
This commit is contained in:
+15
-17
@@ -129,24 +129,28 @@ public enum TaintPcodeArithmetic implements PcodeArithmetic<TaintVec> {
|
||||
*/
|
||||
@Override
|
||||
public TaintVec binaryOp(PcodeOp op, TaintVec in1, TaintVec in2) {
|
||||
return PcodeArithmetic.super.binaryOp(op, in1, in2).withOp(op);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaintVec binaryOp(int opcode, int sizeout, int sizein1, TaintVec in1,
|
||||
int sizein2, TaintVec in2) {
|
||||
// TODO: Detect immediate operands and be more precise
|
||||
switch (op.getOpcode()) {
|
||||
switch (opcode) {
|
||||
case PcodeOp.INT_XOR, PcodeOp.INT_SUB, PcodeOp.BOOL_XOR -> {
|
||||
if (Objects.equals(op.getInput(0), op.getInput(1))) {
|
||||
return fromConst(0, op.getOutput().getSize()); // NB: withOp unneeded, as this essentially removes taint
|
||||
if (Objects.equals(in1, in2)) {
|
||||
return fromConst(0, sizeout); // NB: withOp unneeded, as this essentially removes taint
|
||||
}
|
||||
}
|
||||
}
|
||||
int sizein2 = op.getInput(1).getSize();
|
||||
int sizeout = op.getOutput().getSize();
|
||||
return switch (op.getOpcode()) {
|
||||
return switch (opcode) {
|
||||
case PcodeOp.BOOL_AND, PcodeOp.BOOL_OR, PcodeOp.BOOL_XOR, PcodeOp.INT_AND, //
|
||||
PcodeOp.INT_OR, PcodeOp.INT_XOR -> {
|
||||
yield in1.zipUnion(in2).withOp(op);
|
||||
yield in1.zipUnion(in2);
|
||||
}
|
||||
case PcodeOp.INT_ADD, PcodeOp.INT_SUB -> {
|
||||
TaintVec temp = in1.zipUnion(in2);
|
||||
yield temp.setCascade(endian.isBigEndian()).withOp(op);
|
||||
yield temp.setCascade(endian.isBigEndian());
|
||||
}
|
||||
case PcodeOp.INT_SLESS, PcodeOp.INT_SLESSEQUAL, //
|
||||
PcodeOp.INT_LESS, PcodeOp.INT_LESSEQUAL, //
|
||||
@@ -154,26 +158,20 @@ public enum TaintPcodeArithmetic implements PcodeArithmetic<TaintVec> {
|
||||
PcodeOp.FLOAT_LESS, PcodeOp.FLOAT_LESSEQUAL, //
|
||||
PcodeOp.FLOAT_EQUAL, PcodeOp.FLOAT_NOTEQUAL -> {
|
||||
TaintSet temp = in1.union().union(in2.union());
|
||||
yield TaintVec.copies(temp, sizeout).withOp(op);
|
||||
yield TaintVec.copies(temp, sizeout);
|
||||
}
|
||||
case PcodeOp.PIECE -> {
|
||||
TaintVec temp = in1.extended(sizeout, endian.isBigEndian(), false);
|
||||
temp.setShifted(endian.isBigEndian() ? -sizein2 : sizein2, ShiftMode.UNBOUNDED);
|
||||
yield temp.set(endian.isBigEndian() ? sizeout - sizein2 : 0, in2).withOp(op);
|
||||
yield temp.set(endian.isBigEndian() ? sizeout - sizein2 : 0, in2);
|
||||
}
|
||||
default -> {
|
||||
TaintVec temp = in1.zipUnion(in2).truncated(sizeout, endian.isBigEndian());
|
||||
yield temp.setCopies(temp.union()).withOp(op);
|
||||
yield temp.setCopies(temp.union());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaintVec binaryOp(int opcode, int sizeout, int sizein1, TaintVec in1,
|
||||
int sizein2, TaintVec in2) {
|
||||
throw new RuntimeException("Not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
||||
+3
-4
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package ghidra.pcode.emu.taint.trace;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -236,7 +235,7 @@ public class TaintTracePcodeEmulatorTest extends AbstractTracePcodeEmulatorTest
|
||||
assertEquals(makeTaintEntries(tb.trace, Lifespan.at(1), ram, Set.of(
|
||||
0x00600000L, 0x00600001L, 0x00600002L, 0x00600003L,
|
||||
0x00600004L, 0x00600005L, 0x00600006L, 0x00600007L),
|
||||
"test_0"),
|
||||
"test_0@(ram, 0x400000, 0, 0)"),
|
||||
Set.copyOf(taintMap.getEntries(
|
||||
Lifespan.at(1), tb.range(0x00600000, 0x00600007))));
|
||||
}
|
||||
@@ -366,7 +365,7 @@ public class TaintTracePcodeEmulatorTest extends AbstractTracePcodeEmulatorTest
|
||||
assertEquals(makeTaintEntries(tb.trace, Lifespan.at(1), ram, Set.of(
|
||||
0x20000000L, 0x20000001L, 0x20000002L, 0x20000003L,
|
||||
0x20000004L, 0x20000005L, 0x20000006L, 0x20000007L),
|
||||
"test_0"),
|
||||
"test_0@(ram, 0x400000, 0, 0)"),
|
||||
Set.copyOf(taintMap.getEntries(
|
||||
Lifespan.at(1), tb.range(0x20000000, 0x20000007))));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user