Commit Graph

121 Commits

Author SHA1 Message Date
Kevin Quick
f2b98011ce
Use initSimContext to create a Crucible SimContext.
This helps to immunize against changes in SimContext... e.g. the
addition on the profilingMetrics field that initSimContext provides a
default value for.
2019-01-21 12:20:00 -08:00
Nathan Collins
86ef62645d Fill in undefineds with nonsense so pretty printing works 2019-01-17 14:25:59 -08:00
Kevin Quick
190ed07121
[symbolic] add imports for mappend operator for GHC 8.2.2. 2019-01-12 18:10:16 -08:00
Tristan Ravitch
379f89ee78 Update to the latest crucible version
The llvm memory model was extended with better diagnostics and configurable
handling of undefined behavior.  macaw-symbolic uses no undefined behavior
checking, as those operations are only undefined in C.
2019-01-11 23:01:07 -08:00
Tristan Ravitch
7b57ac0c34 Additional haddocks 2019-01-11 13:58:15 -08:00
Tristan Ravitch
bda8ace256 symbolic: Clean up the memory mapping API
The API is now cleaner and includes more documentation (with an example).  Some
unnecessary types are removed/combined.
2019-01-11 13:21:04 -08:00
Tristan Ravitch
81f8f5a849 Add an extra comment to the backend docs 2019-01-11 13:11:40 -08:00
Tristan Ravitch
68c5578f03 symbolic: Translate the InstructionStart metadata statement into Crucible
Before, we just discarded them during the translation.  They are useful metadata
for generating diagnostics in Crucible, so this commit translates them.  They
are no-ops during symbolic evaluation.

To make them truly useful, they need to include the address of the block that
they belong to (their data payload in macaw is just an offset from the start of
a block).  This information wasn't available before, so it has to be plumbed
through in macaw-x86.
2019-01-10 22:23:39 -08:00
Tristan Ravitch
694e463e5d symbolic: Export another useful value wrapper in the user-facing API
This is a data wrapper used to convert macaw to crucible values
2019-01-10 22:22:44 -08:00
Tristan Ravitch
cc85cfe657 Clean up and document the macaw-symbolic API
This cleanup consolidates the interface to macaw symbolic into two (and a half)
modules:

 - Data.Macaw.Symbolic for clients who just need to symbolically simulate
   machine code
 - Data.Macaw.Symbolic.Backend for clients that need to implement new
   architectures
 - Data.Macaw.Symbolic.Memory provides a reusable example implementation of
   machine pointer to LLVM memory model pointer mapping

Most functions are now documented and are grouped by use case.  There are two
worked (compiling) examples in the haddocks that show how to translate Macaw
into Crucible and then symbolically simulate the results (including setting up
all aspects of Crucible).  The examples are included in the symbolic/examples
directory and can be loaded with GHCi to type check them.

The Data.Macaw.Symbolic.Memory module still needs a worked example.

There were very few changes to actual code as part of this overhaul, but there
are a few places where complicated functions were hidden behind newtypes, as
users never need to construct the values themselves (e.g., MacawArchEvalFn and
MacawSymbolicArchFunctions).  There was also a slight consolidation of
constraint synonyms to reduce duplication.  All callers will have to be updated.

There is also now a README for macaw-symbolic that explains its purpose and
includes pointers to the new haddocks.

This commit also fixes up the (minor) breakage in the macaw-x86-symbolic
implementation from the API changes.
2019-01-10 18:20:54 -08:00
Kevin Quick
98807daee2
Added -Wcompat for warnings about future compatibility. 2019-01-10 13:43:27 -08:00
Kevin Quick
b5ef20067d
Explicit results checking instead of implicit pattern monad fail. 2019-01-10 13:39:09 -08:00
Kevin Quick
16a867efd2
Haddock and README fixes. 2019-01-08 16:38:38 -08:00
Tristan Ravitch
b398db41b2 Merge branch 'master' of github.com:GaloisInc/macaw into HEAD 2019-01-07 20:43:32 -08:00
Tristan Ravitch
9c19e1b37d macaw-symbolic: Export an extra constructor
This constructor is very useful for traversing terms externally
2019-01-07 20:42:52 -08:00
Luke Maurer
46cdd8be82 Adapt to Nonce-based registerized CFGs 2019-01-03 12:10:24 -08:00
Luke Maurer
c43a0c24d8 Add INLINE pragmas to CrucGen monad instance 2018-12-26 18:42:50 -08:00
Brian Huffman
8dc4a54ca2 Use new constant noAlignment instead of literal 0 :: Alignment. 2018-12-20 14:03:38 -08:00
Brian Huffman
00c08376e5 Bump crucible version; adapt to crucible-llvm changes. 2018-12-18 17:47:50 -08:00
Brian Huffman
7e6582fa07 Bump submodules, adapt to changes in crucible-llvm api. 2018-12-18 13:47:51 -08:00
Andrei Stefanescu
3f39c614e9 Add support for RepMovs and RepStos. 2018-11-27 02:23:36 -08:00
Rob Dockins
5f75652a37 Update crucible and parameterized-utils submodules 2018-11-14 10:33:10 -08:00
Luke Maurer
1d88f1fe98 Emit ErrorStmt rather than failing when an instruction has no successor
We were getting "Unterminated crucible block" errors for any code
containing the X86 HLT instruction.  An ErrorStmt is perhaps not
precisely what HLT means, but we're going with that for the moment.
2018-11-08 16:07:21 -08:00
Joe Hendrix
2e93d42893
Merge remote-tracking branch 'public/master' 2018-10-22 13:04:30 -07:00
Joe Hendrix
c886c19b03
Rename Memory exports.
This update renames many of the declarations exported by
Data.Macaw.Memory so that we have more consistent names.

