def parse_disasm_def(fname): global CPU_PLUGIN with open(fname) as f: for l in f: l = filter_config_line(l) if not l: continue #print(l) while True: if not l: #return break if l[0] == "[": section = l[1:-1] print("Processing section: %s" % section) if section == "entrypoints": l = parse_entrypoints(f) elif section == "subareas": l = parse_subareas(f) else: assert 0, "Unknown section: " + section else: break if not l: break if l.startswith("load"): args = l.split() if args[2][0] in string.digits: addr = int(args[2], 0) print("Loading %s @0x%x" % (args[1], addr)) engine.ADDRESS_SPACE.load_content(open(args[1], "rb"), addr) else: print("Loading %s (%s plugin)" % (args[1], args[2])) loader = __import__(args[2]) load_target_file(loader, args[1]) elif l.startswith("cpu "): args = l.split() CPU_PLUGIN = __import__(args[1]) if hasattr(CPU_PLUGIN, "arch_id"): engine.set_arch_id(CPU_PLUGIN.arch_id) print("Loading CPU plugin %s" % (args[1])) elif l.startswith("show bytes "): args = l.split() APP.show_bytes = int(args[2]) elif l.startswith("area "): args = l.split() assert len(args) == 4 start, end = parse_range(args[2]) a = engine.ADDRESS_SPACE.add_area(start, end, { "name": args[1], "access": args[3].upper() }) print("Adding area: %s" % engine.str_area(a)) else: assert 0, "Unknown directive: " + l
def parse_disasm_def(fname): global CPU_PLUGIN with open(fname) as f: for l in f: l = filter_config_line(l) if not l: continue #print(l) while True: if not l: #return break if l[0] == "[": section = l[1:-1] print("Processing section: %s" % section) if section == "entrypoints": l = parse_entrypoints(f) elif section == "subareas": l = parse_subareas(f) else: assert 0, "Unknown section: " + section else: break if not l: break if l.startswith("load"): args = l.split() if args[2][0] in string.digits: addr = str2int(args[2]) print("Loading %s @0x%x" % (args[1], addr)) engine.ADDRESS_SPACE.load_content(open(args[1], "rb"), addr) else: print("Loading %s (%s plugin)" % (args[1], args[2])) loader = __import__(args[2]) load_target_file(loader, args[1]) elif l.startswith("cpu "): args = l.split() CPU_PLUGIN = __import__(args[1]) if hasattr(CPU_PLUGIN, "arch_id"): engine.set_arch_id(CPU_PLUGIN.arch_id) print("Loading CPU plugin %s" % (args[1])) elif l.startswith("show bytes "): args = l.split() APP.show_bytes = int(args[2]) elif l.startswith("area "): args = l.split() assert len(args) == 4 start, end = parse_range(args[2]) a = engine.ADDRESS_SPACE.add_area(start, end, {"name": args[1], "access": args[3].upper()}) print("Adding area: %s" % engine.str_area(a)) else: assert 0, "Unknown directive: " + l