diff options
Diffstat (limited to 'test/analysis')
| -rw-r--r-- | test/analysis/data_flow.py | 90 | ||||
| -rw-r--r-- | test/analysis/depgraph.py | 66 | ||||
| -rw-r--r-- | test/analysis/dse.py | 8 |
3 files changed, 82 insertions, 82 deletions
diff --git a/test/analysis/data_flow.py b/test/analysis/data_flow.py index d5b197d2..8204d9ce 100644 --- a/test/analysis/data_flow.py +++ b/test/analysis/data_flow.py @@ -1,11 +1,11 @@ """ Test cases for dead code elimination""" from miasm2.expression.expression import ExprId, ExprInt, ExprAff, ExprMem -from miasm2.core.asmblock import AsmSymbolPool +from miasm2.core.locationdb import LocationDB from miasm2.analysis.data_flow import * from miasm2.ir.analysis import ira from miasm2.ir.ir import IRBlock, AssignBlock -symbol_pool = AsmSymbolPool() +loc_db = LocationDB() a = ExprId("a", 32) b = ExprId("b", 32) @@ -26,13 +26,13 @@ CST1 = ExprInt(0x11, 32) CST2 = ExprInt(0x12, 32) CST3 = ExprInt(0x13, 32) -LBL0 = symbol_pool.add_location("lbl0", 0) -LBL1 = symbol_pool.add_location("lbl1", 1) -LBL2 = symbol_pool.add_location("lbl2", 2) -LBL3 = symbol_pool.add_location("lbl3", 3) -LBL4 = symbol_pool.add_location("lbl4", 4) -LBL5 = symbol_pool.add_location("lbl5", 5) -LBL6 = symbol_pool.add_location("lbl6", 6) +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) IRDst = ExprId('IRDst', 32) dummy = ExprId('dummy', 32) @@ -68,9 +68,9 @@ class IRATest(ira): """Fake IRA class for tests""" - def __init__(self, symbol_pool=None): + def __init__(self, loc_db=None): arch = Arch() - super(IRATest, self).__init__(arch, 32, symbol_pool) + super(IRATest, self).__init__(arch, 32, loc_db) self.IRDst = IRDst self.ret_reg = r @@ -79,7 +79,7 @@ class IRATest(ira): # graph 1 : Simple graph with dead and alive variables -G1_IRA = IRATest(symbol_pool) +G1_IRA = IRATest(loc_db) G1_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST2)]]) G1_IRB1 = gen_irblock(LBL1, [[ExprAff(a, b)]]) @@ -91,7 +91,7 @@ G1_IRA.graph.add_uniq_edge(G1_IRB0.loc_key, G1_IRB1.loc_key) G1_IRA.graph.add_uniq_edge(G1_IRB1.loc_key, G1_IRB2.loc_key) # Expected output for graph 1 -G1_EXP_IRA = IRATest(symbol_pool) +G1_EXP_IRA = IRATest(loc_db) G1_EXP_IRB0 = gen_irblock(LBL0, [[], [ExprAff(b, CST2)]]) G1_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(a, b)]]) @@ -102,7 +102,7 @@ G1_EXP_IRA.blocks = {irb.loc_key : irb for irb in [G1_EXP_IRB0, G1_EXP_IRB1, # graph 2 : Natural loop with dead variable -G2_IRA = IRATest(symbol_pool) +G2_IRA = IRATest(loc_db) G2_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(r, CST1)]]) G2_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)]]) @@ -115,7 +115,7 @@ G2_IRA.graph.add_uniq_edge(G2_IRB1.loc_key, G2_IRB2.loc_key) G2_IRA.graph.add_uniq_edge(G2_IRB1.loc_key, G2_IRB1.loc_key) # Expected output for graph 2 -G2_EXP_IRA = IRATest(symbol_pool) +G2_EXP_IRA = IRATest(loc_db) G2_EXP_IRB0 = gen_irblock(LBL0, [[], [ExprAff(r, CST1)]]) G2_EXP_IRB1 = gen_irblock(LBL1, [[]]) @@ -126,7 +126,7 @@ G2_EXP_IRA.blocks = {irb.loc_key : irb for irb in [G2_EXP_IRB0, G2_EXP_IRB1, # graph 3 : Natural loop with alive variables -G3_IRA = IRATest(symbol_pool) +G3_IRA = IRATest(loc_db) G3_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)]]) G3_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)]]) @@ -139,7 +139,7 @@ G3_IRA.graph.add_uniq_edge(G3_IRB1.loc_key, G3_IRB2.loc_key) G3_IRA.graph.add_uniq_edge(G3_IRB1.loc_key, G3_IRB1.loc_key) # Expected output for graph 3 -G3_EXP_IRA = IRATest(symbol_pool) +G3_EXP_IRA = IRATest(loc_db) G3_EXP_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)]]) G3_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)]]) @@ -150,7 +150,7 @@ G3_EXP_IRA.blocks = {irb.loc_key : irb for irb in [G3_EXP_IRB0, G3_EXP_IRB1, # graph 4 : If/else with dead variables -G4_IRA = IRATest(symbol_pool) +G4_IRA = IRATest(loc_db) G4_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)]]) G4_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)]]) @@ -166,7 +166,7 @@ G4_IRA.graph.add_uniq_edge(G4_IRB1.loc_key, G4_IRB3.loc_key) G4_IRA.graph.add_uniq_edge(G4_IRB2.loc_key, G4_IRB3.loc_key) # Expected output for graph 4 -G4_EXP_IRA = IRATest(symbol_pool) +G4_EXP_IRA = IRATest(loc_db) G4_EXP_IRB0 = gen_irblock(LBL0, [[]]) G4_EXP_IRB1 = gen_irblock(LBL1, [[]]) @@ -178,7 +178,7 @@ G4_EXP_IRA.blocks = {irb.loc_key : irb for irb in [G4_EXP_IRB0, G4_EXP_IRB1, # graph 5 : Loop and If/else with dead variables -G5_IRA = IRATest(symbol_pool) +G5_IRA = IRATest(loc_db) G5_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)]]) G5_IRB1 = gen_irblock(LBL1, [[ExprAff(r, CST2)]]) @@ -199,7 +199,7 @@ G5_IRA.graph.add_uniq_edge(G5_IRB4.loc_key, G5_IRB5.loc_key) G5_IRA.graph.add_uniq_edge(G5_IRB4.loc_key, G5_IRB1.loc_key) # Expected output for graph 5 -G5_EXP_IRA = IRATest(symbol_pool) +G5_EXP_IRA = IRATest(loc_db) G5_EXP_IRB0 = gen_irblock(LBL0, [[]]) G5_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(r, CST2)]]) @@ -215,7 +215,7 @@ G5_EXP_IRA.blocks = {irb.loc_key : irb for irb in [G5_EXP_IRB0, G5_EXP_IRB1, # graph 6 : Natural loop with dead variables symetric affectation # (a = b <-> b = a ) -G6_IRA = IRATest(symbol_pool) +G6_IRA = IRATest(loc_db) G6_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)]]) G6_IRB1 = gen_irblock(LBL1, [[ExprAff(b, a)]]) @@ -231,7 +231,7 @@ G6_IRA.graph.add_uniq_edge(G6_IRB2.loc_key, G6_IRB1.loc_key) G6_IRA.graph.add_uniq_edge(G6_IRB2.loc_key, G6_IRB3.loc_key) # Expected output for graph 6 -G6_EXP_IRA = IRATest(symbol_pool) +G6_EXP_IRA = IRATest(loc_db) G6_EXP_IRB0 = gen_irblock(LBL0, [[]]) G6_EXP_IRB1 = gen_irblock(LBL1, [[]]) @@ -243,7 +243,7 @@ G6_EXP_IRA.blocks = {irb.loc_key : irb for irb in [G6_EXP_IRB0, G6_EXP_IRB1, # graph 7 : Double entry loop with dead variables -G7_IRA = IRATest(symbol_pool) +G7_IRA = IRATest(loc_db) G7_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(r, CST1)]]) G7_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)]]) @@ -261,7 +261,7 @@ G7_IRA.graph.add_uniq_edge(G7_IRB0.loc_key, G7_IRB2.loc_key) # Expected output for graph 7 -G7_EXP_IRA = IRATest(symbol_pool) +G7_EXP_IRA = IRATest(loc_db) G7_EXP_IRB0 = gen_irblock(LBL0, [[], [ExprAff(r, CST1)]]) G7_EXP_IRB1 = gen_irblock(LBL1, [[]]) @@ -273,7 +273,7 @@ G7_EXP_IRA.blocks = {irb.loc_key : irb for irb in [G7_EXP_IRB0, G7_EXP_IRB1, # graph 8 : Nested loops with dead variables -G8_IRA = IRATest(symbol_pool) +G8_IRA = IRATest(loc_db) G8_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST1)]]) G8_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)]]) @@ -293,7 +293,7 @@ G8_IRA.graph.add_uniq_edge(G8_IRB3.loc_key, G8_IRB2.loc_key) # Expected output for graph 8 -G8_EXP_IRA = IRATest(symbol_pool) +G8_EXP_IRA = IRATest(loc_db) G8_EXP_IRB0 = gen_irblock(LBL0, [[], []]) G8_EXP_IRB1 = gen_irblock(LBL1, [[]]) @@ -305,7 +305,7 @@ G8_EXP_IRA.blocks = {irb.loc_key : irb for irb in [G8_EXP_IRB0, G8_EXP_IRB1, # graph 9 : Miultiple-exits loops with dead variables -G9_IRA = IRATest(symbol_pool) +G9_IRA = IRATest(loc_db) G9_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST1)]]) G9_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)], [ExprAff(b, b+CST1)]]) @@ -328,7 +328,7 @@ G9_IRA.graph.add_uniq_edge(G9_IRB3.loc_key, G9_IRB4.loc_key) # Expected output for graph 9 -G9_EXP_IRA = IRATest(symbol_pool) +G9_EXP_IRA = IRATest(loc_db) G9_EXP_IRB0 = gen_irblock(LBL0, [[], [ExprAff(b, CST1)]]) G9_EXP_IRB1 = gen_irblock(LBL1, [[], [ExprAff(b, b+CST1)]]) @@ -343,7 +343,7 @@ G9_EXP_IRA.blocks = {irb.loc_key : irb for irb in [G9_EXP_IRB0, G9_EXP_IRB1, # graph 10 : Natural loop with alive variables symetric affectation # (a = b <-> b = a ) -G10_IRA = IRATest(symbol_pool) +G10_IRA = IRATest(loc_db) G10_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)]]) G10_IRB1 = gen_irblock(LBL1, [[ExprAff(b, a)]]) @@ -359,7 +359,7 @@ G10_IRA.graph.add_uniq_edge(G10_IRB2.loc_key, G10_IRB1.loc_key) G10_IRA.graph.add_uniq_edge(G10_IRB2.loc_key, G10_IRB3.loc_key) # Expected output for graph 10 -G10_EXP_IRA = IRATest(symbol_pool) +G10_EXP_IRA = IRATest(loc_db) G10_EXP_IRB0 = gen_irblock(LBL0, [[]]) G10_EXP_IRB1 = gen_irblock(LBL1, [[]]) @@ -371,7 +371,7 @@ G10_EXP_IRA.blocks = {irb.loc_key : irb for irb in [G10_EXP_IRB0, G10_EXP_IRB1, # graph 11 : If/Else conditions with alive variables -G11_IRA = IRATest(symbol_pool) +G11_IRA = IRATest(loc_db) G11_IRB0 = gen_irblock(LBL0, [[ExprAff(a, b)]]) G11_IRB1 = gen_irblock(LBL1, [[ExprAff(b, a)]]) @@ -390,7 +390,7 @@ G11_IRA.graph.add_uniq_edge(G11_IRB1.loc_key, G11_IRB2.loc_key) # Expected output for graph 11 -G11_EXP_IRA = IRATest(symbol_pool) +G11_EXP_IRA = IRATest(loc_db) G11_EXP_IRB0 = gen_irblock(LBL0, [[ExprAff(a, b)]]) G11_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(b, a)]]) @@ -404,7 +404,7 @@ G11_EXP_IRA.blocks = {irb.loc_key : irb for irb in [G11_EXP_IRB0, G11_EXP_IRB1, # graph 12 : Graph with multiple out points and useless definitions # of return register -G12_IRA = IRATest(symbol_pool) +G12_IRA = IRATest(loc_db) G12_IRB0 = gen_irblock(LBL0, [[ExprAff(r, CST1)], [ExprAff(a, CST2)]]) G12_IRB1 = gen_irblock(LBL1, [[ExprAff(r, CST2)]]) @@ -423,7 +423,7 @@ G12_IRA.graph.add_uniq_edge(G12_IRB2.loc_key, G12_IRB4.loc_key) G12_IRA.graph.add_uniq_edge(G12_IRB4.loc_key, G12_IRB5.loc_key) # Expected output for graph 12 -G12_EXP_IRA = IRATest(symbol_pool) +G12_EXP_IRA = IRATest(loc_db) G12_EXP_IRB0 = gen_irblock(LBL0, [[], []]) G12_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(r, CST2)]]) @@ -439,7 +439,7 @@ G12_EXP_IRA.blocks = {irb.loc_key : irb for irb in [G12_EXP_IRB0, G12_EXP_IRB1, # graph 13 : Graph where a leaf has lost its son -G13_IRA = IRATest(symbol_pool) +G13_IRA = IRATest(loc_db) G13_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST2)]]) G13_IRB1 = gen_irblock(LBL1, [[ExprAff(r, b)]]) @@ -457,7 +457,7 @@ G13_IRA.graph.add_uniq_edge(G13_IRB2.loc_key, G13_IRB3.loc_key) G13_IRA.graph.add_uniq_edge(G13_IRB4.loc_key, G13_IRB2.loc_key) # Expected output for graph 13 -G13_EXP_IRA = IRATest(symbol_pool) +G13_EXP_IRA = IRATest(loc_db) G13_EXP_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST2)]]) G13_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(r, b)]]) @@ -474,7 +474,7 @@ G13_EXP_IRA.blocks = {irb.loc_key: irb for irb in [G13_EXP_IRB0, G13_EXP_IRB1, # graph 14 : Graph where variable assigned multiple times in a block but still # useful in the end -G14_IRA = IRATest(symbol_pool) +G14_IRA = IRATest(loc_db) G14_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(c, a)], [ExprAff(a, CST2)]]) @@ -485,7 +485,7 @@ G14_IRA.blocks = {irb.loc_key : irb for irb in [G14_IRB0, G14_IRB1]} G14_IRA.graph.add_uniq_edge(G14_IRB0.loc_key, G14_IRB1.loc_key) # Expected output for graph 1 -G14_EXP_IRA = IRATest(symbol_pool) +G14_EXP_IRA = IRATest(loc_db) G14_EXP_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(c, a)], [ExprAff(a, CST2)]]) @@ -496,7 +496,7 @@ G14_EXP_IRA.blocks = {irb.loc_key: irb for irb in [G14_EXP_IRB0, G14_EXP_IRB1]} # graph 15 : Graph where variable assigned multiple and read at the same time, # but useless -G15_IRA = IRATest(symbol_pool) +G15_IRA = IRATest(loc_db) G15_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST2)], [ExprAff(a, CST1), ExprAff(b, a+CST2), @@ -508,7 +508,7 @@ G15_IRA.blocks = {irb.loc_key : irb for irb in [G15_IRB0, G15_IRB1]} G15_IRA.graph.add_uniq_edge(G15_IRB0.loc_key, G15_IRB1.loc_key) # Expected output for graph 1 -G15_EXP_IRA = IRATest(symbol_pool) +G15_EXP_IRA = IRATest(loc_db) G15_EXP_IRB0 = gen_irblock(LBL0, [[], [ExprAff(a, CST1)]]) G15_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(r, a)]]) @@ -517,7 +517,7 @@ G15_EXP_IRA.blocks = {irb.loc_key: irb for irb in [G15_EXP_IRB0, G15_EXP_IRB1]} # graph 16 : Graph where variable assigned multiple times in the same bloc -G16_IRA = IRATest(symbol_pool) +G16_IRA = IRATest(loc_db) G16_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1), ExprAff(b, CST2), ExprAff(c, CST3)], [ExprAff(a, c+CST1), @@ -533,7 +533,7 @@ G16_IRA.graph.add_uniq_edge(G16_IRB1.loc_key, G16_IRB2.loc_key) G16_IRA.blocks = {irb.loc_key : irb for irb in [G16_IRB0, G16_IRB1]} # Expected output for graph 1 -G16_EXP_IRA = IRATest(symbol_pool) +G16_EXP_IRA = IRATest(loc_db) G16_EXP_IRB0 = gen_irblock(LBL0, [[ExprAff(c, CST3)], [ExprAff(a, c + CST1), ExprAff(b, c + CST2)]]) @@ -543,7 +543,7 @@ G16_EXP_IRA.blocks = {irb.loc_key: irb for irb in [G16_EXP_IRB0, G16_EXP_IRB1]} # graph 17 : parallel ir -G17_IRA = IRATest(symbol_pool) +G17_IRA = IRATest(loc_db) G17_IRB0 = gen_irblock(LBL0, [[ExprAff(a, a*b), ExprAff(b, c), @@ -604,7 +604,7 @@ G17_IRA.blocks = {irb.loc_key : irb for irb in [G17_IRB0]} G17_IRA.graph.add_node(G17_IRB0.loc_key) # Expected output for graph 17 -G17_EXP_IRA = IRATest(symbol_pool) +G17_EXP_IRA = IRATest(loc_db) G17_EXP_IRB0 = gen_irblock(LBL0, [[], diff --git a/test/analysis/depgraph.py b/test/analysis/depgraph.py index 86857182..a7d3a148 100644 --- a/test/analysis/depgraph.py +++ b/test/analysis/depgraph.py @@ -1,7 +1,7 @@ """Regression test module for DependencyGraph""" from miasm2.expression.expression import ExprId, ExprInt, ExprAff, ExprCond, \ ExprLoc, LocKey -from miasm2.core.asmblock import AsmSymbolPool +from miasm2.core.locationdb import LocationDB from miasm2.ir.analysis import ira from miasm2.ir.ir import IRBlock, AssignBlock from miasm2.core.graph import DiGraph @@ -10,7 +10,7 @@ from itertools import count from pdb import pm import re -symbol_pool = AsmSymbolPool() +loc_db = LocationDB() EMULATION = True try: @@ -44,13 +44,13 @@ CST33 = ExprInt(0x33, 32) CST35 = ExprInt(0x35, 32) CST37 = ExprInt(0x37, 32) -LBL0 = symbol_pool.add_location("lbl0", 0) -LBL1 = symbol_pool.add_location("lbl1", 1) -LBL2 = symbol_pool.add_location("lbl2", 2) -LBL3 = symbol_pool.add_location("lbl3", 3) -LBL4 = symbol_pool.add_location("lbl4", 4) -LBL5 = symbol_pool.add_location("lbl5", 5) -LBL6 = symbol_pool.add_location("lbl6", 6) +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) def gen_irblock(label, exprs_list): """ Returns an IRBlock. @@ -90,9 +90,9 @@ class IRATest(ira): """Fake IRA class for tests""" - def __init__(self, symbol_pool=None): + def __init__(self, loc_db=None): arch = Arch() - super(IRATest, self).__init__(arch, 32, symbol_pool) + super(IRATest, self).__init__(arch, 32, loc_db) self.IRDst = PC self.ret_reg = R @@ -116,7 +116,7 @@ def bloc2graph(irgraph, label=False, lines=True): out_blocks = [] for label in irgraph.graph.nodes(): if isinstance(label, LocKey): - label_name = irgraph.symbol_pool.loc_key_to_name(label) + label_name = irgraph.loc_db.loc_key_to_name(label) else: label_name = str(label) @@ -156,11 +156,11 @@ def bloc2graph(irgraph, label=False, lines=True): # Generate links for src, dst in irgraph.graph.edges(): if isinstance(src, LocKey): - src_name = irgraph.symbol_pool.loc_key_to_name(src) + src_name = irgraph.loc_db.loc_key_to_name(src) else: src_name = str(src) if isinstance(dst, LocKey): - dst_name = irgraph.symbol_pool.loc_key_to_name(dst) + dst_name = irgraph.loc_db.loc_key_to_name(dst) else: dst_name = str(dst) @@ -189,7 +189,7 @@ def dg2graph(graph, label=False, lines=True): out_blocks = [] for node in graph.nodes(): if isinstance(node, DependencyNode): - name = symbol_pool.loc_key_to_name(node.loc_key) + name = loc_db.loc_key_to_name(node.loc_key) node_name = "%s %s %s" % (name, node.element, node.line_nb) @@ -232,7 +232,7 @@ DNC3 = DependencyNode(LBL1, C, 0) # graph 1 -G1_IRA = IRATest(symbol_pool) +G1_IRA = IRATest(loc_db) G1_IRB0 = gen_irblock(LBL0, [[ExprAff(C, CST1)]]) G1_IRB1 = gen_irblock(LBL1, [[ExprAff(B, C)]]) @@ -245,7 +245,7 @@ G1_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G1_IRB0, G1_IRB1, G1_IRB2]] # graph 2 -G2_IRA = IRATest(symbol_pool) +G2_IRA = IRATest(loc_db) G2_IRB0 = gen_irblock(LBL0, [[ExprAff(C, CST1)]]) G2_IRB1 = gen_irblock(LBL1, [[ExprAff(B, CST2)]]) @@ -259,7 +259,7 @@ G2_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G2_IRB0, G2_IRB1, G2_IRB2]] # graph 3 -G3_IRA = IRATest(symbol_pool) +G3_IRA = IRATest(loc_db) G3_IRB0 = gen_irblock(LBL0, [[ExprAff(C, CST1)]]) G3_IRB1 = gen_irblock(LBL1, [[ExprAff(B, CST2)]]) @@ -276,7 +276,7 @@ G3_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G3_IRB0, G3_IRB1, # graph 4 -G4_IRA = IRATest(symbol_pool) +G4_IRA = IRATest(loc_db) G4_IRB0 = gen_irblock(LBL0, [[ExprAff(C, CST1)]]) G4_IRB1 = gen_irblock(LBL1, [[ExprAff(C, C + CST2)], @@ -295,7 +295,7 @@ G4_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G4_IRB0, G4_IRB1, G4_IRB2]] # graph 5 -G5_IRA = IRATest(symbol_pool) +G5_IRA = IRATest(loc_db) G5_IRB0 = gen_irblock(LBL0, [[ExprAff(B, CST1)]]) G5_IRB1 = gen_irblock(LBL1, [[ExprAff(B, B + CST2)], @@ -313,7 +313,7 @@ G5_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G5_IRB0, G5_IRB1, G5_IRB2]] # graph 6 -G6_IRA = IRATest(symbol_pool) +G6_IRA = IRATest(loc_db) G6_IRB0 = gen_irblock(LBL0, [[ExprAff(B, CST1)]]) G6_IRB1 = gen_irblock(LBL1, [[ExprAff(A, B)]]) @@ -325,7 +325,7 @@ G6_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G6_IRB0, G6_IRB1]]) # graph 7 -G7_IRA = IRATest(symbol_pool) +G7_IRA = IRATest(loc_db) G7_IRB0 = gen_irblock(LBL0, [[ExprAff(C, CST1)]]) G7_IRB1 = gen_irblock(LBL1, [[ExprAff(B, C)], [ExprAff(A, B)]]) @@ -339,7 +339,7 @@ G7_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G7_IRB0, G7_IRB1, G7_IRB2]] # graph 8 -G8_IRA = IRATest(symbol_pool) +G8_IRA = IRATest(loc_db) G8_IRB0 = gen_irblock(LBL0, [[ExprAff(C, CST1)]]) G8_IRB1 = gen_irblock(LBL1, [[ExprAff(B, C)], [ExprAff(C, D)]]) @@ -355,7 +355,7 @@ G8_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G8_IRB0, G8_IRB1, G8_IRB2]] # graph 10 -G10_IRA = IRATest(symbol_pool) +G10_IRA = IRATest(loc_db) G10_IRB1 = gen_irblock(LBL1, [[ExprAff(B, B + CST2)]]) G10_IRB2 = gen_irblock(LBL2, [[ExprAff(A, B)]]) @@ -367,7 +367,7 @@ G10_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G10_IRB1, G10_IRB2]]) # graph 11 -G11_IRA = IRATest(symbol_pool) +G11_IRA = IRATest(loc_db) G11_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1), ExprAff(B, CST2)]]) @@ -383,7 +383,7 @@ G11_IRA.blocks = dict([(irb.loc_key, irb) # graph 12 -G12_IRA = IRATest(symbol_pool) +G12_IRA = IRATest(loc_db) G12_IRB0 = gen_irblock(LBL0, [[ExprAff(B, CST1)]]) G12_IRB1 = gen_irblock(LBL1, [[ExprAff(A, B)], [ExprAff(B, B + CST2)]]) @@ -399,7 +399,7 @@ G12_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G12_IRB0, G12_IRB1, # graph 13 -G13_IRA = IRATest(symbol_pool) +G13_IRA = IRATest(loc_db) G13_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1)], #[ExprAff(B, A)], @@ -427,7 +427,7 @@ G13_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G13_IRB0, G13_IRB1, # graph 14 -G14_IRA = IRATest(symbol_pool) +G14_IRA = IRATest(loc_db) G14_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1)], [ExprAff(G14_IRA.IRDst, @@ -457,7 +457,7 @@ G14_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G14_IRB0, G14_IRB1, # graph 16 -G15_IRA = IRATest(symbol_pool) +G15_IRA = IRATest(loc_db) G15_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1)]]) G15_IRB1 = gen_irblock(LBL1, [[ExprAff(D, A + B)], @@ -474,7 +474,7 @@ G15_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G15_IRB0, G15_IRB1, # graph 16 -G16_IRA = IRATest(symbol_pool) +G16_IRA = IRATest(loc_db) G16_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1)]]) G16_IRB1 = gen_irblock(LBL1, [[ExprAff(R, D)]]) @@ -498,7 +498,7 @@ G16_IRA.blocks = dict([(irb.loc_key, irb) for irb in [G16_IRB0, G16_IRB1, # graph 17 -G17_IRA = IRATest(symbol_pool) +G17_IRA = IRATest(loc_db) G17_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1), ExprAff(D, CST2)]]) @@ -642,7 +642,7 @@ def flatNode(node): element = int(node.element.arg) else: RuntimeError("Unsupported type '%s'" % type(enode.element)) - name = symbol_pool.loc_key_to_name(node.loc_key) + name = loc_db.loc_key_to_name(node.loc_key) return (name, element, node.line_nb) @@ -741,7 +741,7 @@ def match_results(resultsA, resultsB, nodes): def get_flat_init_depnodes(depnodes): out = [] for node in depnodes: - name = symbol_pool.loc_key_to_name(node.loc_key) + name = loc_db.loc_key_to_name(node.loc_key) out.append((name, node.element.name, node.line_nb, diff --git a/test/analysis/dse.py b/test/analysis/dse.py index 4367f6f7..56de4d4e 100644 --- a/test/analysis/dse.py +++ b/test/analysis/dse.py @@ -69,17 +69,17 @@ class DSETest(object): def asm(self): mn_x86 = self.machine.mn - blocks, symbol_pool = parse_asm.parse_txt( + blocks, loc_db = parse_asm.parse_txt( mn_x86, self.arch_attrib, self.TXT, - symbol_pool=self.myjit.ir_arch.symbol_pool + loc_db=self.myjit.ir_arch.loc_db ) # fix shellcode addr - symbol_pool.set_offset(symbol_pool.getby_name("main"), 0x0) + loc_db.set_offset(loc_db.getby_name("main"), 0x0) output = StrPatchwork() - patches = asm_resolve_final(mn_x86, blocks, symbol_pool) + patches = asm_resolve_final(mn_x86, blocks, loc_db) for offset, raw in patches.items(): output[offset] = raw |