def do_remove_empty_assignblks(self, ssa, head): """ Remove empty assignblks @head: Location instance of the graph head """ modified = remove_empty_assignblks(ssa.graph) return modified
def do_dead_simp_ircfg(self, ircfg, head): """ Apply: - dead_simp - remove_empty_assignblks - merge_blocks on the @ircfg until reaching fix point Return True if the graph has been modified @ircfg: IRCFG instance to simplify @head: Location instance of the ircfg head """ modified = dead_simp(self.ir_arch, ircfg) modified |= remove_empty_assignblks(ircfg) modified |= merge_blocks(ircfg, set([head])) return modified
help="Apply simplifications rules (liveness, graph simplification, ...)") args = parser.parse_args() machine = Machine("x86_32") loc_db = LocationDB() cont = Container.from_stream(open(args.filename, 'rb'), loc_db) mdis = machine.dis_engine(cont.bin_stream, loc_db=loc_db) ir_arch = machine.ira(mdis.loc_db) addr = int(args.address, 0) deadrm = DeadRemoval(ir_arch) asmcfg = mdis.dis_multiblock(addr) ircfg = ir_arch.new_ircfg_from_asmcfg(asmcfg) entry_points = set([mdis.loc_db.get_offset_location(addr)]) init_infos = ir_arch.arch.regs.regs_init cst_propag_link = propagate_cst_expr(ir_arch, ircfg, addr, init_infos) if args.simplify: ircfg.simplify(expr_simp) modified = True while modified: modified = False modified |= deadrm(ircfg) modified |= remove_empty_assignblks(ircfg) modified |= merge_blocks(ircfg, entry_points) open("%s.propag.dot" % args.filename, 'w').write(ircfg.dot())
help="Apply simplifications rules (liveness, graph simplification, ...)") args = parser.parse_args() machine = Machine("x86_32") cont = Container.from_stream(open(args.filename, 'rb')) mdis = machine.dis_engine(cont.bin_stream, loc_db=cont.loc_db) ir_arch = machine.ira(mdis.loc_db) addr = int(args.address, 0) asmcfg = mdis.dis_multiblock(addr) ircfg = ir_arch.new_ircfg_from_asmcfg(asmcfg) entry_points = set([mdis.loc_db.get_offset_location(addr)]) init_infos = ir_arch.arch.regs.regs_init cst_propag_link = propagate_cst_expr(ir_arch, ircfg, addr, init_infos) if args.simplify: ircfg.simplify(expr_simp) modified = True while modified: modified = False modified |= dead_simp(ir_arch, ircfg) modified |= remove_empty_assignblks(ircfg) modified |= merge_blocks(ircfg, entry_points) open("%s.propag.dot" % args.filename, 'w').write(ircfg.dot())