Skip to content

Commit

Permalink
Merge pull request #1046 from GaloisInc/wip/T861-take-two
Browse files Browse the repository at this point in the history
Experimental support for loading JIMAGE (JDK 9+) files
  • Loading branch information
mergify[bot] authored Feb 11, 2021
2 parents 856f4e0 + 1e749e0 commit c4ab82b
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 122 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## New Features

SAW now includes experimental support for verifying Java code using JDK 9 or
later. Verifying Java code that only uses primitive data types is known to work
well, but code that imports certain classes (e.g., `String`) is known to suffer
from issues documented
[here](https://github.com/GaloisInc/crucible/issues/641).

When verifying Java code, the path to Java can be specified with the new
`--java-bin-dirs`/`-b` command-line option. Alternatively, if
`--java-bin-dirs` is not set, then SAW searches the `PATH` to find Java.
Expand Down
2 changes: 1 addition & 1 deletion deps/crucible
Submodule crucible updated 49 files
+5 −3 .github/ci.sh
+2 −0 .github/workflows/crux-llvm-build.yml
+2 −0 .github/workflows/crux-mir-build.yml
+8 −1 crucible-jvm/crucible-jvm.cabal
+232 −35 crucible-jvm/src/Lang/JVM/Codebase.hs
+93 −0 crucible-jvm/src/Lang/JVM/JavaTools.hs
+30 −0 crucible-jvm/src/Lang/JVM/ProcessUtils.hs
+ crucible-jvm/tests/Str.class
+5 −3 crucible-jvm/tests/ashes/README.md
+1 −3 crucible-jvm/tests/ashes/runcrucible.sh
+1 −4 crucible-jvm/tests/test.sh
+50 −11 crucible-jvm/tool/Main.hs
+1 −1 crucible-llvm/crucible-llvm.cabal
+21 −4 crucible-llvm/src/Lang/Crucible/LLVM/Translation.hs
+2 −2 crucible-llvm/test/Tests.hs
+1 −1 crux-llvm/crux-llvm.cabal
+0 −0 crux-llvm/test-data/golden/golden-loop-merging/issue_478.result
+0 −1 crux-llvm/test-data/golden/golden-loop-merging/issue_478_unsafe.good
+1 −0 crux-llvm/test-data/golden/golden-loop-merging/issue_478_unsafe.result
+0 −0 crux-llvm/test-data/golden/golden-loop-merging/loop_exit.result
+0 −1 crux-llvm/test-data/golden/golden-loop-merging/loop_exit_unsafe.good
+1 −0 crux-llvm/test-data/golden/golden-loop-merging/loop_exit_unsafe.result
+0 −0 crux-llvm/test-data/golden/golden-loop-merging/loop_sequence.result
+0 −1 crux-llvm/test-data/golden/golden-loop-merging/loop_sequence_unsafe.good
+1 −0 crux-llvm/test-data/golden/golden-loop-merging/loop_sequence_unsafe.result
+0 −0 crux-llvm/test-data/golden/golden-loop-merging/nested.result
+0 −1 crux-llvm/test-data/golden/golden-loop-merging/nested_unsafe.good
+1 −0 crux-llvm/test-data/golden/golden-loop-merging/nested_unsafe.result
+0 −0 crux-llvm/test-data/golden/golden-loop-merging/string.result
+0 −0 crux-llvm/test-data/golden/golden-loop-merging/string2.result
+0 −0 crux-llvm/test-data/golden/golden-loop-merging/strlen_test.result
+0 −0 crux-llvm/test-data/golden/golden-loop-merging/strlen_test2.result
+0 −0 crux-llvm/test-data/golden/golden/float-cast.result
+0 −0 crux-llvm/test-data/golden/golden/float-cast2.result
+0 −0 crux-llvm/test-data/golden/golden/funnel.result
+0 −0 crux-llvm/test-data/golden/golden/gcd-test.result
+0 −0 crux-llvm/test-data/golden/golden/hello.result
+0 −0 crux-llvm/test-data/golden/golden/hello2.result
+0 −0 crux-llvm/test-data/golden/golden/printing.result
+0 −0 crux-llvm/test-data/golden/golden/string.result
+0 −0 crux-llvm/test-data/golden/golden/string2.result
+0 −0 crux-llvm/test-data/golden/golden/strlen_test.result
+0 −0 crux-llvm/test-data/golden/golden/strlen_test2.result
+0 −0 crux-llvm/test-data/golden/golden/uint-cast.result
+0 −0 crux-llvm/test-data/golden/golden/vector-cmp.result
+0 −0 crux-llvm/test-data/golden/golden/vector-gep.result
+0 −0 crux-llvm/test-data/golden/golden/vector-select.result
+238 −94 crux-llvm/test/Test.hs
+1 −1 dependencies/jvm-parser
8 changes: 5 additions & 3 deletions doc/manual/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -1575,9 +1575,11 @@ The resulting `JavaClass` can be passed into the various functions
described below to perform analysis of specific Java methods.

Java class files from any JDK newer than version 6 should work. However,
JDK version 9 and newer do not contain a JAR file containing the
standard libraries, and therefore do not currently work with SAW. We are
investigating the best way to resolve this issue.
support for JDK 9 and later is experimental. Verifying code that only uses
primitive data types is known to work well, but there are some as-of-yet
unresolved issues in verifying code involving classes such as `String`. For
more information on these issues, refer to
[this GitHub issue](https://github.com/GaloisInc/crucible/issues/641).

## Notes on Compiling Code for SAW

Expand Down
8 changes: 5 additions & 3 deletions doc/tutorial/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,11 @@ Alternatively, if Java is located on your `PATH`, you can omit the `-b`
option entirely.

Both Oracle JDK and OpenJDK versions 6 through 8 work well with SAW.
From version 9 onward, the core libraries are no longer stored in a
standard JAR file, making them inacessible to SAW. We're currently
considering strategies for working with newer Java versions.
SAW also includes experimental support for JDK 9 and later. Code that only
involves primitive data types (such as `FFS.java` above) is known to work well
under JDK 9+, but there are some as-of-yet unresolved issues in verifying code
involving classes such as `String`. For more information on these issues, refer
to [this GitHub issue](https://github.com/GaloisInc/crucible/issues/641).

Now we can do the proof both within and across languages (from
`ffs_compare.saw`):
Expand Down
4 changes: 2 additions & 2 deletions saw-remote-api/src/SAWServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ initialState readFileFn =
ss <- basic_ss sc
let jarFiles = []
classPaths = []
jcb <- JSS.loadCodebase jarFiles classPaths
javaBinDirs = []
jcb <- JSS.loadCodebase jarFiles classPaths javaBinDirs
let bic = BuiltinContext { biSharedContext = sc
, biJavaCodebase = jcb
, biBasicSS = ss
}
cenv <- initCryptolEnv sc
Expand Down
3 changes: 0 additions & 3 deletions saw-script.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ library
, utf8-string
, what4 >= 0.4
, vector
, xdg-basedir
, GraphSCC
, macaw-base
, macaw-x86
Expand Down Expand Up @@ -115,15 +114,13 @@ library
SAWScript.ImportAIG
SAWScript.Interpreter
SAWScript.JavaExpr
SAWScript.JavaTools
SAWScript.JavaPretty
SAWScript.Lexer
SAWScript.LLVMBuiltins
SAWScript.Options
SAWScript.Panic
SAWScript.Parser
SAWScript.PathVC
SAWScript.ProcessUtils
SAWScript.Proof
SAWScript.Position
SAWScript.SBVParser
Expand Down
4 changes: 3 additions & 1 deletion src/SAWScript/Builtins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ import Verifier.SAW.TypedAST

import SAWScript.Position

-- crucible-jvm
import Lang.JVM.ProcessUtils

-- cryptol-saw-core
import qualified Verifier.SAW.CryptolEnv as CEnv

Expand Down Expand Up @@ -118,7 +121,6 @@ import SAWScript.ImportAIG

import SAWScript.AST (getVal, pShow, Located(..))
import SAWScript.Options as Opts
import SAWScript.ProcessUtils
import SAWScript.Proof
import SAWScript.TopLevel
import qualified SAWScript.Value as SV
Expand Down
3 changes: 1 addition & 2 deletions src/SAWScript/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ buildTopLevelEnv proxy opts =
simps <- scSimpset sc0 cryptolDefs [] convs
let sc = rewritingSharedContext sc0 simps
ss <- basic_ss sc
jcb <- JCB.loadCodebase (jarList opts) (classPath opts)
jcb <- JCB.loadCodebase (jarList opts) (classPath opts) (javaBinDirs opts)
currDir <- getCurrentDirectory
Crucible.withHandleAllocator $ \halloc -> do
let ro0 = TopLevelRO
Expand All @@ -433,7 +433,6 @@ buildTopLevelEnv proxy opts =
}
let bic = BuiltinContext {
biSharedContext = sc
, biJavaCodebase = jcb
, biBasicSS = ss
}
primsAvail = Set.fromList [Current]
Expand Down
74 changes: 0 additions & 74 deletions src/SAWScript/JavaTools.hs

This file was deleted.

7 changes: 4 additions & 3 deletions src/SAWScript/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import System.IO
import Text.Read (readMaybe)
import Text.Show.Functions ()

import SAWScript.JavaTools
import Lang.JVM.JavaTools

-- TODO: wouldn't it be better to extract the options-processing code from this file and put it in saw/Main.hs (which already does part of the options processing)? It seems that other parts of SAW only need the datatype definition below, and not the rest.
data Options = Options
Expand Down Expand Up @@ -207,8 +207,9 @@ processEnv opts = do
-- --java-bin-dirs or PATH, see the Haddocks for findJavaIn), then use that
-- to detect the path to Java's standard rt.jar file and add it to the
-- jarList on Java 8 or earlier. (Later versions of Java do not use
-- rt.jar—see #861.) If Java's path is not specified, return the Options
-- unchanged.
-- rt.jar—see Note [Loading classes from JIMAGE files] in
-- Lang.JVM.Codebase in crucible-jvm.)
-- If Java's path is not specified, return the Options unchanged.
addJavaBinDirInducedOpts :: Options -> IO Options
addJavaBinDirInducedOpts os@Options{javaBinDirs} = do
mbJavaPath <- findJavaIn javaBinDirs
Expand Down
29 changes: 0 additions & 29 deletions src/SAWScript/ProcessUtils.hs

This file was deleted.

1 change: 0 additions & 1 deletion src/SAWScript/Value.hs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ data SAW_CFG where
JVM_CFG :: Crucible.AnyCFG JVM -> SAW_CFG

data BuiltinContext = BuiltinContext { biSharedContext :: SharedContext
, biJavaCodebase :: JSS.Codebase
, biBasicSS :: Simpset
}
deriving Generic
Expand Down

0 comments on commit c4ab82b

Please sign in to comment.