miasm
Reverse engineering framework
unssa Namespace Reference

Classes

class  Arch
 
class  CustomIRCFGSimplifierSSA
 
class  IRAOutRegs
 
class  IRATest
 
class  Regs
 

Functions

def gen_irblock (label, exprs_list)
 
def add_out_reg_end (ir_arch_a, ircfg_a)
 

Variables

 loc_db = LocationDB()
 
 a = ExprId("a", 32)
 
 b = ExprId("b", 32)
 
 c = ExprId("c", 32)
 
 d = ExprId("d", 32)
 
 r = ExprId("r", 32)
 
 x = ExprId("x", 32)
 
 y = ExprId("y", 32)
 
 u8 = ExprId("u8", 8)
 
 zf = ExprId('zf', 1)
 
 a_init = ExprId("a_init", 32)
 
 b_init = ExprId("b_init", 32)
 
 c_init = ExprId("c_init", 32)
 
 d_init = ExprId("d_init", 32)
 
 r_init = ExprId("r_init", 32)
 
 pc = ExprId("pc", 32)
 
 sp = ExprId("sp", 32)
 
 CST0 = ExprInt(0x0, 32)
 
 CST1 = ExprInt(0x1, 32)
 
 CST2 = ExprInt(0x2, 32)
 
 CST3 = ExprInt(0x3, 32)
 
 CSTX_8 = ExprInt(12, 8)
 
 LBL0 = loc_db.add_location("lbl0", 0)
 
 LBL1 = loc_db.add_location("lbl1", 1)
 
 LBL2 = loc_db.add_location("lbl2", 2)
 
 LBL3 = loc_db.add_location("lbl3", 3)
 
 LBL4 = loc_db.add_location("lbl4", 4)
 
 LBL5 = loc_db.add_location("lbl5", 5)
 
 LBL6 = loc_db.add_location("lbl6", 6)
 
 LBL7 = loc_db.add_location("lbl7", 7)
 
 IRDst = ExprId('IRDst', 32)
 
 dummy = ExprId('dummy', 32)
 
 IRA = IRATest(loc_db)
 
 END = ExprId("END", IRDst.size)
 
 G0_IRA = IRA.new_ircfg()
 
def G0_IRB0
 
def G0_IRB1
 
def G0_IRB2
 
 G1_IRA = IRA.new_ircfg()
 
def G1_IRB0
 
def G1_IRB1
 
def G1_IRB2
 
def G1_IRB3
 
 G2_IRA = IRA.new_ircfg()
 
def G2_IRB0
 
def G2_IRB1
 
def G2_IRB2
 
 G3_IRA = IRA.new_ircfg()
 
def G3_IRB0
 
def G3_IRB1
 
def G3_IRB2
 
def G3_IRB3
 
def G3_IRB4
 
def G3_IRB5
 
 G4_IRA = IRA.new_ircfg()
 
def G4_IRB0
 
def G4_IRB1
 
def G4_IRB2
 
def G4_IRB3
 
def G4_IRB4
 
def G4_IRB5
 
 G5_IRA = IRA.new_ircfg()
 
def G5_IRB0
 
def G5_IRB1
 
def G5_IRB2
 
 G6_IRA = IRA.new_ircfg()
 
def G6_IRB0
 
def G6_IRB1
 
def G6_IRB2
 
def G6_IRB3
 
def G6_IRB4
 
def G6_IRB5
 
 G7_IRA = IRA.new_ircfg()
 
def G7_IRB0
 
def G7_IRB1
 
def G7_IRB2
 
def G7_IRB3
 
def G7_IRB4
 
def G7_IRB5
 
 G8_IRA = IRA.new_ircfg()
 
def G8_IRB0
 
def G8_IRB1
 
def G8_IRB2
 
def G8_IRB3
 
def G8_IRB4
 
def G8_IRB5
 
def G8_IRB6
 
def G8_IRB7
 
 G9_IRA = IRA.new_ircfg()
 
