Hack: filter out known bad addresses from concretize abs ptrs

This commit is contained in:
Ben Davis 2017-12-19 09:40:13 -05:00
parent c1b6b472ef
commit ebbca0aded
No known key found for this signature in database
GPG Key ID: 65EE8F9A9C863EF2

View File

@ -98,26 +98,39 @@ import Data.Macaw.Types
-- Utilities
-- | Get code pointers out of a abstract value.
concretizeAbsCodePointers :: MemWidth w
concretizeAbsCodePointers' :: MemWidth w
=> Memory w
-> AbsValue w (BVType w)
-> [MemSegmentOff w]
concretizeAbsCodePointers mem (FinSet s) =
concretizeAbsCodePointers' mem (FinSet s) =
[ sa
| a <- Set.toList s
, sa <- maybeToList (resolveAbsoluteAddr mem (fromInteger a))
, segmentFlags (msegSegment sa) `Perm.hasPerm` Perm.execute
]
concretizeAbsCodePointers _ (CodePointers s _) =
concretizeAbsCodePointers' _ (CodePointers s _) =
[ sa
| sa <- Set.toList s
, segmentFlags (msegSegment sa) `Perm.hasPerm` Perm.execute
]
-- FIXME: this is dangerous !!
concretizeAbsCodePointers _mem StridedInterval{} = [] -- FIXME: this case doesn't make sense
concretizeAbsCodePointers' _mem StridedInterval{} = [] -- FIXME: this case doesn't make sense
-- debug DCFG ("I think these are code pointers!: " ++ show s) $ []
-- filter (isCodeAddr mem) $ fromInteger <$> SI.toList s
concretizeAbsCodePointers _mem _ = []
concretizeAbsCodePointers' _mem _ = []
concretizeAbsCodePointers :: MemWidth w
=> Memory w
-> AbsValue w (BVType w)
-> [MemSegmentOff w]
concretizeAbsCodePointers mem aVal = filteredResults
where rval = concretizeAbsCodePointers' mem aVal
-- GIANT HACK: filter out known invalid addresses for current experiments only
filteredResults = [r | r <- rval
, addr <- maybeToList (msegAddr r)
, addr >= 0x1c04
]
{-
printAddrBacktrace :: Map (ArchMemAddr arch) (FoundAddr arch)