Skip to content

Commit

Permalink
Merge branch 'ptomin-fix-slice-mem-rule'
Browse files Browse the repository at this point in the history
  • Loading branch information
uxmal committed Jan 15, 2024
2 parents 454d053 + 42463e0 commit 13c3481
Show file tree
Hide file tree
Showing 21 changed files with 606 additions and 594 deletions.
2 changes: 1 addition & 1 deletion src/Decompiler/Evaluation/SliceMem_Rule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public SliceMem_Rule()
if (0 <= bitBegin && bitEnd <= acc.DataType.BitSize)
{
//$REVIEW: endianness?
offset = op.ApplyConstants(offset.DataType, offset, Constant.Create(ea.DataType, slice.Offset / ctx.MemoryGranularity));
offset = op.ApplyConstants(offset.DataType, offset, Constant.Create(offset.DataType, slice.Offset / ctx.MemoryGranularity));
Expression newEa = new BinaryExpression(op, offset.DataType, ea, offset);
if (segptr is not null)
{
Expand Down
13 changes: 13 additions & 0 deletions src/UnitTests/Decompiler/Evaluation/ExpressionSimplifierTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,5 +1314,18 @@ public void Exs_Eq_false()

Assert.AreEqual("!c_3", exp.ToString());
}

[Test]
public void Exs_SliceMemPtrIdPlusIntConst()
{
Given_ExpressionSimplifier();
var id = Given_Tmp("id", PrimitiveType.Ptr32);
Expression exp = m.Slice(
m.Mem(PrimitiveType.Word64, m.IAdd(id, m.Word32(1))),
PrimitiveType.Word32, 8);
exp = RunExpressionSimplifier(exp);

Assert.AreEqual("Mem0[id_3 + 2<32>:word32]", exp.ToString());
}
}
}
Loading

0 comments on commit 13c3481

Please sign in to comment.