Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.Macaw.Architecture.Info
Description
This defines the architecture-specific information needed for code discovery.
Synopsis
- data ArchitectureInfo arch = ArchitectureInfo {
- withArchConstraints :: forall a. (ArchConstraints arch => a) -> a
- archAddrWidth :: !(AddrWidthRepr (ArchAddrWidth arch))
- archEndianness :: !Endianness
- extractBlockPrecond :: !(ArchSegmentOff arch -> AbsBlockState (ArchReg arch) -> Either String (ArchBlockPrecond arch))
- initialBlockRegs :: !(forall ids. ArchSegmentOff arch -> ArchBlockPrecond arch -> RegState (ArchReg arch) (Value arch ids))
- disassembleFn :: !(DisassembleFn arch)
- mkInitialAbsState :: !(Memory (ArchAddrWidth arch) -> ArchSegmentOff arch -> AbsBlockState (ArchReg arch))
- absEvalArchFn :: !(forall ids (tp :: Type). AbsProcessorState (ArchReg arch) ids -> ArchFn arch (Value arch ids) tp -> AbsValue (ArchAddrWidth arch) tp)
- absEvalArchStmt :: !(forall ids. AbsProcessorState (ArchReg arch) ids -> ArchStmt arch (Value arch ids) -> AbsProcessorState (ArchReg arch) ids)
- identifyCall :: forall ids. Memory (ArchAddrWidth arch) -> Seq (Stmt arch ids) -> RegState (ArchReg arch) (Value arch ids) -> Maybe (Seq (Stmt arch ids), ArchSegmentOff arch)
- archCallParams :: !(CallParams (ArchReg arch))
- checkForReturnAddr :: forall ids. RegState (ArchReg arch) (Value arch ids) -> AbsProcessorState (ArchReg arch) ids -> Bool
- identifyReturn :: forall ids. Seq (Stmt arch ids) -> RegState (ArchReg arch) (Value arch ids) -> AbsProcessorState (ArchReg arch) ids -> Maybe (Seq (Stmt arch ids))
- rewriteArchFn :: forall s src tgt (tp :: Type). ArchFn arch (Value arch src) tp -> Rewriter arch s src tgt (Value arch tgt tp)
- rewriteArchStmt :: forall s src tgt. ArchStmt arch (Value arch src) -> Rewriter arch s src tgt ()
- rewriteArchTermStmt :: forall s src tgt. ArchTermStmt arch (Value arch src) -> Rewriter arch s src tgt (ArchTermStmt arch (Value arch tgt))
- archDemandContext :: !(DemandContext arch)
- postArchTermStmtAbsState :: !(forall ids. Memory (ArchAddrWidth arch) -> AbsProcessorState (ArchReg arch) ids -> IntraJumpBounds arch ids -> RegState (ArchReg arch) (Value arch ids) -> ArchTermStmt arch (Value arch ids) -> Maybe (IntraJumpTarget arch))
- archClassifier :: !(forall ids. BlockClassifier arch ids)
- postCallAbsState :: ArchitectureInfo arch -> AbsProcessorState (ArchReg arch) ids -> RegState (ArchReg arch) (Value arch ids) -> ArchSegmentOff arch -> AbsBlockState (ArchReg arch)
- type DisassembleFn arch = forall s ids. NonceGenerator (ST s) ids -> ArchSegmentOff arch -> RegState (ArchReg arch) (Value arch ids) -> Int -> ST s (Block arch ids, Int)
- type BlockClassifier arch ids = BlockClassifierM arch ids (ParsedContents arch ids)
- data BlockClassifierM arch ids a
- runBlockClassifier :: BlockClassifier arch ids -> BlockClassifierContext arch ids -> Classifier (ParsedContents arch ids)
- data BlockClassifierContext arch ids = BlockClassifierContext {
- classifierParseContext :: !(ParseContext arch ids)
- classifierInitRegState :: !(RegState (ArchReg arch) (Value arch ids))
- classifierStmts :: !(Seq (Stmt arch ids))
- classifierBlockSize :: !Int
- classifierAbsState :: !(AbsProcessorState (ArchReg arch) ids)
- classifierJumpBounds :: !(IntraJumpBounds arch ids)
- classifierWrittenAddrs :: ![ArchSegmentOff arch]
- classifierFinalRegState :: !(RegState (ArchReg arch) (Value arch ids))
- data Classifier o
- = ClassifyFailed [ClassificationError]
- | ClassifySucceeded [ClassificationError] o
- classifierName :: String -> BlockClassifierM arch ids a -> BlockClassifierM arch ids a
- liftClassifier :: Classifier a -> BlockClassifierM arch ids a
- data ParseContext arch ids = ParseContext {
- pctxMemory :: !(Memory (ArchAddrWidth arch))
- pctxArchInfo :: !(ArchitectureInfo arch)
- pctxKnownFnEntries :: !(Map (ArchSegmentOff arch) NoReturnFunStatus)
- pctxFunAddr :: !(ArchSegmentOff arch)
- pctxAddr :: !(ArchSegmentOff arch)
- pctxExtResolution :: [(ArchSegmentOff arch, [ArchSegmentOff arch])]
- data NoReturnFunStatus
- module Data.Macaw.CFG.Block
- rewriteBlock :: ArchitectureInfo arch -> RewriteContext arch s src tgt -> Block arch src -> ST s (RewriteContext arch s src tgt, Block arch tgt)
Documentation
data ArchitectureInfo arch Source #
This records architecture specific functions for analysis.
Constructors
ArchitectureInfo | |
Fields
|
Arguments
:: ArchitectureInfo arch | |
-> AbsProcessorState (ArchReg arch) ids | Processor state at call. |
-> RegState (ArchReg arch) (Value arch ids) | Register values when call occurs. |
-> ArchSegmentOff arch | Return address |
-> AbsBlockState (ArchReg arch) |
type DisassembleFn arch Source #
Arguments
= forall s ids. NonceGenerator (ST s) ids | |
-> ArchSegmentOff arch | The offset to start reading from. |
-> RegState (ArchReg arch) (Value arch ids) | Initial values to use for registers. |
-> Int | Maximum offset for this to read from. |
-> ST s (Block arch ids, Int) |
Function for disassembling a range of code (usually a function in the target code image) into blocks.
A block is defined as a contiguous region of code with a single known entrance and potentially multiple exits.
This returns the list of blocks, the number of bytes in the blocks, and any potential error that prematurely terminated translating the block.
Block classification
type BlockClassifier arch ids = BlockClassifierM arch ids (ParsedContents arch ids) Source #
data BlockClassifierM arch ids a Source #
The underlying monad for the BlockClassifier
, which handles collecting
matching errors
Instances
runBlockClassifier :: BlockClassifier arch ids -> BlockClassifierContext arch ids -> Classifier (ParsedContents arch ids) Source #
Run a classifier in a given block context
data BlockClassifierContext arch ids Source #
The fields of the BlockClassifierContext
are:
ParseContext ...
- The context for the parse
RegState ...
- Initial register values
Seq (Stmt ...)
- The statements in the block
AbsProcessorState ...
- Abstract state of registers prior to terminator statement being executed.
Jmp.IntraJumpBounds ...
- Bounds prior to terminator statement being executed.
ArchSegmentOff arch
- Address of all segments written to memory
RegState ...
- Final register values
Constructors
BlockClassifierContext | |
Fields
|
Instances
MonadReader (BlockClassifierContext arch ids) (BlockClassifierM arch ids) Source # | |
Defined in Data.Macaw.Architecture.Info Methods ask :: BlockClassifierM arch ids (BlockClassifierContext arch ids) # local :: (BlockClassifierContext arch ids -> BlockClassifierContext arch ids) -> BlockClassifierM arch ids a -> BlockClassifierM arch ids a # reader :: (BlockClassifierContext arch ids -> a) -> BlockClassifierM arch ids a # |
data Classifier o Source #
The result of block classification, which collects information about all of the match failures to help diagnose shortcomings in the analysis
Constructors
ClassifyFailed [ClassificationError] | |
ClassifySucceeded [ClassificationError] o |
Instances
classifierName :: String -> BlockClassifierM arch ids a -> BlockClassifierM arch ids a Source #
In the given context, set the name of the current classifier
This is used to improve the labels for each classifier failure
liftClassifier :: Classifier a -> BlockClassifierM arch ids a Source #
data ParseContext arch ids Source #
Information needed to parse the processor state
Constructors
ParseContext | |
Fields
|
data NoReturnFunStatus Source #
Flags whether a function is labeled no return or not.
Constructors
NoReturnFun | Function labeled no return |
MayReturnFun | Function may retun |
Instances
Show NoReturnFunStatus Source # | |
Defined in Data.Macaw.Architecture.Info Methods showsPrec :: Int -> NoReturnFunStatus -> ShowS # show :: NoReturnFunStatus -> String # showList :: [NoReturnFunStatus] -> ShowS # | |
Pretty NoReturnFunStatus Source # | |
Defined in Data.Macaw.Architecture.Info |
Unclassified blocks
module Data.Macaw.CFG.Block
rewriteBlock :: ArchitectureInfo arch -> RewriteContext arch s src tgt -> Block arch src -> ST s (RewriteContext arch s src tgt, Block arch tgt) Source #
Apply optimizations to code in the block