Esempio n. 1
0
    def getEq(self, x, y):

        assert (x.getSizeInBytes() == y.getSizeInBytes())

        conds = []

        if x.isMem() and y.isMem():

            srcs = x.getLocations()
            dsts = y.getLocations()

            for (src, dst) in zip(srcs, dsts):
                sname = Memvars.read(src)
                src_array = mkArray(sname)

                sname = Memvars.read(dst)
                dst_array = mkArray(sname)

                conds.append(
                    src_array[src.getIndex()] == dst_array[dst.getIndex()])

            return conds

        elif x.isMem() and y | iss | ImmOp:
            #assert(0)
            srcs = x.getLocations()
            dsts = mkByteListConst(y)

            #endiannes
            dsts.reverse()

            for (src, dst) in zip(srcs, dsts):
                #print str(x)
                sname = Memvars.read(src)
                src_array = mkArray(sname)
                conds.append(src_array[src.getIndex()] == dst)

            return conds
        else:

            src, dst = self.getOperands([x, y])
            return [src == dst]
Esempio n. 2
0
  def getEq(self, x, y):
    
    assert(x.getSizeInBytes() == y.getSizeInBytes())
    
    conds = []
    
    if x.isMem() and y.isMem():
      
      srcs = x.getLocations()
      dsts = y.getLocations()
      
      for (src,dst) in zip(srcs, dsts):
        sname = Memvars.read(src)
        src_array = mkArray(sname)
        
        sname = Memvars.read(dst)
        dst_array = mkArray(sname)
        
        conds.append(src_array[src.getIndex()] == dst_array[dst.getIndex()])
      
      return conds
    
    elif x.isMem() and y |iss| ImmOp:
      #assert(0)
      srcs = x.getLocations()
      dsts = mkByteListConst(y)

      #endiannes
      dsts.reverse()
    
      for (src,dst) in zip(srcs, dsts):
        #print str(x)
        sname = Memvars.read(src)
        src_array = mkArray(sname)
        conds.append(src_array[src.getIndex()] == dst)
    
      return conds
    else:

      src, dst = self.getOperands([x,y])      
      return [src == dst]  
Esempio n. 3
0
 def getEq(self, x, y):
   
   if x.isMem() and y.isMem():
     src_name, src_offset = Memvars.read(x)
     src_array = mkArray(src_name)
     
     dst_name, dst_offset = Memvars.read(y)
     dst_array = mkArray(dst_name)
     return [src_array[src_offset] == dst_array[dst_offset]]
   
   elif x.isMem() and y.isImm():
     
     assert(y.size == 1) # y should be a BYTE
     
     src_name, src_offset = Memvars.read(x)
     src_array = mkArray(src_name)
     
     dst = self.getOperands([y])
     return [src_array[src_offset] == dst[0]]
   else:
     src, dst = self.getOperands([x,y])
     return [src == dst]  
Esempio n. 4
0
    def getEq(self, x, y):

        if x.isMem() and y.isMem():
            src_name, src_offset = Memvars.read(x)
            src_array = mkArray(src_name)

            dst_name, dst_offset = Memvars.read(y)
            dst_array = mkArray(dst_name)
            return [src_array[src_offset] == dst_array[dst_offset]]

        elif x.isMem() and y.isImm():

            assert (y.size == 1)  # y should be a BYTE

            src_name, src_offset = Memvars.read(x)
            src_array = mkArray(src_name)

            dst = self.getOperands([y])
            return [src_array[src_offset] == dst[0]]
        else:
            src, dst = self.getOperands([x, y])
            return [src == dst]
Esempio n. 5
0
  def getEq(self):
    sname, offset = Memvars.read(self.ins.getReadMemOperands()[0])
    array = mkArray(sname)
    
    dst = (self.write_operands)[0]
    dsts = map(lambda b: z3.BitVec(b,8), dst.get_bytes())
    dsts.reverse()    

    conds = []
    
    for (i,dst) in zip(range(dst.size), dsts):
      conds.append(array[offset+i] == dst)

    return conds
Esempio n. 6
0
    def getEq(self):
        sname, offset = Memvars.read(self.ins.getReadMemOperands()[0])
        array = mkArray(sname)

        dst = (self.write_operands)[0]
        dsts = map(lambda b: z3.BitVec(b, 8), dst.get_bytes())
        dsts.reverse()

        conds = []

        for (i, dst) in zip(range(dst.size), dsts):
            conds.append(array[offset + i] == dst)

        return conds
