コード例 #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
コード例 #2
0
def save_cfg(cfg, suffix):
    with open(cfg.filename + suffix, "w") as out:
        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
コード例 #3
0
    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)
コード例 #4
0
ファイル: apply_xform.py プロジェクト: pfalcon/ScratchABlock
    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)
コード例 #5
0
from utils import maybesorted


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