Skip to content

Commit

Permalink
Fix mips32b cpu wrapper.
Browse files Browse the repository at this point in the history
Actually it were two different issues:
1. mips32b should be inherited from mips32l otherwise arch and regs
information are incorrect.
2. Parent constructor call infinite loop if big endian cpu created.
  • Loading branch information
nurmukhametov committed Jul 12, 2019
1 parent eefd5eb commit fdd3612
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions sibyl/engine/qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def __init__(self, *args, **kwargs):
}
self.pc_reg_name = "EIP"
self.pc_reg_value = csts.UC_X86_REG_EIP
super(self.__class__, self).__init__(*args, **kwargs)
super(UcWrapCPU_x86_32, self).__init__(*args, **kwargs)


class UcWrapCPU_x86_64(UcWrapCPU):
Expand All @@ -288,7 +288,7 @@ def __init__(self, *args, **kwargs):
}
self.pc_reg_name = "RIP"
self.pc_reg_value = csts.UC_X86_REG_RIP
super(self.__class__, self).__init__(*args, **kwargs)
super(UcWrapCPU_x86_64, self).__init__(*args, **kwargs)


class UcWrapCPU_arml(UcWrapCPU):
Expand Down Expand Up @@ -316,7 +316,7 @@ def __init__(self, *args, **kwargs):
}
self.pc_reg_name = "PC"
self.pc_reg_value = csts.UC_ARM_REG_PC
super(self.__class__, self).__init__(*args, **kwargs)
super(UcWrapCPU_arml, self).__init__(*args, **kwargs)

class UcWrapCPU_armtl(UcWrapCPU):
'''
Expand Down Expand Up @@ -345,13 +345,16 @@ def __init__(self, *args, **kwargs):
}
self.pc_reg_name = "PC"
self.pc_reg_value = csts.UC_ARM_REG_PC
super(self.__class__, self).__init__(*args, **kwargs)
super(UcWrapCPU_armtl, self).__init__(*args, **kwargs)

class UcWrapCPU_armb(UcWrapCPU_arml):

if unicorn:
uc_mode = unicorn.UC_MODE_ARM + unicorn.UC_MODE_BIG_ENDIAN

def __init__(self, *args, **kwargs):
super(UcWrapCPU_armb, self).__init__(*args, **kwargs)


class UcWrapCPU_mips32l(UcWrapCPU):

Expand Down Expand Up @@ -440,14 +443,17 @@ def __init__(self, *args, **kwargs):
}
self.pc_reg_name = "PC"
self.pc_reg_value = csts.UC_MIPS_REG_PC
super(self.__class__, self).__init__(*args, **kwargs)
super(UcWrapCPU_mips32l, self).__init__(*args, **kwargs)


class UcWrapCPU_mips32b(UcWrapCPU):
class UcWrapCPU_mips32b(UcWrapCPU_mips32l):

if unicorn:
uc_mode = unicorn.UC_MODE_MIPS32 + unicorn.UC_MODE_BIG_ENDIAN

def __init__(self, *args, **kwargs):
super(UcWrapCPU_mips32b, self).__init__(*args, **kwargs)


UcWrapCPU_x86_32.register("x86", 32)
UcWrapCPU_x86_64.register("x86", 64)
Expand Down

0 comments on commit fdd3612

Please sign in to comment.