Example #1
0
def new(arch):

	tm = None
	if arch == sefi.arch.x86:
		tm = TargetMachine.x86()
	elif arch == sefi.arch.x86_64:
		tm = TargetMachine.x86_64()
	elif arch == sefi.arch.arm:
		tm = TargetMachine.arm()
	elif arch == sefi.arch.thumb1:
		tm = TargetMachine.thumb()
	else:
		tm = TargetMachine.lookup(arch)

	if not tm:
		raise ArchNotSupported("llvm does not recognize " + \
								"architecture %s" % arch)
	
	try:
		llvmdasm = llvm.mc.Disassembler(tm)
	except llvm.LLVMException as e:
		raise ArchNotSupported("llvm does not have a " + \
								"disassembler for %s" % arch)

	return LLVMDasm(llvmdasm, arch)
Example #2
0
def new(arch):

    tm = None
    if arch == sefi.arch.x86:
        tm = TargetMachine.x86()
    elif arch == sefi.arch.x86_64:
        tm = TargetMachine.x86_64()
    elif arch == sefi.arch.arm:
        tm = TargetMachine.arm()
    elif arch == sefi.arch.thumb1:
        tm = TargetMachine.thumb()
    else:
        tm = TargetMachine.lookup(arch)

    if not tm:
        raise ArchNotSupported("llvm does not recognize " + \
              "architecture %s" % arch)

    try:
        llvmdasm = llvm.mc.Disassembler(tm)
    except llvm.LLVMException as e:
        raise ArchNotSupported("llvm does not have a " + \
              "disassembler for %s" % arch)

    return LLVMDasm(llvmdasm, arch)
Example #3
0
            else:
                ops = ", ".join(map(lambda op: repr(op), inst.operands()))
                if isinstance(inst, mc.BadInstr):
                    print("\t0x%x (bad) ops = %s" % (addr, ops))
                else:
                    print("\t0x%x ops = %s" % (addr, ops))

                print("\t\topcode = 0x%x, flags = 0x%x, tsflags = 0x%x" % (inst.opcode, inst.flags, inst.ts_flags))
                for line in str(inst).split("\n"):
                    print("\t\t%-24s %s" % ("".join(map(lambda b: "%02x" % b, data))+":", line.strip()))

                for bp in branch_properties:
                    print("\t\t%-22s%r" % (bp+":", getattr(inst, bp)() ))


    x86 = TargetMachine.x86()
    print("x86: LE=%s" % x86.is_little_endian())
    print_instructions(Disassembler(x86), "\x01\xc3\xc3\xcc\x90")

    x86_64 = TargetMachine.x86_64()
    print("x86-64: LE=%s" % x86_64.is_little_endian())
    print_instructions(Disassembler(x86_64), "\x55\x48\x89\xe8")

    arm = TargetMachine.arm()
    print("arm: LE=%s" % arm.is_little_endian())
    code = [
        "\xe9\x2d\x48\x00",
        "\xea\x00\x00\x06",
        "\xe2\x4d\xd0\x20",
        "\xe2\x8d\xb0\x04",
        "\xe5\x0b\x00\x20",