def G9_IRB0
 
def G9_IRB1
 
def G9_IRB2
 
 G10_IRA = IRA.new_ircfg()
 
def G10_IRB0
 
def G10_IRB1
 
def G10_IRB2
 
 ir_arch_a = IRAOutRegs(loc_db)
 
 ircfg_orig = IRCFG(IRDst, loc_db)
 
 head = LBL0
 
 simplifier = CustomIRCFGSimplifierSSA(ir_arch_a)
 
 ircfg = simplifier(ircfg, head)
 

Detailed Description

 Test cases for dead code elimination

Function Documentation

◆ add_out_reg_end()

def unssa.add_out_reg_end (   ir_arch_a,
  ircfg_a 
)

◆ gen_irblock()

def unssa.gen_irblock (   label,
  exprs_list 
)

Variable Documentation

◆ a

unssa.a = ExprId("a", 32)

◆ a_init

unssa.a_init = ExprId("a_init", 32)

◆ b

unssa.b = ExprId("b", 32)

◆ b_init

unssa.b_init = ExprId("b_init", 32)

◆ c

unssa.c = ExprId("c", 32)

◆ c_init

unssa.c_init = ExprId("c_init", 32)

◆ CST0

unssa.CST0 = ExprInt(0x0, 32)

◆ CST1

unssa.CST1 = ExprInt(0x1, 32)

◆ CST2

unssa.CST2 = ExprInt(0x2, 32)

◆ CST3

unssa.CST3 = ExprInt(0x3, 32)

◆ CSTX_8

unssa.CSTX_8 = ExprInt(12, 8)

◆ d

unssa.d = ExprId("d", 32)

◆ d_init

unssa.d_init = ExprId("d_init", 32)

◆ dummy

unssa.dummy = ExprId('dummy', 32)

◆ END

unssa.END = ExprId("END", IRDst.size)

◆ G0_IRA

unssa.G0_IRA = IRA.new_ircfg()

◆ G0_IRB0

def unssa.G0_IRB0
Initial value:
1 = gen_irblock(LBL0, [
2  [ExprAssign(a, CST1)],
3  [ExprAssign(IRDst, ExprLoc(LBL1, 32))]
4 ])

◆ G0_IRB1

def unssa.G0_IRB1
Initial value:
1 = gen_irblock(LBL1, [
2  [ExprAssign(a, a+CST1)],
3  [ExprAssign(IRDst, ExprCond(x,
4  ExprLoc(LBL1, 32),
5  ExprLoc(LBL2, 32)
6  )
7  )]
8 ])

◆ G0_IRB2

def unssa.G0_IRB2
Initial value:
1 = gen_irblock(LBL2, [
2  [ExprAssign(r, a)],
3  [ExprAssign(IRDst, END)]
4 ])

◆ G10_IRA

unssa.G10_IRA = IRA.new_ircfg()

◆ G10_IRB0

def unssa.G10_IRB0
Initial value:
1 = gen_irblock(LBL0, [
2  [ExprAssign(a, CST0)],
3  [ExprAssign(IRDst, ExprLoc(LBL1, 32))]
4 ])

◆ G10_IRB1

def unssa.G10_IRB1
Initial value:
1 = gen_irblock(LBL1, [
2  [ExprAssign(a, a+CST1)],
3  [ExprAssign(IRDst, ExprCond(a,
4  ExprLoc(LBL1, 32),
5  ExprLoc(LBL2, 32)
6  )
7  )]
8 ])

◆ G10_IRB2

def unssa.G10_IRB2
Initial value:
1 = gen_irblock(LBL2, [
2  [ExprAssign(r, CST1)],
3  [ExprAssign(IRDst, END)]
4 ])

◆ G1_IRA

unssa.G1_IRA = IRA.new_ircfg()

◆ G1_IRB0

