| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Macaw.AbsDomain.StackAnalysis
Description
This module defines a relational abstract domain for tracking registers and stack addresses. The model records when one of these values is known to be equal to the current pointer stack frame. This domain also tracks equalities between nodes so that analysis algorithms built on top of this are modulo known equivalences between registers and stack locations.
The theory is defined over bitvector with a predefined
"address width" addrWidth for the number of bits in the
address space
p := t = u | t = stack_frame + c | t = uext u w (1 <= width u && width u < w) t := r (@r@ is a register) | *(stack_frame + c)
c is a signed addrWidth-bit bitvector. stack_frame denotes
a addrWidth-bit bitvector for the stack frame. w is a width
parameter.
Given a set of axioms using the constraint P we have the following
proof rules:
A,p |= p (assumption) A |= t = t (reflexivity) A |= t = u => A |= u = t (symmetry) A |= t = u && A |= u = v => A |= t = v (transitivity) A |= t = uext u w && A |= u = uext v w' => A |= t = uext v w (double uext) A |= t = uext u w && A |= u = v => A |= t = uext v w (uext congruence)
Synopsis
- data BlockStartStackConstraints arch
- data StackEqConstraint (r :: Type -> Type) (tp :: Type) where
- IsStackOff :: forall (r :: Type -> Type). !(MemInt (RegAddrWidth r)) -> StackEqConstraint r ('BVType (RegAddrWidth r))
- EqualLoc :: forall (r :: Type -> Type) (tp :: Type). !(BoundLoc r tp) -> StackEqConstraint r tp
- IsUExt :: forall (u :: Natural) (w :: Natural) (r :: Type -> Type). (1 <= u, (u + 1) <= w) => !(BoundLoc r (BVType u)) -> !(NatRepr w) -> StackEqConstraint r ('BVType w)
- ppBlockStartStackConstraints :: ShowF (ArchReg arch) => BlockStartStackConstraints arch -> [Doc ann]
- fnEntryBlockStartStackConstraints :: RegisterInfo (ArchReg arch) => BlockStartStackConstraints arch
- ppStackEqConstraint :: forall (r :: Type -> Type) ann (tp :: Type). ShowF r => Doc ann -> StackEqConstraint r tp -> Doc ann
- blockStartLocExpr :: forall arch (tp :: Type) ids. (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch)) => BlockStartStackConstraints arch -> BoundLoc (ArchReg arch) tp -> StackExpr arch ids tp
- blockStartLocStackOffset :: forall arch (tp :: Type). (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch)) => BlockStartStackConstraints arch -> BoundLoc (ArchReg arch) tp -> Maybe (MemInt (ArchAddrWidth arch))
- data StackOffConstraint (r :: Type -> Type) (tp :: Type) where
- StackOffCns :: forall (r :: Type -> Type). !(MemInt (RegAddrWidth r)) -> StackOffConstraint r ('BVType (RegAddrWidth r))
- UExtCns :: forall (u :: Natural) (w :: Natural) (r :: Type -> Type). (1 <= u, (u + 1) <= w) => !(BoundLoc r (BVType u)) -> !(NatRepr w) -> StackOffConstraint r ('BVType w)
- blockStartLocRepAndCns :: forall arch (tp :: Type). (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch)) => BlockStartStackConstraints arch -> BoundLoc (ArchReg arch) tp -> (BoundLoc (ArchReg arch) tp, Maybe (StackOffConstraint (ArchReg arch) tp))
- data BoundLoc (r :: Type -> Type) (tp :: Type) where
- joinBlockStartStackConstraints :: (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch), HasRepr (ArchReg arch) TypeRepr) => BlockStartStackConstraints arch -> BlockStartStackConstraints arch -> Changed s (BlockStartStackConstraints arch, JoinClassMap (ArchReg arch))
- type JoinClassMap (r :: Type -> Type) = MapF (JoinClassPair (BoundLoc r)) (BoundLoc r)
- data JoinClassPair (key :: k -> Type) (tp :: k) = JoinClassPair !(key tp) !(key tp)
- data BlockIntraStackConstraints arch ids
- mkBlockIntraStackConstraints :: (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch)) => BlockStartStackConstraints arch -> BlockIntraStackConstraints arch ids
- biscInitConstraints :: BlockIntraStackConstraints arch ids -> BlockStartStackConstraints arch
- intraStackValueExpr :: forall arch ids (tp :: Type). (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch)) => BlockIntraStackConstraints arch ids -> Value arch ids tp -> StackExpr arch ids tp
- data StackExpr arch ids (tp :: Type) where
- ClassRepExpr :: forall arch (tp :: Type) ids. !(BoundLoc (ArchReg arch) tp) -> StackExpr arch ids tp
- UninterpAssignExpr :: forall ids (tp :: Type) arch. !(AssignId ids tp) -> !(AssignRhs arch (Value arch ids) tp) -> StackExpr arch ids tp
- StackOffsetExpr :: forall arch ids. !(MemInt (ArchAddrWidth arch)) -> StackExpr arch ids ('BVType (ArchAddrWidth arch))
- CExpr :: forall arch (tp :: Type) ids. !(CValue arch tp) -> StackExpr arch ids tp
- UExtExpr :: forall (u :: Natural) (w :: Natural) arch ids. (1 <= u, (u + 1) <= w) => StackExpr arch ids (BVType u) -> NatRepr w -> StackExpr arch ids ('BVType w)
- AppExpr :: forall ids (tp :: Type) arch. !(AssignId ids tp) -> !(App (StackExpr arch ids) tp) -> StackExpr arch ids tp
- intraStackRhsExpr :: forall arch ids (tp :: Type). (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch), ShowF (ArchReg arch)) => BlockIntraStackConstraints arch ids -> AssignId ids tp -> AssignRhs arch (Value arch ids) tp -> StackExpr arch ids tp
- intraStackSetAssignId :: forall ids (tp :: Type) arch. AssignId ids tp -> StackExpr arch ids tp -> BlockIntraStackConstraints arch ids -> BlockIntraStackConstraints arch ids
- discardMemInfo :: BlockIntraStackConstraints arch ids -> BlockIntraStackConstraints arch ids
- writeStackOff :: forall arch ids (tp :: Type). (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch)) => BlockIntraStackConstraints arch ids -> MemInt (ArchAddrWidth arch) -> MemRepr tp -> Value arch ids tp -> BlockIntraStackConstraints arch ids
- postJumpStackConstraints :: RegisterInfo (ArchReg arch) => BlockIntraStackConstraints arch ids -> RegState (ArchReg arch) (Value arch ids) -> NextStateMonad arch ids (BlockStartStackConstraints arch)
- data CallParams (r :: Type -> Type)
- postCallStackConstraints :: RegisterInfo (ArchReg arch) => CallParams (ArchReg arch) -> BlockIntraStackConstraints arch ids -> RegState (ArchReg arch) (Value arch ids) -> NextStateMonad arch ids (BlockStartStackConstraints arch)
- data LocMap (r :: Type -> Type) (v :: Type -> Type) = LocMap {
- locMapRegs :: !(MapF r v)
- locMapStack :: !(MemMap (MemInt (RegAddrWidth r)) v)
- locMapEmpty :: forall (r :: Type -> Type) (v :: Type -> Type). LocMap r v
- locMapNull :: forall (r :: Type -> Type) (v :: Type -> Type). LocMap r v -> Bool
- locMapToList :: forall (r :: Type -> Type) (v :: Type -> Type). LocMap r v -> [Pair (BoundLoc r) v]
- locLookup :: forall (r :: Type -> Type) (tp :: Type) v. (MemWidth (RegAddrWidth r), OrdF r) => BoundLoc r tp -> LocMap r v -> Maybe (v tp)
- nonOverlapLocInsert :: forall (r :: Type -> Type) (tp :: Type) v. OrdF r => BoundLoc r tp -> v tp -> LocMap r v -> LocMap r v
- locOverwriteWith :: forall (r :: Type -> Type) v (tp :: Type). (OrdF r, MemWidth (RegAddrWidth r)) => (v tp -> v tp -> v tp) -> BoundLoc r tp -> v tp -> LocMap r v -> LocMap r v
- ppLocMap :: forall (r :: Type -> Type) ann p. ShowF r => (forall (tp :: Type). Doc ann -> p tp -> Doc ann) -> LocMap r p -> [Doc ann]
- foldLocMap :: forall a (r :: Type -> Type) v. (forall (tp :: Type). a -> BoundLoc r tp -> v tp -> a) -> a -> LocMap r v -> a
- data MemMap o (v :: Type -> Type)
- emptyMemMap :: forall o (v :: Type -> Type). MemMap o v
- memMapLookup :: forall o (tp :: Type) (p :: Type -> Type). MemIndex o => o -> MemRepr tp -> MemMap o p -> MemMapLookup o p tp
- memMapLookup' :: forall o (tp :: Type) (v :: Type -> Type). MemIndex o => o -> MemRepr tp -> MemMap o v -> Maybe (o, MemVal v)
- data MemMapLookup o (p :: Type -> Type) (tp :: Type) where
- MMLResult :: forall (p :: Type -> Type) (tp :: Type) o. !(p tp) -> MemMapLookup o p tp
- MMLOverlap :: forall o (utp :: Type) (p :: Type -> Type) (tp :: Type). !o -> !(MemRepr utp) -> !(p utp) -> MemMapLookup o p tp
- MMLNone :: forall o (p :: Type -> Type) (tp :: Type). MemMapLookup o p tp
- memMapOverwrite :: forall o p (tp :: Type). (Ord o, Num o) => o -> MemRepr tp -> p tp -> MemMap o p -> MemMap o p
- memMapMapWithKey :: (forall (tp :: Type). o -> MemRepr tp -> a tp -> b tp) -> MemMap o a -> MemMap o b
- memMapTraverseWithKey_ :: Applicative m => (forall (tp :: Type). o -> MemRepr tp -> v tp -> m ()) -> MemMap o v -> m ()
- memMapTraverseMaybeWithKey :: Applicative m => (forall (tp :: Type). o -> MemRepr tp -> a tp -> m (Maybe (b tp))) -> MemMap o a -> m (MemMap o b)
- memMapDropAbove :: forall o (p :: Type -> Type). Integral o => Integer -> MemMap o p -> MemMap o p
- memMapDropBelow :: forall o (p :: Type -> Type). Integral o => Integer -> MemMap o p -> MemMap o p
- data NextStateMonad arch ids a
- runNextStateMonad :: NextStateMonad arch ids a -> a
- getNextStateRepresentatives :: NextStateMonad arch ids [Pair (BoundLoc (ArchReg arch)) (StackExpr arch ids)]
- data MemVal (p :: Type -> Type) = MemVal !(MemRepr tp) !(p tp)
Block level datatypes
BlockStartStackConstraints
data BlockStartStackConstraints arch Source #
Constraints on start of block.
This datatype maintains equality constraints between locations and stack offsets. It is used in jump bounds and other analysis libraries where we want to know when two registers or stack locations are equal.
data StackEqConstraint (r :: Type -> Type) (tp :: Type) where Source #
A constraint on the value stored in a location (i.e., register or stack offset) at the start of block executino.
Constructors
| IsStackOff :: forall (r :: Type -> Type). !(MemInt (RegAddrWidth r)) -> StackEqConstraint r ('BVType (RegAddrWidth r)) | This indicates the value is equal to the frame pointer plus the given offset. As stacks grow down on many architectures, the offset will typically be negative. |
| EqualLoc :: forall (r :: Type -> Type) (tp :: Type). !(BoundLoc r tp) -> StackEqConstraint r tp | Indicates the value is equal to the value stored at the location. |
| IsUExt :: forall (u :: Natural) (w :: Natural) (r :: Type -> Type). (1 <= u, (u + 1) <= w) => !(BoundLoc r (BVType u)) -> !(NatRepr w) -> StackEqConstraint r ('BVType w) | Indicates the value is the unsigned extension of the value at another location. |
ppBlockStartStackConstraints :: ShowF (ArchReg arch) => BlockStartStackConstraints arch -> [Doc ann] Source #
Pretty print the lines in stack constraints.
fnEntryBlockStartStackConstraints :: RegisterInfo (ArchReg arch) => BlockStartStackConstraints arch Source #
ppStackEqConstraint :: forall (r :: Type -> Type) ann (tp :: Type). ShowF r => Doc ann -> StackEqConstraint r tp -> Doc ann Source #
blockStartLocExpr :: forall arch (tp :: Type) ids. (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch)) => BlockStartStackConstraints arch -> BoundLoc (ArchReg arch) tp -> StackExpr arch ids tp Source #
Return an expression equivalent to the location in the constraint map.
This attempts to normalize the expression to get a representative.
blockStartLocStackOffset :: forall arch (tp :: Type). (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch)) => BlockStartStackConstraints arch -> BoundLoc (ArchReg arch) tp -> Maybe (MemInt (ArchAddrWidth arch)) Source #
blockStartLocStackOffset c l determines if l has the form stack_frame + o
using the constraints c for some stack offset o.
If it does, then this returns Just o. Otherwise it returns Nothing.
data StackOffConstraint (r :: Type -> Type) (tp :: Type) where Source #
Constraint on a class representative
Constructors
| StackOffCns :: forall (r :: Type -> Type). !(MemInt (RegAddrWidth r)) -> StackOffConstraint r ('BVType (RegAddrWidth r)) | |
| UExtCns :: forall (u :: Natural) (w :: Natural) (r :: Type -> Type). (1 <= u, (u + 1) <= w) => !(BoundLoc r (BVType u)) -> !(NatRepr w) -> StackOffConstraint r ('BVType w) |
Instances
| TestEquality r => Eq (StackOffConstraint r tp) Source # | |
Defined in Data.Macaw.AbsDomain.StackAnalysis Methods (==) :: StackOffConstraint r tp -> StackOffConstraint r tp -> Bool # (/=) :: StackOffConstraint r tp -> StackOffConstraint r tp -> Bool # | |
blockStartLocRepAndCns :: forall arch (tp :: Type). (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch)) => BlockStartStackConstraints arch -> BoundLoc (ArchReg arch) tp -> (BoundLoc (ArchReg arch) tp, Maybe (StackOffConstraint (ArchReg arch) tp)) Source #
boundsLocRep cns loc returns the representative location for
loc.
This representative location has the property that a location must
have the same value as its representative location, and if two
locations have provably equal values in cns, then they must
have the same representative.
data BoundLoc (r :: Type -> Type) (tp :: Type) where Source #
A location within a function tracked by our bounds analysis algorithms.
Locations for these purposes are registers, stack offsets, and global memory offsets.
Constructors
| RegLoc :: forall (r :: Type -> Type) (tp :: Type). !(r tp) -> BoundLoc r tp |
|
| StackOffLoc :: forall (r :: Type -> Type) (tp :: Type). !(MemInt (RegAddrWidth r)) -> !(MemRepr tp) -> BoundLoc r tp |
We should note that this makes no claim that those addresses are valid. |
Instances
| TestEquality r => TestEquality (BoundLoc r :: Type -> Type) Source # | |
Defined in Data.Macaw.AbsDomain.StackAnalysis | |
| ShowF r => PrettyF (BoundLoc r :: Type -> Type) Source # | |
| OrdF r => OrdF (BoundLoc r :: Type -> Type) Source # | |
Defined in Data.Macaw.AbsDomain.StackAnalysis Methods compareF :: forall (x :: Type) (y :: Type). BoundLoc r x -> BoundLoc r y -> OrderingF x y leqF :: forall (x :: Type) (y :: Type). BoundLoc r x -> BoundLoc r y -> Bool ltF :: forall (x :: Type) (y :: Type). BoundLoc r x -> BoundLoc r y -> Bool geqF :: forall (x :: Type) (y :: Type). BoundLoc r x -> BoundLoc r y -> Bool gtF :: forall (x :: Type) (y :: Type). BoundLoc r x -> BoundLoc r y -> Bool | |
| ShowF r => ShowF (BoundLoc r :: Type -> Type) Source # | |
| HasRepr r TypeRepr => HasRepr (BoundLoc r :: Type -> Type) TypeRepr Source # | |
| ShowF r => Show (BoundLoc r tp) Source # | |
| TestEquality r => Eq (BoundLoc r tp) Source # | |
| ShowF r => Pretty (BoundLoc r tp) Source # | |
Defined in Data.Macaw.AbsDomain.StackAnalysis | |
joinBlockStartStackConstraints :: (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch), HasRepr (ArchReg arch) TypeRepr) => BlockStartStackConstraints arch -> BlockStartStackConstraints arch -> Changed s (BlockStartStackConstraints arch, JoinClassMap (ArchReg arch)) Source #
Return a jump bounds that implies both input bounds, or Nothing
if every fact inx the old bounds is implied by the new bounds.
type JoinClassMap (r :: Type -> Type) = MapF (JoinClassPair (BoundLoc r)) (BoundLoc r) Source #
Maps representatives from old and new join constraints to representative in merged map.
data JoinClassPair (key :: k -> Type) (tp :: k) Source #
Constructors
| JoinClassPair !(key tp) !(key tp) |
Instances
| TestEquality k2 => TestEquality (JoinClassPair k2 :: k1 -> Type) Source # | |
Defined in Data.Macaw.AbsDomain.StackAnalysis Methods testEquality :: forall (a :: k1) (b :: k1). JoinClassPair k2 a -> JoinClassPair k2 b -> Maybe (a :~: b) # | |
| OrdF k2 => OrdF (JoinClassPair k2 :: k1 -> Type) Source # | |
Defined in Data.Macaw.AbsDomain.StackAnalysis Methods compareF :: forall (x :: k1) (y :: k1). JoinClassPair k2 x -> JoinClassPair k2 y -> OrderingF x y leqF :: forall (x :: k1) (y :: k1). JoinClassPair k2 x -> JoinClassPair k2 y -> Bool ltF :: forall (x :: k1) (y :: k1). JoinClassPair k2 x -> JoinClassPair k2 y -> Bool geqF :: forall (x :: k1) (y :: k1). JoinClassPair k2 x -> JoinClassPair k2 y -> Bool gtF :: forall (x :: k1) (y :: k1). JoinClassPair k2 x -> JoinClassPair k2 y -> Bool | |
BlockIntraStackConstraints
data BlockIntraStackConstraints arch ids Source #
Information about bounds for a particular value within a block.
Instances
| ShowF (ArchReg arch) => Pretty (BlockIntraStackConstraints arch ids) Source # | |
Defined in Data.Macaw.AbsDomain.StackAnalysis Methods pretty :: BlockIntraStackConstraints arch ids -> Doc ann prettyList :: [BlockIntraStackConstraints arch ids] -> Doc ann | |
mkBlockIntraStackConstraints :: (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch)) => BlockStartStackConstraints arch -> BlockIntraStackConstraints arch ids Source #
Create index bounds from initial index bounds.
biscInitConstraints :: BlockIntraStackConstraints arch ids -> BlockStartStackConstraints arch Source #
Bounds at execution start.
intraStackValueExpr :: forall arch ids (tp :: Type). (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch)) => BlockIntraStackConstraints arch ids -> Value arch ids tp -> StackExpr arch ids tp Source #
Return the value of the index expression given the bounds.
data StackExpr arch ids (tp :: Type) where Source #
This is an expression that represents the value of stack locations and assignments during steping through the block.
The main diference between this and
the Value type, index expressions do not depend on values read
and written to memory during execution of the block, and are purely
functions of the input
This is different from ClassPred in that ClassPred is a property
assigned to equivalence classes
Constructors
| ClassRepExpr :: forall arch (tp :: Type) ids. !(BoundLoc (ArchReg arch) tp) -> StackExpr arch ids tp | This refers to the value that a location had at the start of block execution. The location should be a class representative in the initial bounds. |
| UninterpAssignExpr :: forall ids (tp :: Type) arch. !(AssignId ids tp) -> !(AssignRhs arch (Value arch ids) tp) -> StackExpr arch ids tp | An assignment that is not interpreted, and just treated as a constant. |
| StackOffsetExpr :: forall arch ids. !(MemInt (ArchAddrWidth arch)) -> StackExpr arch ids ('BVType (ArchAddrWidth arch)) | Denotes the value of the stack pointer at function start plus some constant. |
| CExpr :: forall arch (tp :: Type) ids. !(CValue arch tp) -> StackExpr arch ids tp | Denotes a constant |
| UExtExpr :: forall (u :: Natural) (w :: Natural) arch ids. (1 <= u, (u + 1) <= w) => StackExpr arch ids (BVType u) -> NatRepr w -> StackExpr arch ids ('BVType w) | This is a pure function applied to other index expressions that may be worth interpreting (but could be treated as an uninterp assign expr also. |
| AppExpr :: forall ids (tp :: Type) arch. !(AssignId ids tp) -> !(App (StackExpr arch ids) tp) -> StackExpr arch ids tp | This is a pure function applied to other index expressions that may be worth interpreting (but could be treated as an uninterp assign expr also. |
Instances
| TestEquality (ArchReg arch) => TestEquality (StackExpr arch ids :: Type -> Type) Source # | |
Defined in Data.Macaw.AbsDomain.StackAnalysis | |
| ShowF (ArchReg arch) => PrettyF (StackExpr arch id :: Type -> Type) Source # | |
| OrdF (ArchReg arch) => OrdF (StackExpr arch ids :: Type -> Type) Source # | |
Defined in Data.Macaw.AbsDomain.StackAnalysis Methods compareF :: forall (x :: Type) (y :: Type). StackExpr arch ids x -> StackExpr arch ids y -> OrderingF x y leqF :: forall (x :: Type) (y :: Type). StackExpr arch ids x -> StackExpr arch ids y -> Bool ltF :: forall (x :: Type) (y :: Type). StackExpr arch ids x -> StackExpr arch ids y -> Bool geqF :: forall (x :: Type) (y :: Type). StackExpr arch ids x -> StackExpr arch ids y -> Bool gtF :: forall (x :: Type) (y :: Type). StackExpr arch ids x -> StackExpr arch ids y -> Bool | |
| (HasRepr (ArchReg arch) TypeRepr, MemWidth (ArchAddrWidth arch)) => HasRepr (StackExpr arch ids :: Type -> Type) TypeRepr Source # | |
| ShowF (ArchReg arch) => Show (StackExpr arch ids tp) Source # | |
| TestEquality (ArchReg arch) => Eq (StackExpr arch ids tp) Source # | |
| OrdF (ArchReg arch) => Ord (StackExpr arch ids tp) Source # | |
Defined in Data.Macaw.AbsDomain.StackAnalysis Methods compare :: StackExpr arch ids tp -> StackExpr arch ids tp -> Ordering # (<) :: StackExpr arch ids tp -> StackExpr arch ids tp -> Bool # (<=) :: StackExpr arch ids tp -> StackExpr arch ids tp -> Bool # (>) :: StackExpr arch ids tp -> StackExpr arch ids tp -> Bool # (>=) :: StackExpr arch ids tp -> StackExpr arch ids tp -> Bool # max :: StackExpr arch ids tp -> StackExpr arch ids tp -> StackExpr arch ids tp # min :: StackExpr arch ids tp -> StackExpr arch ids tp -> StackExpr arch ids tp # | |
| ShowF (ArchReg arch) => Pretty (StackExpr arch id tp) Source # | |
Defined in Data.Macaw.AbsDomain.StackAnalysis | |
intraStackRhsExpr :: forall arch ids (tp :: Type). (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch), ShowF (ArchReg arch)) => BlockIntraStackConstraints arch ids -> AssignId ids tp -> AssignRhs arch (Value arch ids) tp -> StackExpr arch ids tp Source #
Return an expression associated with the AssignRhs.
intraStackSetAssignId :: forall ids (tp :: Type) arch. AssignId ids tp -> StackExpr arch ids tp -> BlockIntraStackConstraints arch ids -> BlockIntraStackConstraints arch ids Source #
Associate the given bound expression with the assignment.
discardMemInfo :: BlockIntraStackConstraints arch ids -> BlockIntraStackConstraints arch ids Source #
Discard information about memory due to an operation that may affect arbitrary memory.
writeStackOff :: forall arch ids (tp :: Type). (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch)) => BlockIntraStackConstraints arch ids -> MemInt (ArchAddrWidth arch) -> MemRepr tp -> Value arch ids tp -> BlockIntraStackConstraints arch ids Source #
Update the stack to point to the given expression.
Block terminator updates
postJumpStackConstraints Source #
Arguments
| :: RegisterInfo (ArchReg arch) | |
| => BlockIntraStackConstraints arch ids | Constraints at end of block. |
| -> RegState (ArchReg arch) (Value arch ids) | Register values at start of next state. Note. ip_reg is ignored, so it does not have to be up-to-date. |
| -> NextStateMonad arch ids (BlockStartStackConstraints arch) |
Bounds for block after jump
data CallParams (r :: Type -> Type) Source #
Minimal information needed to update stack constraints after a call.
postCallStackConstraints :: RegisterInfo (ArchReg arch) => CallParams (ArchReg arch) -> BlockIntraStackConstraints arch ids -> RegState (ArchReg arch) (Value arch ids) -> NextStateMonad arch ids (BlockStartStackConstraints arch) Source #
Return the index bounds after a function call.
LocMap
data LocMap (r :: Type -> Type) (v :: Type -> Type) Source #
A map from BoundLoc locations to values.
Constructors
| LocMap | |
Fields
| |
locMapEmpty :: forall (r :: Type -> Type) (v :: Type -> Type). LocMap r v Source #
An empty location map.
locMapNull :: forall (r :: Type -> Type) (v :: Type -> Type). LocMap r v -> Bool Source #
Return true if map is null.
locMapToList :: forall (r :: Type -> Type) (v :: Type -> Type). LocMap r v -> [Pair (BoundLoc r) v] Source #
Construct a list out of a location map.
locLookup :: forall (r :: Type -> Type) (tp :: Type) v. (MemWidth (RegAddrWidth r), OrdF r) => BoundLoc r tp -> LocMap r v -> Maybe (v tp) Source #
Return value associated with location or nothing if it is not defined.
nonOverlapLocInsert :: forall (r :: Type -> Type) (tp :: Type) v. OrdF r => BoundLoc r tp -> v tp -> LocMap r v -> LocMap r v Source #
This associates the location with a value in the map, replacing any existing binding.
It is prefixed with "nonOverlap" because it doesn't guarantee that stack values are non-overlapping -- the user should ensure this before calling this.
ppLocMap :: forall (r :: Type -> Type) ann p. ShowF r => (forall (tp :: Type). Doc ann -> p tp -> Doc ann) -> LocMap r p -> [Doc ann] Source #
Pretty print a location map.
foldLocMap :: forall a (r :: Type -> Type) v. (forall (tp :: Type). a -> BoundLoc r tp -> v tp -> a) -> a -> LocMap r v -> a Source #
Fold over values in a location map.
MemMap
data MemMap o (v :: Type -> Type) Source #
This is a data structure for representing values written to concrete offsets in memory.
The offset type is a parameter so that we can use signed or unsigned offsets.
memMapLookup :: forall o (tp :: Type) (p :: Type -> Type). MemIndex o => o -> MemRepr tp -> MemMap o p -> MemMapLookup o p tp Source #
Lookup value (if any) at given offset and representation.
memMapLookup' :: forall o (tp :: Type) (v :: Type -> Type). MemIndex o => o -> MemRepr tp -> MemMap o v -> Maybe (o, MemVal v) Source #
Lookup value (if any) at given offset and representation.
This generalized memMapLookup below to not require exact matches, but
just some overlap.
data MemMapLookup o (p :: Type -> Type) (tp :: Type) where Source #
Result returned by memMapLookup.
Constructors
| MMLResult :: forall (p :: Type -> Type) (tp :: Type) o. !(p tp) -> MemMapLookup o p tp | We found a value at the exact offset and repr |
| MMLOverlap :: forall o (utp :: Type) (p :: Type -> Type) (tp :: Type). !o -> !(MemRepr utp) -> !(p utp) -> MemMapLookup o p tp | We found a value that had an overlapping offset and repr. |
| MMLNone :: forall o (p :: Type -> Type) (tp :: Type). MemMapLookup o p tp | We found neither an exact match nor an overlapping write. |
Arguments
| :: forall o p (tp :: Type). (Ord o, Num o) | |
| => o | Offset in the stack to write to |
| -> MemRepr tp | Type of value to write |
| -> p tp | Value to write |
| -> MemMap o p | |
| -> MemMap o p |
This assigns a region of bytes to a particular value in the stack.
It overwrites any values that overlap with the location.
memMapMapWithKey :: (forall (tp :: Type). o -> MemRepr tp -> a tp -> b tp) -> MemMap o a -> MemMap o b Source #
memMapTraverseWithKey_ :: Applicative m => (forall (tp :: Type). o -> MemRepr tp -> v tp -> m ()) -> MemMap o v -> m () Source #
memMapDropAbove :: forall o (p :: Type -> Type). Integral o => Integer -> MemMap o p -> MemMap o p Source #
memMapDropBelow :: forall o (p :: Type -> Type). Integral o => Integer -> MemMap o p -> MemMap o p Source #
NextStateMonad
data NextStateMonad arch ids a Source #
Instances
runNextStateMonad :: NextStateMonad arch ids a -> a Source #
getNextStateRepresentatives :: NextStateMonad arch ids [Pair (BoundLoc (ArchReg arch)) (StackExpr arch ids)] Source #
Return a list of locations and associated expressions that represent equivalence classes in the next state.
Note that each equivalence class has a unique stack expression, so all the locations in an equivalence class should have the same expression.