@@ -544,12 +544,28 @@ assumePointsTo ::
544
544
assumePointsTo env tyenv nameEnv (LLVMPointsTo _ cond tptr tptval) = do
545
545
when (isJust cond) $ throwX86 " unsupported x86_64 command: crucible_conditional_points_to"
546
546
tval <- checkConcreteSizePointsToValue tptval
547
+ sym <- use x86Sym
548
+ cc <- use x86CrucibleContext
549
+ mem <- use x86Mem
550
+ ptr <- resolvePtrSetupValue env tyenv tptr
551
+ val <- liftIO $ resolveSetupVal cc mem env tyenv Map. empty tval
552
+ storTy <- liftIO $ C.LLVM. toStorableType =<< typeOfSetupValue cc tyenv nameEnv tval
553
+ mem' <- liftIO $ C.LLVM. storeConstRaw sym mem ptr storTy C.LLVM. noAlignment val
554
+ x86Mem .= mem'
555
+
556
+ resolvePtrSetupValue ::
557
+ X86Constraints =>
558
+ Map MS. AllocIndex Ptr ->
559
+ Map MS. AllocIndex LLVMAllocSpec ->
560
+ MS. SetupValue LLVM ->
561
+ X86Sim Ptr
562
+ resolvePtrSetupValue env tyenv tptr = do
547
563
sym <- use x86Sym
548
564
cc <- use x86CrucibleContext
549
565
mem <- use x86Mem
550
566
elf <- use x86Elf
551
567
base <- use x86GlobalBase
552
- ptr <- case tptr of
568
+ case tptr of
553
569
MS. SetupGlobal () nm -> case
554
570
(Vector. !? 0 )
555
571
. Vector. filter (\ e -> Elf. steName e == encodeUtf8 (Text. pack nm))
@@ -562,10 +578,6 @@ assumePointsTo env tyenv nameEnv (LLVMPointsTo _ cond tptr tptval) = do
562
578
liftIO $ C.LLVM. doPtrAddOffset sym mem base =<< W4. bvLit sym knownNat (BV. mkBV knownNat addr)
563
579
_ -> liftIO $ C.LLVM. unpackMemValue sym (C.LLVM. LLVMPointerRepr $ knownNat @ 64 )
564
580
=<< resolveSetupVal cc mem env tyenv Map. empty tptr
565
- val <- liftIO $ resolveSetupVal cc mem env tyenv Map. empty tval
566
- storTy <- liftIO $ C.LLVM. toStorableType =<< typeOfSetupValue cc tyenv nameEnv tval
567
- mem' <- liftIO $ C.LLVM. storeConstRaw sym mem ptr storTy C.LLVM. noAlignment val
568
- x86Mem .= mem'
569
581
570
582
checkConcreteSizePointsToValue :: LLVMPointsToValue LLVMArch -> X86Sim (MS. SetupValue LLVM )
571
583
checkConcreteSizePointsToValue = \ case
@@ -700,8 +712,7 @@ assertPointsTo env tyenv nameEnv (LLVMPointsTo _ cond tptr tptexpected) = do
700
712
cc <- use x86CrucibleContext
701
713
ms <- use x86MethodSpec
702
714
mem <- use x86Mem
703
- ptr <- liftIO $ C.LLVM. unpackMemValue sym (C.LLVM. LLVMPointerRepr $ knownNat @ 64 )
704
- =<< resolveSetupVal cc mem env tyenv Map. empty tptr
715
+ ptr <- resolvePtrSetupValue env tyenv tptr
705
716
memTy <- liftIO $ typeOfSetupValue cc tyenv nameEnv texpected
706
717
storTy <- liftIO $ C.LLVM. toStorableType memTy
707
718
actual <- liftIO $ C.LLVM. assertSafe sym =<< C.LLVM. loadRaw sym mem ptr storTy C.LLVM. noAlignment
0 commit comments