Esempio n. 7
0
  def getEq(self):
    
    conds = []
    
    src = self.ins.getReadMemOperands()[0]
    srcs = src.getLocations()
    
    dst = (self.write_operands)[0]
    if dst.isVar():
      dsts = mkByteListVar(dst)    
    else:
      dsts = mkByteListConst(dst)
    
    #endianness
    dsts.reverse()

    for (src,dst) in zip(srcs, dsts):
      sname = Memvars.read(src)
      array = mkArray(sname)
      conds.append(array[src.getIndex()] == dst)
    
    return conds
Esempio n. 8
0
    def getEq(self):

        conds = []

        src = self.ins.getReadMemOperands()[0]
        srcs = src.getLocations()

        dst = (self.write_operands)[0]
        if dst.isVar():
            dsts = mkByteListVar(dst)
        else:
            dsts = mkByteListConst(dst)

        #endianness
        dsts.reverse()

        for (src, dst) in zip(srcs, dsts):
            sname = Memvars.read(src)
            array = mkArray(sname)
            conds.append(array[src.getIndex()] == dst)

        return conds
Esempio n. 9
0
  def getEq(self, mlocs):
    #assert(0)
    #for loc in mlocs:
    #  print loc, "--",
    #print ""
    r = []
    src = self.src
    srcs = src.getLocations()
    sname = Memvars.read(srcs[0])

    read_array = mkArray(sname)

    dst = self.dst 
    dsts = dst.getLocations()
    
    old_sname, new_sname = Memvars.write(dsts[0])
    
    old_array = mkArray(old_sname)
    array = mkArray(new_sname)

    for (src_loc,dst_loc) in zip(srcs, dsts):

      read_val = z3.Select(read_array, src_loc.getIndex()) 
      if dst_loc in mlocs:
        array = z3.Store(array, dst_loc.getIndex(), read_val)
      
      r.append(read_val <> 0)
 
    r.append((old_array == array))
    #print r
    #assert(0)
    return r


    #print self.src, self.dst
    
    #if (self.src.isReg()):
    #  src = self.src.name
    #  self.src.size = self.size
    #  srcs = self.getOperands([self.src])
    #  print srcs
    #else:
    #  assert(0)
  
    #old_sname, new_sname, offset = Memvars.write(self.dst)
      
    #old_array = mkArray(old_sname)
    #array = mkArray(new_sname)
    
    #for i in range(self.size):
      
    #  dst_op = Operand(self.dst.mem_source+"@"+str(offset+i), "BYTE")
    #  src_var = z3.BitVec(src+":"+str(i)+"(0)",8)
      
    #  if (dst_op in mvars):
    #    array = z3.Store(array, offset+i, src_var)

    #  r.append(src_var <> 0)
      
    #r.append((old_array == array))

    return r
Esempio n. 10
0
    def getEq(self, mlocs):
        #assert(0)
        #for loc in mlocs:
        #  print loc, "--",
        #print ""
        r = []
        src = self.src
        srcs = src.getLocations()
        sname = Memvars.read(srcs[0])

        read_array = mkArray(sname)

        dst = self.dst
        dsts = dst.getLocations()

        old_sname, new_sname = Memvars.write(dsts[0])

        old_array = mkArray(old_sname)
        array = mkArray(new_sname)

        for (src_loc, dst_loc) in zip(srcs, dsts):

            read_val = z3.Select(read_array, src_loc.getIndex())
            if dst_loc in mlocs:
                array = z3.Store(array, dst_loc.getIndex(), read_val)

            r.append(read_val <> 0)

        r.append((old_array == array))
        #print r
        #assert(0)
        return r

        #print self.src, self.dst

        #if (self.src.isReg()):
        #  src = self.src.name
        #  self.src.size = self.size
        #  srcs = self.getOperands([self.src])
        #  print srcs
        #else:
        #  assert(0)

        #old_sname, new_sname, offset = Memvars.write(self.dst)

        #old_array = mkArray(old_sname)
        #array = mkArray(new_sname)

        #for i in range(self.size):

        #  dst_op = Operand(self.dst.mem_source+"@"+str(offset+i), "BYTE")
        #  src_var = z3.BitVec(src+":"+str(i)+"(0)",8)

        #  if (dst_op in mvars):
        #    array = z3.Store(array, offset+i, src_var)

        #  r.append(src_var <> 0)

        #r.append((old_array == array))

        return r