def unssa.G1_IRB0
Initial value:
1 = gen_irblock(LBL0, [
2  [ExprAssign(a, CST1)],
3  [ExprAssign(IRDst, ExprCond(x,
4  ExprLoc(LBL1, 32),
5  ExprLoc(LBL2, 32)
6  )
7  )]
8 ])

◆ G1_IRB1

def unssa.G1_IRB1
Initial value:
1 = gen_irblock(LBL1, [
2  [ExprAssign(a, a+CST1)],
3  [ExprAssign(IRDst, ExprLoc(LBL3, 32))]
4 ])

◆ G1_IRB2

def unssa.G1_IRB2
Initial value:
1 = gen_irblock(LBL2, [
2  [ExprAssign(a, a+CST2)],
3  [ExprAssign(IRDst, ExprLoc(LBL3, 32))]
4 ])

◆ G1_IRB3

def unssa.G1_IRB3
Initial value:
1 = gen_irblock(LBL3, [
2  [ExprAssign(r, a)],
3  [ExprAssign(IRDst, END)]
4 ])

◆ G2_IRA

unssa.G2_IRA = IRA.new_ircfg()

◆ G2_IRB0

def unssa.G2_IRB0
Initial value:
1 = gen_irblock(LBL0, [
2  [ExprAssign(a, CST1)],
3  [ExprAssign(b, CST2)],
4  [ExprAssign(IRDst, ExprLoc(LBL1, 32))]
5 ])

◆ G2_IRB1

def unssa.G2_IRB1
Initial value:
1 = gen_irblock(LBL1, [
2  [
3  ExprAssign(a, b),
4  ExprAssign(b, a),
5  ],
6  [ExprAssign(IRDst, ExprCond(x,
7  ExprLoc(LBL1, 32),
8  ExprLoc(LBL2, 32)
9  )
10  )]
11 ])

◆ G2_IRB2

def unssa.G2_IRB2
Initial value:
1 = gen_irblock(LBL2, [
2  [ExprAssign(r, a)],
3  [ExprAssign(IRDst, END)]
4 ])

◆ G3_IRA

unssa.G3_IRA = IRA.new_ircfg()

◆ G3_IRB0

def unssa.G3_IRB0
Initial value:
1 = gen_irblock(LBL0, [
2  [ExprAssign(a, CST1)],
3  [ExprAssign(IRDst, ExprLoc(LBL1, 32))]
4 ])

◆ G3_IRB1

def unssa.G3_IRB1
Initial value:
1 = gen_irblock(LBL1, [
2  [
3  ExprAssign(a, a + CST1),
4  ],
5  [ExprAssign(IRDst, ExprCond(x,
6  ExprLoc(LBL2, 32),
7  ExprCond(y,
8  ExprLoc(LBL3, 32),
9  ExprLoc(LBL5, 32)
10  )
11  ))]
12 ])

◆ G3_IRB2

def unssa.G3_IRB2
Initial value:
1 = gen_irblock(LBL2, [
2  [ExprAssign(a, a + CST1)],
3  [ExprAssign(IRDst, ExprLoc(LBL1, 32))]
4 ])

◆ G3_IRB3

def unssa.G3_IRB3
Initial value:
1 = gen_irblock(LBL3, [
2  [ExprAssign(a, a + CST2)],
3  [ExprAssign(IRDst, ExprLoc(LBL1, 32))]
4 ])

◆ G3_IRB4

def unssa.G3_IRB4
Initial value:
1 = gen_irblock(LBL4, [
2  [ExprAssign(r, a + CST3)],
3  [
4  ExprAssign(IRDst,
5  ExprCond(y,
6  ExprLoc(LBL1, 32),
7  ExprLoc(LBL5, 32)
8  )
9  )
10  ]
11 ])

◆ G3_IRB5

def unssa.G3_IRB5
Initial value:
1 = gen_irblock(LBL5, [
2  [ExprAssign(r, a)],
3  [ExprAssign(IRDst, END)]
4 ])

◆ G4_IRA

