Ejemplo n.º 1
0
 def map(self):
     if self._map is None:
         self._map = mapper(self)
         self.helper(self._map)
     if self.misc['func']:
         return self.misc['func'].map
     return self._map
Ejemplo n.º 2
0
 def map(self):
     if self._map is None:
         self._map = mapper(self)
         self.helper(self._map)
     if self.misc['func']:
         return self.misc['func'].map
     return self._map
Ejemplo n.º 3
0
def test_compose2(m,x,y,z,w):
    al = conf.Cas.noaliasing
    conf.Cas.noaliasing = False
    mx = mem(x,32)
    my = mem(y,32)
    mxx = mem(x+2,32)
    m[mx] = cst(0xdeadbeef,32)
    m[my] = cst(0xbabebabe,32)
    m[mxx] = cst(0x01234567,32)
    m[z] = m(mem(w,32))
    m[w] = m(my)
    mprev = mapper()
    mprev[x] = z
    mprev[y] = z
    mprev[w] = z
    cm = m<<mprev
    # x==y in prev so mx==my:
    assert cm(mx) == 0x4567babe
    assert cm(my) == 0x4567babe
    # aliasing is possible so z
    # receives mem(z) AFTER the 2
    # memory writes in mx/my,
    # i.e cm(my):
    assert cm(w)==cm(my)
    conf.Cas.noaliasing = al
Ejemplo n.º 4
0
def test_compose1(m,x,y,z,w):
    al = conf.Cas.noaliasing
    conf.Cas.noaliasing = True
    tr = conf.Cas.memtrace
    conf.Cas.memtrace = True
    mx = mem(x,32)
    my = mem(y,32)
    mxx = mem(x+2,32)
    m[mx] = cst(0xdeadbeef,32)
    m[my] = cst(0xbabebabe,32)
    m[mxx] = cst(0x01234567,32)
    m[z] = m(mem(w,32))
    mprev = mapper()
    mprev[x] = z
    mprev[y] = z
    mprev[w] = z
    cm = m<<mprev
    # x == y in prev so mx==my:
    assert cm(mx) == 0x4567babe
    assert cm(my) == 0x4567babe
    # no aliasing is assumed so z
    # receives mem(w) BEFORE m,
    # i.e mem(z):
    assert cm(z) == mem(z,32)
    conf.Cas.noaliasing = al
    conf.Cas.memtrace = tr
Ejemplo n.º 5
0
def test_merge(m,r,w,x,y,a,b):
    m[r] = w+3
    mm = m.assume([x==3,w==0,y>0])
    m2 = mapper()
    m2[r] = a+b
    mm2 = m2.assume([w==1,y<0])
    mm3 = merge(mm,mm2)
    assert mm3(r)._is_vec
    assert mm3(r).l[0] == 0x3
    m3 = mapper()
    m3[r] = x
    m3[w] = cst(0x1000,32)
    mm4 = merge(mm3,m3)
    mm4w = mm4(w)
    assert mm4w._is_vec
    assert w in mm4w
    assert 0x1000 in mm4w
Ejemplo n.º 6
0
 def map(self):
     """the propery providing the symbolic map of the block, or if this
     block is the entry of a :class:`func` object, the map of the
     function it belongs to.
     """
     if self._map is None:
         self._map = mapper(self.instr)
         self.helper(self._map)
     if self.misc['func']:
         return self.misc['func'].map
     return self._map
Ejemplo n.º 7
0
 def __init__(self, x):
     self.map = mapper()
     x(self.map)
     self.name = str(x)
     self.address = x
     self.length = 0
     self.misc = defaultdict(lambda: 0)
     doc = x.stub(x.ref).func_doc
     if doc:
         for (k, v) in tag.list():
             if (k in doc) or (v in doc):
                 self.misc[v] = 1
Ejemplo n.º 8
0
 def __init__(self, x):
     self.map = mapper()
     x(self.map)
     self.name = str(x)
     self.address = x
     self.length = 0
     self.misc  = defaultdict(lambda :0)
     doc = x.stub(x.ref).func_doc
     if doc:
         for (k,v) in tag.list():
             if (k in doc) or (v in doc):
                 self.misc[v] = 1
Ejemplo n.º 9
0
 def __init__(self, x):
     self.map = mapper()
     x(self.map)
     self.name = str(x)
     self.address = x
     self.instr = []
     self.length = 0
     self.misc = defaultdict(_code_misc_default)
     doc = x.stub(x.ref).func_doc
     if doc:
         for (k, v) in tag.list():
             if (k in doc) or (v in doc):
                 self.misc[v] = 1
     self.view = xfuncView(self)
Ejemplo n.º 10
0
def test_compose2(m,x,y,z,w):
    mx = mem(x,32)
    my = mem(y,32)
    mxx = mem(x+2,32)
    m[mx] = cst(0xdeadbeef,32)
    m[my] = cst(0xbabebabe,32)
    m[mxx] = cst(0x01234567,32)
    m[z] = m(mem(w,32))
    m[w] = m(my)
    mprev = mapper()
    mprev[x] = z
    mprev[y] = z
    cm = m<<mprev
    assert cm(my) == 0x4567babe
    assert cm(w)==cm(my)
Ejemplo n.º 11
0
def test_aliasing3(m,x,y,a):
    m.clear()
    m[mem(x-4,32)] = cst(0x44434241,32)
    m[mem(x-8,32)] = y
    m[x] = x-8
    res = m(mem(x+2,32))
    assert res._is_cmp
    assert res[16:32] == 0x4241
    assert res[0:16] == y[16:32]
    m[mem(a,8)] = cst(0xCC,8)
    res = m(mem(x+2,32))
    assert res._is_mem and len(res.mods)==3
    mprev = mapper()
    mprev[a] = x-4
    res = mprev(res)
    assert res[16:24] == 0xcc
Ejemplo n.º 12
0
def test_compose1(m,x,y,z,w):
    al = conf.Cas.noaliasing
    conf.Cas.noaliasing = True
    mx = mem(x,32)
    my = mem(y,32)
    mxx = mem(x+2,32)
    m[mx] = cst(0xdeadbeef,32)
    m[my] = cst(0xbabebabe,32)
    m[mxx] = cst(0x01234567,32)
    m[z] = m(mem(w,32))
    mprev = mapper()
    mprev[x] = z
    mprev[y] = z
    mprev[w] = z
    cm = m<<mprev
    assert cm(my) == 0x4567babe
    assert cm(z) == 0x4567babe
    conf.Cas.noaliasing = al