@@ -128,6 +128,7 @@ data X86State = X86State
128
128
, _x86Options :: Options
129
129
, _x86SharedContext :: SharedContext
130
130
, _x86CrucibleContext :: LLVMCrucibleContext LLVMArch
131
+ , _x86Elf :: Elf. Elf 64
131
132
, _x86RelevantElf :: RelevantElf
132
133
, _x86MethodSpec :: MS. CrucibleMethodSpecIR LLVM
133
134
, _x86Mem :: Mem
@@ -384,6 +385,8 @@ initialState sym opts sc cc elf relf ms globs maxAddr = do
384
385
emptyRegs <- traverseWithIndex (freshRegister sym) C. knownRepr
385
386
let
386
387
align = C.LLVM. exponentToAlignment 4
388
+ allocGlobalEnd :: MS. AllocGlobal LLVM -> Integer
389
+ allocGlobalEnd (LLVMAllocGlobal _ (LLVM. Symbol nm)) = globalEnd nm
387
390
globalEnd :: String -> Integer
388
391
globalEnd nm = case
389
392
Vector. headM
@@ -396,6 +399,7 @@ initialState sym opts sc cc elf relf ms globs maxAddr = do
396
399
sz <- W4. bvLit sym knownNat . maximum $ mconcat
397
400
[ [maxAddr]
398
401
, globalEnd . fst <$> globs
402
+ , allocGlobalEnd <$> ms ^. MS. csGlobalAllocs
399
403
]
400
404
(base, mem) <- C.LLVM. doMalloc sym C.LLVM. GlobalAlloc C.LLVM. Immutable
401
405
" globals" emptyMem sz align
@@ -404,6 +408,7 @@ initialState sym opts sc cc elf relf ms globs maxAddr = do
404
408
, _x86Options = opts
405
409
, _x86SharedContext = sc
406
410
, _x86CrucibleContext = cc
411
+ , _x86Elf = elf
407
412
, _x86RelevantElf = relf
408
413
, _x86MethodSpec = ms
409
414
, _x86Mem = mem
@@ -530,8 +535,21 @@ executePointsTo env tyenv nameEnv (LLVMPointsTo _ cond tptr tval)
530
535
sym <- use x86Sym
531
536
cc <- use x86CrucibleContext
532
537
mem <- use x86Mem
533
- ptr <- liftIO $ C.LLVM. unpackMemValue sym (C.LLVM. LLVMPointerRepr $ knownNat @ 64 )
534
- =<< resolveSetupVal cc mem env tyenv Map. empty tptr
538
+ elf <- use x86Elf
539
+ base <- use x86GlobalBase
540
+ ptr <- case tptr of
541
+ MS. SetupGlobal () nm -> case
542
+ Vector. headM
543
+ . Vector. filter (\ e -> Elf. steName e == encodeUtf8 (Text. pack nm))
544
+ . mconcat
545
+ . fmap Elf. elfSymbolTableEntries
546
+ $ Elf. elfSymtab elf of
547
+ Nothing -> throwX86 " not found"
548
+ Just entry -> do
549
+ let addr = fromIntegral $ Elf. steValue entry
550
+ liftIO $ C.LLVM. doPtrAddOffset sym mem base =<< W4. bvLit sym knownNat addr
551
+ _ -> liftIO $ C.LLVM. unpackMemValue sym (C.LLVM. LLVMPointerRepr $ knownNat @ 64 )
552
+ =<< resolveSetupVal cc mem env tyenv Map. empty tptr
535
553
val <- liftIO $ resolveSetupVal cc mem env tyenv Map. empty tval
536
554
storTy <- liftIO $ C.LLVM. toStorableType =<< typeOfSetupValue cc tyenv nameEnv tval
537
555
mem' <- liftIO $ C.LLVM. storeConstRaw sym mem ptr storTy C.LLVM. noAlignment val
@@ -667,7 +685,6 @@ checkGoals = do
667
685
case mb of
668
686
Nothing -> printOutLn opts Info " Goal succeeded"
669
687
Just ex -> do
670
- print g
671
688
fail $ mconcat
672
689
[" Failure (" , show $ gLoc g
673
690
, " ): " , show $ gMessage g
0 commit comments