unssa.G4_IRA = IRA.new_ircfg()

◆ G4_IRB0

def unssa.G4_IRB0
Initial value:
1 = gen_irblock(LBL0, [
2  [ExprAssign(a, CST1)],
3  [ExprAssign(IRDst, ExprLoc(LBL1, 32))]
4 ])

◆ G4_IRB1

def unssa.G4_IRB1
Initial value:
1 = gen_irblock(LBL1, [
2  [ExprAssign(IRDst, ExprCond(x,
3  ExprLoc(LBL2, 32),
4  ExprLoc(LBL3, 32)
5  )
6  )]
7 ])

◆ G4_IRB2

def unssa.G4_IRB2
Initial value:
1 = gen_irblock(LBL2, [
2  [ExprAssign(a, a+CST2)],
3  [ExprAssign(IRDst, ExprLoc(LBL4, 32))]
4 ])

◆ G4_IRB3

def unssa.G4_IRB3
Initial value:
1 = gen_irblock(LBL3, [
2  [ExprAssign(a, a+CST3)],
3  [ExprAssign(IRDst, ExprLoc(LBL4, 32))]
4 ])

◆ G4_IRB4

def unssa.G4_IRB4
Initial value:
1 = gen_irblock(LBL4, [
2  [ExprAssign(a, a+CST1)],
3  [
4  ExprAssign(
5  IRDst,
6  ExprCond(
7  x,
8  ExprLoc(LBL5, 32),
9  ExprLoc(LBL1, 32)
10  )
11  )
12  ]
13 ])

◆ G4_IRB5

def unssa.G4_IRB5
Initial value:
1 = gen_irblock(LBL5, [
2  [ExprAssign(r, a)],
3  [ExprAssign(IRDst, END)]
4 ])

◆ G5_IRA

unssa.G5_IRA = IRA.new_ircfg()

◆ G5_IRB0

def unssa.G5_IRB0
Initial value:
1 = gen_irblock(LBL0, [
2  [
3  ExprAssign(a, CST1),
4  ExprAssign(b, CST1),
5  ],
6  [ExprAssign(IRDst, ExprLoc(LBL1, 32))]
7 ])

◆ G5_IRB1

def unssa.G5_IRB1
Initial value:
1 = gen_irblock(LBL1, [
2  [
3  ExprAssign(b, a),
4  ExprAssign(a, a+CST1)
5  ],
6  [ExprAssign(IRDst, ExprCond(x,
7  ExprLoc(LBL1, 32),
8  ExprLoc(LBL2, 32)
9  )
10  )]
11 ])

◆ G5_IRB2

def unssa.G5_IRB2
Initial value:
1 = gen_irblock(LBL2, [
2  [ExprAssign(r, b)],
3  [ExprAssign(IRDst, END)]
4 ])

◆ G6_IRA

unssa.G6_IRA = IRA.new_ircfg()

◆ G6_IRB0

def unssa.G6_IRB0
Initial value:
1 = gen_irblock(LBL0, [
2  [
3  ExprAssign(a, CST1),
4  ExprAssign(b, CST1),
5  ],
6  [ExprAssign(IRDst, ExprCond(x,
7  ExprLoc(LBL1, 32),
8  ExprLoc(LBL2, 32)
9  )
10  )]
11 ])

◆ G6_IRB1

def unssa.G6_IRB1
Initial value:
1 = gen_irblock(LBL1, [
2  [ExprAssign(a, a + CST1)],
3  [ExprAssign(IRDst, ExprLoc(LBL5, 32))]
4 ])

◆ G6_IRB2

def unssa.G6_IRB2
Initial value:
1 = gen_irblock(LBL2, [
2  [
3  ExprAssign(a, a + CST1),
4  ],
5  [ExprAssign(IRDst, ExprCond(x,
6  ExprLoc(LBL3, 32),
7  ExprLoc(LBL4, 32)
8  )
9  )]
10 ])

◆ G6_IRB3

