Skip to content

Commit e74a79a

Browse files
committed
Adapt to changes in GaloisInc/macaw#327
This mostly involves consolidating various `macaw` memory model–related options into a `MemModelConfig` value. Apart from the API changes, there should be no user-visible changes in behavior.
1 parent 4fb3fd2 commit e74a79a

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

src/SAWScript/Crucible/LLVM/X86.hs

+10-5
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,18 @@ llvm_verify_x86_common (Some (llvmModule :: LLVMModule x)) path nm globsyms chec
475475
archEvalFns = Macaw.x86_64MacawEvalFn sfs Macaw.defaultMacawArchStmtExtensionOverride
476476
lookupSyscall = Macaw.unsupportedSyscalls "saw-script"
477477
noExtraValidityPred _ _ _ _ = return Nothing
478+
mmConf = Macaw.MemModelConfig
479+
{ Macaw.globalMemMap = mkGlobalMap . Map.singleton 0 $ preState ^. x86GlobalBase
480+
, Macaw.lookupFunctionHandle = funcLookup
481+
, Macaw.lookupSyscallHandle = lookupSyscall
482+
, Macaw.mkGlobalPointerValidityAssertion = noExtraValidityPred
483+
, Macaw.resolvePointer = pure
484+
, Macaw.concreteImmutableGlobalRead = \_ _ -> pure Nothing
485+
, Macaw.lazilyPopulateGlobalMem = \_ _ -> pure
486+
}
478487
defaultMacawExtensions_x86_64 =
479488
Macaw.macawExtensions
480-
archEvalFns mvar
481-
(mkGlobalMap . Map.singleton 0 $ preState ^. x86GlobalBase)
482-
funcLookup
483-
lookupSyscall
484-
noExtraValidityPred
489+
archEvalFns mvar mmConf
485490
sawMacawExtensions = defaultMacawExtensions_x86_64
486491
{ C.extensionExec = \s0 st -> case s0 of
487492
Macaw.PtrLt w x y -> doPtrCmp W4.bvUlt st mvar w x y

src/SAWScript/X86.hs

+11-1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ import Data.Macaw.Symbolic( ArchRegStruct
106106
, GlobalMap
107107
, MacawSimulatorState(..)
108108
, macawExtensions
109+
, MemModelConfig(..)
109110
, unsupportedSyscalls
110111
, defaultMacawArchStmtExtensionOverride
111112
)
@@ -491,13 +492,22 @@ doSim opts elf sfs name (globs,overs) st checkPost =
491492
let noExtraValidityPred _ _ _ _ = return Nothing
492493
let archEvalFns = x86_64MacawEvalFn sfs defaultMacawArchStmtExtensionOverride
493494
let lookupSyscall = unsupportedSyscalls "saw-script"
495+
let mmConf = MemModelConfig
496+
{ globalMemMap = globs
497+
, lookupFunctionHandle = callHandler overs sym
498+
, lookupSyscallHandle = lookupSyscall
499+
, mkGlobalPointerValidityAssertion = noExtraValidityPred
500+
, resolvePointer = pure
501+
, concreteImmutableGlobalRead = \_ _ -> pure Nothing
502+
, lazilyPopulateGlobalMem = \_ _ -> pure
503+
}
494504
let ctx :: SimContext (MacawSimulatorState Sym) Sym (MacawExt X86_64)
495505
ctx = SimContext { _ctxBackend = backend opts
496506
, ctxSolverProof = \a -> a
497507
, ctxIntrinsicTypes = llvmIntrinsicTypes
498508
, simHandleAllocator = allocator opts
499509
, printHandle = stdout
500-
, extensionImpl = macawExtensions archEvalFns mvar globs (callHandler overs sym) lookupSyscall noExtraValidityPred
510+
, extensionImpl = macawExtensions archEvalFns mvar mmConf
501511
, _functionBindings = FnBindings $
502512
insertHandleMap (cfgHandle cfg) (UseCFG cfg (postdomInfo cfg)) emptyHandleMap
503513
, _cruciblePersonality = MacawSimulatorState

0 commit comments

Comments
 (0)