Example #1
0
def calc_callsites_live_out(cg, callee):
    """Calculate function's callsites_live_out property.

    Go thru function's callers (using callgraph), and union their
    calls_live_out information pertinent to this function.
    """

    callers = maybesorted(cg.pred(callee))
    # If there're no callers, will return empty set, which
    # is formally correct - if there're no callers, the
    # function is dead. However, realistically that means
    # that callers aren't known, and we should treat that
    # specially.
    call_lo_union = set()
    for c in callers:
        clo = progdb.FUNC_DB[c].get("calls_live_out", [])
        #print("  %s: calls_live_out: %s" % (c, utils.repr_stable(clo)))
        for bbaddr, callee_expr, live_out in clo:
            if is_addr(callee_expr) and callee_expr.addr == callee:
                print("  %s: calls_live_out[%s]: %s" %
                      (c, callee,
                       utils.repr_stable((bbaddr, callee_expr, live_out))))
                call_lo_union.update(live_out)

    progdb.FUNC_DB[callee]["callsites_live_out"] = call_lo_union

    return call_lo_union
Example #2
0
def calc_callsites_live_out(cg, callee):
    """Calculate function's callsites_live_out property.

    Go thru function's callers (using callgraph), and union their
    calls_live_out information pertinent to this function.
    """

    callers = maybesorted(cg.pred(callee))
    # If there're no callers, will return empty set, which
    # is formally correct - if there're no callers, the
    # function is dead. However, realistically that means
    # that callers aren't known, and we should treat that
    # specially.
    call_lo_union = set()
    for c in callers:
        clo = progdb.FUNC_DB[c].get("calls_live_out", [])
        #print("  %s: calls_live_out: %s" % (c, utils.repr_stable(clo)))
        for bbaddr, callee_expr, live_out in clo:
            if is_addr(callee_expr) and callee_expr.addr == callee:
                print("  %s: calls_live_out[%s]: %s" % (c, callee, utils.repr_stable((bbaddr, callee_expr, live_out))))
                call_lo_union.update(live_out)

    progdb.FUNC_DB[callee]["callsites_live_out"] = call_lo_union

    return call_lo_union
 def ext_repr(x):
     if is_addr(x):
         return x.addr
     if is_value(x):
         return hex(x.val)
     if is_expr(x):
         if x.op == "+" and len(x.args) == 2:
             if is_value(x.args[1]):
                 x = EXPR("+", [x.args[1], x.args[0]])
         return str(x)
     return str(x)
Example #4
0
 def ext_repr(x):
     if is_addr(x):
         return x.addr
     if is_value(x):
         return hex(x.val)
     if is_expr(x):
         if x.op == "+" and len(x.args) == 2:
             if is_value(x.args[1]):
                 x = EXPR("+", [x.args[1], x.args[0]])
         return str(x)
     return str(x)
Example #5
0
def calc_callsites_live_out(cg, callee):
    callers = maybesorted(cg.pred(callee))
    # If there're no callers, will return empty set, which
    # is formally correct - if there're no callers, the
    # function is dead. However, realistically that means
    # that callers aren't known, and we should treat that
    # specially.
    call_lo_union = set()
    for c in callers:
        clo = progdb.FUNC_DB[c].get("calls_live_out", [])
        print("%s: calls_live_out: %s" % (c, clo))
        for bbaddr, callee_expr, live_out in clo:
            if is_addr(callee_expr) and callee_expr.addr == callee:
                call_lo_union.update(live_out)
    return call_lo_union