def unssa.G6_IRB3
Initial value:
1 = gen_irblock(LBL3, [
2  [
3  ExprAssign(b, a + CST1),
4  ],
5  [ExprAssign(IRDst, ExprLoc(LBL5, 32))],
6 ])

◆ G6_IRB4

def unssa.G6_IRB4
Initial value:
1 = gen_irblock(LBL4, [
2  [
3  ExprAssign(b, a + CST1),
4  ],
5  [ExprAssign(IRDst, ExprLoc(LBL5, 32))],
6 ])

◆ G6_IRB5

def unssa.G6_IRB5
Initial value:
1 = gen_irblock(LBL5, [
2  [ExprAssign(r, a)],
3  [ExprAssign(IRDst, END)]
4 ])

◆ G7_IRA

unssa.G7_IRA = IRA.new_ircfg()

◆ G7_IRB0

def unssa.G7_IRB0
Initial value:
1 = gen_irblock(LBL0, [
2  [ExprAssign(a, a + CST1)],
3  [ExprAssign(IRDst, ExprLoc(LBL1, 32))]
4 ])

◆ G7_IRB1

def unssa.G7_IRB1
Initial value:
1 = gen_irblock(LBL1, [
2  [ExprAssign(IRDst, ExprCond(x,
3  ExprLoc(LBL2, 32),
4  ExprLoc(LBL3, 32)
5  )
6  )]
7 ])

◆ G7_IRB2

def unssa.G7_IRB2
Initial value:
1 = gen_irblock(LBL2, [
2  [ExprAssign(IRDst, ExprLoc(LBL4, 32))]
3 ])

◆ G7_IRB3

def unssa.G7_IRB3
Initial value:
1 = gen_irblock(LBL3, [
2  [ExprAssign(a, a+CST3)],
3  [ExprAssign(IRDst, ExprLoc(LBL4, 32))]
4 ])

◆ G7_IRB4

def unssa.G7_IRB4
Initial value:
1 = gen_irblock(LBL4, [
2  [
3  ExprAssign(
4  IRDst,
5  ExprCond(
6  x,
7  ExprLoc(LBL5, 32),
8  ExprLoc(LBL1, 32)
9  )
10  )
11  ]
12 ])

◆ G7_IRB5

def unssa.G7_IRB5
Initial value:
1 = gen_irblock(LBL5, [
2  [ExprAssign(r, a)],
3  [ExprAssign(IRDst, END)]
4 ])

◆ G8_IRA

unssa.G8_IRA = IRA.new_ircfg()

◆ G8_IRB0

def unssa.G8_IRB0
Initial value:
1 = gen_irblock(LBL0, [
2  [ExprAssign(a, CST0)],
3  [ExprAssign(b, c)],
4  [ExprAssign(IRDst, ExprLoc(LBL1, 32))]
5 ])

◆ G8_IRB1

def unssa.G8_IRB1
Initial value:
1 = gen_irblock(LBL1, [
2  [ExprAssign(u8, ExprMem(b, 8))],
3  [
4  ExprAssign(
5  IRDst,
6  ExprCond(
7  u8,
8  ExprLoc(LBL2, 32),
9  ExprLoc(LBL7, 32)
10  )
11  )
12  ]
13 ])

◆ G8_IRB2

def unssa.G8_IRB2
Initial value:
1 = gen_irblock(LBL2, [
2  [ExprAssign(b, b + CST1)],
3  [
4  ExprAssign(
5  IRDst,
6  ExprCond(
7  u8 + CSTX_8,
8  ExprLoc(LBL1, 32),
9  ExprLoc(LBL3, 32)
10  )
11  )
12  ]
13 ])

◆ G8_IRB3

def unssa.G8_IRB3
Initial value:
1 = gen_irblock(LBL3, [
2  [
3  ExprAssign(a, (ExprMem(b, 8) + u8).zeroExtend(32))
4  ],
5  [
6  ExprAssign(
7  IRDst,
8  ExprLoc(LBL1, 32)
9  )
10  ]
11 ])