The majority of the existing names are now exported with DEPRECATION
warnings.  Some of the symbol declarations that were not used by the
Memory datatype have been moved to other modules.

The minor version of macaw-base has been incremented.
2018-10-18 10:07:20 -07:00
Daniel Wagner
062242e8e6 implement conversion from macaw bit-scan functions to crucible 2018-10-12 13:33:13 -04:00
Daniel Wagner
5cacfec77a syscall fallthrough in CFG creation 2018-10-10 15:04:04 -04:00
Andrei Stefanescu
30b54e399a Translate PopCount to Crucible. 2018-09-28 20:25:18 -07:00
Andrei Stefanescu
59b756c185 Add symbolic semantics for X86 sse_ucomis and sse_cvttsx2si. 2018-09-19 18:47:47 -07:00
Luke Maurer
5c78e9258b
Merge pull request #11 from GaloisInc/cfg-rewriting
Adapt to changes to Crucible for CFG rewriting
2018-09-06 16:46:24 -07:00
Luke Maurer
e08fdf6efa Merge remote-tracking branch 'origin/master' into cfg-rewriting 2018-08-28 13:26:43 -07:00
Andrei Stefanescu
786a45c5e0 Handle float type in Macaw Symbolic. 2018-08-27 11:37:01 -07:00
Brian Huffman
8199a9a088 Merge branch 'master' into saw-script
# Conflicts:
#	symbolic/src/Data/Macaw/Symbolic.hs
#	symbolic/src/Data/Macaw/Symbolic/MemOps.hs
#	x86_symbolic/src/Data/Macaw/X86/Crucible.hs
2018-08-27 11:21:13 -07:00
Brian Huffman
c29d4c924a Merge branch 'master' into saw-script 2018-08-27 10:27:00 -07:00
Luke Maurer
abd51d835d Merge remote-tracking branch 'origin/master' into cfg-rewriting 2018-08-23 14:16:46 -07:00
Brian Huffman
a33202b583 Adapt to changes in crucible-llvm package. 2018-08-20 16:38:20 -07:00
Kevin Quick
05a4d96cd7
Update register CFG initialization for new label and value fields. 2018-08-10 15:06:04 -07:00
Luke Maurer
0c2076d54d Merge remote-tracking branch 'origin/master' into cfg-rewriting 2018-07-24 17:11:20 -07:00
Tristan Ravitch
4d1299a6d2 Merge branch 'master' into breaking-change/symbolic-global-map 2018-07-24 16:53:51 -07:00
Joe Hendrix
dc4a4f0f5f
Merge remote-tracking branch 'public/stable' into jhx-x86-improvements 2018-07-20 20:32:09 -07:00
Rob Dockins
f14222e4a4 Update to track crucible API changes 2018-07-20 18:41:54 -07:00
Luke Maurer
03dc25c6b3 Set new cfgNextLabel field in generated CFG 2018-07-20 11:38:15 -07:00
Luke Maurer
bd9d77ed93 Set new cfgNextValue field in generated CFG 2018-07-17 11:09:10 -07:00
Luke Maurer
b1c5bcfd25 Expose the registerized forms of produced CFGs
Now one can either directly produce an SSA CFG or produce a registerized
one, perhaps mess with it (as with the new
`Lang.Crucible.Utils.RegRewrite` module), then translate it to SSA.
2018-07-16 13:34:03 -07:00
Tristan Ravitch
ed52c54162 Revise the function handle lookup operation
It needs to take (and return) a Crucible state so that we can insert the new
function handle into the handle map (so that the Crucible Call statement can
find it).
2018-07-05 15:16:17 -07:00
Tristan Ravitch
dd53e4231f Revise the GlobalMap API
The GlobalMap is mapping from virtual addresses computed by a program to the
corresponding logical address in the LLVM memory model during symbolic
simulation.  It is needed because addresses in binaries are computed from
bitvectors, which are not valid pointers in the LLVM memory model.

This change turns the GlobalMap from a Data.Map into a function, which is more
flexible and allows for a wider range of possible implementations of this
functionality, especially implementations that introduce numerous disjoint
segments for the original binary contents.
2018-06-19 17:27:30 -07:00
Joe Hendrix
494f6c176d
Updates to Macaw. 2018-06-06 11:48:45 -07:00
Simon Winwood
6a29ed6e56 Added function to convert a single block to Crucible. 2018-06-01 10:54:27 -07:00
Tristan Ravitch
493377cbb9 symbolic: Rewrite the translation of macaw calls into crucible
The former strategy was to represent macaw calls using a macaw-specific
MacawCall statement, which was interpreted by a call handler (which took
registers+memory as input and produced new registers+memory as an output).  This
worked for cases where the callee had a summary, but did not allow for
simulating the called function inline.  Moreover, the OverrideSim monad doesn't
admit recursive calls in this context (we can make the call, but we can't get
the final simulator state out, which we would need to implement a call handler
in macaw-symbolic).

The new strategy is to translate macaw calls into two separate statements:

1. A `LookupFunctionHandle` call, which returns a Crucible FunctionHandle, and
2. A normal Crucible `Call`

The interpretation of LookupFunctionHandle has the full register+memory state
available, and can inspect the IP to determine which function has been
called (and provide the necessary FunctionHandle, which will be interpreted by
Crucible in the standard way).  Note that the handler is in IO, so client code
can translate functions being simulated into Crucible on-demand.
2018-05-25 18:19:19 -07:00
Rob Dockins
c382b59bed Bump crucible submodule to pull in crucible/what4 split refactor,
and update macaw-symbolic and macax-x86-symbolic.
2018-05-15 15:58:14 -07:00