Пример #1
0
def __main__():
    if args.annotate_calls:
        core.Inst.annotate_calls = True

    if not args.funcdb:
        if os.path.isdir(args.file):
            # For an input as directory, use this *input* directory
            proj_dir = args.file
        else:
            # For a single file, use containing directory
            proj_dir = os.path.dirname(args.file) or "."

        args.funcdb = proj_dir + "/funcdb.yaml"
        log.info("Using funcdb: %s", args.funcdb)
        # Load binary data
        import bindata
        bindata.init(proj_dir)
        # Load symtab
        if os.path.exists(proj_dir + "/symtab.txt"):
            log.info("Using symtab:", proj_dir + "/symtab.txt")
            progdb.load_symtab(proj_dir + "/symtab.txt")

    input = args.file
    output = args.output

    iter_no = 0
    while True:
        changed = one_iter(input, output, iter_no)
        if not args.iter:
            break
        if args.debug:
            print("=== Done iteration %d ===" % iter_no)
        if not changed:
            break
        iter_no += 1
        p = CFGPrinter(cfg, out)
        p.print()


def save_cfg_layer(cfg_layer, suffix):
    for name, cfg in cfg_layer.items():
        save_cfg(cfg, suffix)


progdb.load_funcdb(sys.argv[1] + "/funcdb.yaml")
# Load binary data
import bindata
bindata.init(sys.argv[1])
# Load symtab
if os.path.exists(sys.argv[1] + "/symtab.txt"):
    progdb.load_symtab(sys.argv[1] + "/symtab.txt")

callgraph = xform_inter.build_callgraph()

with open("cg-current.dot", "w") as out:
    dot.dot(callgraph, out, is_cfg=False)

#for func in callgraph.iter_rev_postorder():
#    print(func, callgraph[func])

CFG_MAP = collections.defaultdict(dict)

import script_i_prepare

for full_name in glob.glob(sys.argv[1] + "/*.lst"):
    p = Parser(full_name)
Пример #3
0
        if os.path.isdir(args.file):
            # For an input as directory, use this *input* directory
            proj_dir = args.file
        else:
            # For a single file, use containing directory
            proj_dir = os.path.dirname(args.file) or "."

        args.funcdb = proj_dir + "/funcdb.yaml"
        log.info("Using funcdb: %s", args.funcdb)
        # Load binary data
        import bindata
        bindata.init(proj_dir)
        # Load symtab
        if os.path.exists(proj_dir + "/symtab.txt"):
            log.info("Using symtab:", proj_dir + "/symtab.txt")
            progdb.load_symtab(proj_dir + "/symtab.txt")

    input = args.file
    output = args.output

    iter_no = 0
    while True:
        changed = one_iter(input, output, iter_no)
        if not args.iter:
            break
        if args.debug:
            print("=== Done iteration %d ===" % iter_no)
        if not changed:
            break
        iter_no += 1
Пример #4
0
        if os.path.isdir(args.file):
            # For an input as directory, use this *input* directory
            proj_dir = args.file
        else:
            # For a single file, use containing directory
            proj_dir = os.path.dirname(args.file) or "."

        args.funcdb = proj_dir + "/funcdb.yaml"
        log.info("Using funcdb: %s", args.funcdb)
        # Load binary data
        import bindata
        bindata.init(proj_dir)
        # Load symtab
        if os.path.exists(proj_dir + "/symtab.txt"):
            log.info("Using symtab:", proj_dir + "/symtab.txt")
            progdb.load_symtab(proj_dir + "/symtab.txt")

    input = args.file
    output = args.output

    iter_no = 0
    while True:
        changed = one_iter(input, output, iter_no)
        if not args.iter:
            break
        if args.debug:
            print("=== Done iteration %d ===" % iter_no)
        if not changed:
            break
        iter_no += 1
Пример #5
0
core.Inst.annotate_calls = True


def save_cfg_layer(cfg_layer, suffix):
    for name, cfg in cfg_layer.items():
        save_cfg(cfg, suffix)


progdb.load_funcdb(sys.argv[1] + "/funcdb.yaml")
# Load binary data
import bindata
bindata.init(sys.argv[1])
# Load symtab
if os.path.exists(sys.argv[1] + "/symtab.txt"):
    progdb.load_symtab(sys.argv[1] + "/symtab.txt")

callgraph = xform_inter.build_callgraph()

with open("cg-current.dot", "w") as out:
    dot.dot(callgraph, out, is_cfg=False)

#for func in callgraph.iter_rev_postorder():
#    print(func, callgraph[func])

CFG_MAP = collections.defaultdict(dict)

import script_i_prepare

for full_name in glob.glob(sys.argv[1] + "/*.lst"):
    p = Parser(full_name)