Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check bitvector types in crucible_llvm_extract #567

Merged
merged 2 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added intTests/test_issue521/ptr.bc
Binary file not shown.
3 changes: 3 additions & 0 deletions intTests/test_issue521/ptr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
unsigned int add(unsigned int *x, unsigned int *y) {
return *x + *y;
}
2 changes: 2 additions & 0 deletions intTests/test_issue521/test.saw
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
m <- llvm_load_module "ptr.bc";
fails (crucible_llvm_extract m "add");
3 changes: 3 additions & 0 deletions intTests/test_issue521/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set -e

$SAW test.saw
13 changes: 12 additions & 1 deletion src/SAWScript/Crucible/LLVM/Builtins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import Control.Monad.State hiding (fail)
import Control.Monad.Fail (MonadFail(..))
import qualified Data.Bimap as Bimap
import Data.Char (isDigit)
import Data.Foldable (for_, toList, find)
import Data.Foldable (for_, toList, find, fold)
import Data.Function
import Data.IORef
import Data.List
Expand Down Expand Up @@ -1103,6 +1103,17 @@ crucible_llvm_extract ::
crucible_llvm_extract bic opts (Some lm) fn_name = do
let ctx = lm ^. modTrans . Crucible.transContext
let ?lc = ctx^.Crucible.llvmTypeCtx
let edef = findDefMaybeStatic (lm ^. modAST) fn_name
case edef of
Right defs -> do
let defTypes = fold $
NE.map (map L.typedType . L.defArgs) defs <>
NE.map (\d -> [L.defRetType d]) defs
when (any L.isPointer defTypes) $
fail "Pointer types are not supported by `crucible_llvm_extract`."
when (any L.isAlias defTypes) $
fail "Type aliases are not supported by `crucible_llvm_extract`."
Left err -> fail (displayVerifExceptionOpts opts err)
setupLLVMCrucibleContext bic opts lm $ \cc ->
case Map.lookup (fromString fn_name) (Crucible.cfgMap (cc^.ccLLVMModuleTrans)) of
Nothing -> fail $ unwords ["function", fn_name, "not found"]
Expand Down