예제 #1
0
파일: callret.py 프로젝트: weixu8/virtuoso
def remake_trace(trace):
    trace = list(enumerate(t for i, t in trace))
    tbs = make_tbs(trace)
    tbdict = make_tbdict(tbs)
    cfg = make_slice_cfg(tbs)
    return trace, tbs, tbdict, cfg
예제 #2
0
def remake_trace(trace):
    trace = list(enumerate(t for i,t in trace))
    tbs = make_tbs(trace)
    tbdict = make_tbdict(tbs)
    cfg = make_slice_cfg(tbs)
    return trace, tbs, tbdict, cfg
예제 #3
0
파일: callret.py 프로젝트: weixu8/virtuoso
        if is_memop(insn):
            uses_set -= set(["A0"])

        if defs_set & work:
            work = (work - defs_set) | uses_set
            if debug: print i, repr(insn)

    if debug: print "Working set at end:", work
    return source in work


if __name__ == "__main__":
    trace, inbufs, outbufs = load_trace(file(sys.argv[1]))
    tbs = make_tbs(trace)
    tbdict = make_tbdict(tbs)
    cfg = make_slice_cfg(tbs)

    alloc_ctr = counter()
    alloc_calls = defaultdict(list)
    alloc_rets = []
    for m, argbytes, name in mallocs:
        for idx in range(len(
                tbdict[m])):  # This allows us to change the tbdict during
            tb = tbdict[m][idx]  # iteration without getting stale data.

            i = tbs.index(tb)
            callsite = tbs[i - 1]

            # Find the return address and get its TB object
            # Note: this might fail if we have nested calls, but worry
            # about that later. The "right" solution is a shadow stack
예제 #4
0
        # the derivation of the address of a buffer.
        if is_memop(insn):
            uses_set -= set(["A0"])

        if defs_set & work:
            work = (work - defs_set) | uses_set
            if debug: print i,repr(insn)

    if debug: print "Working set at end:", work
    return source in work

if __name__ == "__main__":
    trace, inbufs, outbufs = load_trace(file(sys.argv[1]))
    tbs = make_tbs(trace)
    tbdict = make_tbdict(tbs)
    cfg = make_slice_cfg(tbs)
    
    alloc_ctr = counter()
    alloc_calls = defaultdict(list)
    alloc_rets = []
    for m,argbytes,name in mallocs:
        for idx in range(len(tbdict[m])):  # This allows us to change the tbdict during
            tb = tbdict[m][idx]       # iteration without getting stale data.

            i = tbs.index(tb)
            callsite = tbs[i-1]
            
            # Find the return address and get its TB object
            # Note: this might fail if we have nested calls, but worry
            # about that later. The "right" solution is a shadow stack
            retaddr = find_retaddr(callsite)