◆ G8_IRB4

def unssa.G8_IRB4
Initial value:
1 = gen_irblock(LBL4, [
2  [ExprAssign(b, b + CST1)],
3  [ExprAssign(d, CST0)],
4  [ExprAssign(IRDst, ExprLoc(LBL6, 32))]
5 ])

◆ G8_IRB5

def unssa.G8_IRB5
Initial value:
1 = gen_irblock(LBL5, [
2  [ExprAssign(d, CST1)],
3  [ExprAssign(IRDst, ExprLoc(LBL6, 32))]
4 ])

◆ G8_IRB6

def unssa.G8_IRB6
Initial value:
1 = gen_irblock(LBL6, [
2  [ExprAssign(IRDst, ExprLoc(LBL1, 32))]
3 ])

◆ G8_IRB7

def unssa.G8_IRB7
Initial value:
1 = gen_irblock(LBL7, [
2  [ExprAssign(b, CST2)],
3  [ExprAssign(r, a)],
4  [ExprAssign(IRDst, END)]
5 ])

◆ G9_IRA

unssa.G9_IRA = IRA.new_ircfg()

◆ G9_IRB0

def unssa.G9_IRB0
Initial value:
1 = gen_irblock(LBL0, [
2  [ExprAssign(IRDst, ExprLoc(LBL1, 32))]
3 ])

◆ G9_IRB1

def unssa.G9_IRB1
Initial value:
1 = gen_irblock(LBL1, [
2  [ExprAssign(b, CST1)],
3  [ExprAssign(IRDst, ExprCond(x,
4  ExprLoc(LBL1, 32),
5  ExprLoc(LBL2, 32)
6  )
7  )]
8 ])

◆ G9_IRB2

def unssa.G9_IRB2
Initial value:
1 = gen_irblock(LBL2, [
2  [ExprAssign(r, b)],
3  [ExprAssign(IRDst, END)]
4 ])

◆ head

unssa.head = LBL0

◆ ir_arch_a

unssa.ir_arch_a = IRAOutRegs(loc_db)

◆ IRA

unssa.IRA = IRATest(loc_db)

◆ ircfg

unssa.ircfg = simplifier(ircfg, head)

◆ ircfg_orig

unssa.ircfg_orig = IRCFG(IRDst, loc_db)

◆ IRDst

unssa.IRDst = ExprId('IRDst', 32)

◆ LBL0

unssa.LBL0 = loc_db.add_location("lbl0", 0)

◆ LBL1

unssa.LBL1 = loc_db.add_location("lbl1", 1)

◆ LBL2

unssa.LBL2 = loc_db.add_location("lbl2", 2)

◆ LBL3

unssa.LBL3 = loc_db.add_location("lbl3", 3)

◆ LBL4

unssa.LBL4 = loc_db.add_location("lbl4", 4)

◆ LBL5

unssa.LBL5 = loc_db.add_location("lbl5", 5)

◆ LBL6

unssa.LBL6 = loc_db.add_location("lbl6", 6)

◆ LBL7

unssa.LBL7 = loc_db.add_location("lbl7", 7)

◆ loc_db

unssa.loc_db = LocationDB()

◆ pc

unssa.pc = ExprId("pc", 32)

◆ r

unssa.r = ExprId("r", 32)

◆ r_init

unssa.r_init = ExprId("r_init", 32)

◆ simplifier

unssa.simplifier = CustomIRCFGSimplifierSSA(ir_arch_a)

◆ sp

unssa.sp = ExprId("sp", 32)

◆ u8

unssa.u8 = ExprId("u8", 8)

◆ x

unssa.x = ExprId("x", 32)

◆ y

unssa.y = ExprId("y", 32)

◆ zf

unssa.zf = ExprId('zf', 1)
unssa.gen_irblock
def gen_irblock(label, exprs_list)
Definition: unssa.py:51