Commit Graph

80 Commits

Author SHA1 Message Date
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
Rob Dockins
643989f4b6 Update Macaw libraries for recent Crucible changes 2018-05-02 17:21:26 -07:00
Joe Hendrix
9047cb41fb
Fix warnings in macaw-base; Fix errors in macaw-symbolic.
This also makes some changes to eliminate a couple redundent
type-class constraints in CrucGen.hs which propagated to other changes.
2018-04-24 01:17:03 -07:00
Joe Hendrix
052506f202
Remove PhaseHolderStmt. 2018-04-23 11:35:31 -07:00
Tristan Ravitch
b2d955cb3e symbolic: export macawExtensions
This makes it easier (possible?) to call the simulator with a more custom setup
than is supported by runCodeBlock
2018-04-13 11:52:30 -07:00
Tristan Ravitch
9f93fd09c9 symbolic: Expose the constructor for MacawSimulatorState
This is needed to run the simulator
2018-04-13 09:06:03 -07:00
Tristan Ravitch
a229951066 symbolic: Re-export MacawExt to make it easier to use Data.Macaw.Symbolic 2018-04-02 14:20:43 -07:00
Tristan Ravitch
1517bf64b4 symbolic: Translate the macaw ArchState statement into crucible
This commit introduces a new syntax extension for the macaw translation to
represent the ArchState statement: MacawArchStateUpdate.

Also adds some new instances for MacawCrucibleValue.
2018-04-02 09:14:17 -07:00
Jason Dagit
372d7d7208 Add a new macaw statement to record updates to machine registers
The new statement is called `ArchState`, and has two fields: an address and a
map.  The address is the address of the instruction it is standing in for.  The
map contains a mapping from the *machine registers* that the instruction updated
to the *macaw values* that were assigned to those locations.

This is useful metadata for debugging, but is also required to do some types of
architecture-independent analysis (where we can still reason about machine
register contents).
2018-03-29 09:53:08 -07:00
Iavor Diatchki
3736ce137a Remove some warnings. 2018-03-23 14:37:08 -07:00
Iavor Diatchki
2f070f99f0 Setup LLVM intrinsics, and make sure to use the config as the one for the sym. 2018-03-23 14:34:38 -07:00
Iavor Diatchki
79a4cdf39e Add support for forcing allocation of fresh bits (as opposed to pointer/bits) 2018-03-22 13:11:22 -07:00
Iavor Diatchki
cf34388d41 Don't validate pointer after alignment.
We validate only when using pointers.
2018-03-22 13:10:58 -07:00
Iavor Diatchki
21ffae1ebe Prefix fresh names with macaw
Hopefully, this will avoid clashes with keywords.
2018-03-21 16:14:31 -07:00
Iavor Diatchki
36e6c8f7b9 Export GlobalMap 2018-03-20 19:56:52 -07:00
Iavor Diatchki
cec6f52e0f Merge branch 'master' of github.com:GaloisInc/macaw 2018-03-20 19:04:05 -07:00
Iavor Diatchki
20135c91ae Generate fresh symbolic values. 2018-03-20 19:03:50 -07:00
Joe Hendrix
77f518a9ab
Merge pull request #3 from robdockins/master
Minor update to track crucible API
2018-03-20 15:03:29 -07:00
Iavor Diatchki
4988297429 Change semantics for pointers!
When computing pointers we don't always check that the results are valid.
Instead, we do the check whenever we use the pointers.

The reason is to support code where pointers are temporarily "bad"
but are never used that way.  For example:


   subq $10, %aex   # aex contains a pointer
Loop:
   addq $10, %aex
   ...
2018-03-16 16:14:25 -07:00
Iavor Diatchki
1ea6792f28 Add special treatment for "aligning" pointers.
We don't really do anything with alignment, but sometime asm code
ands pointers to align them.  For example `andq $(-64), %rsp`
aligns the pointer to a multiple of 64.

To support code like this we treat "and"-ing a pointer with a special
constant of the form 0xFFFF...FF000  (i.e., and alignment) as a subtracting
`0x0000...00XXX`  where the `XXX` is symbolic.

This looses some information (i.e., we don't know that the result is aligned).
However, it is good enough for checking memory safety, as it covers
all possible results of the alignment.
2018-03-16 13:35:58 -07:00
Rob Dockins
4a4b9d7a8a Minor update to track crucible API 2018-03-15 17:21:42 -07:00
Iavor Diatchki
f8dfc368c6 Allow reading from raw global addresses. 2018-03-14 17:20:22 -07:00
Iavor Diatchki
9c7070f8e6 Haddock comments fixes, thanks to Brian 2018-03-09 09:51:55 -08:00
Iavor Diatchki
89529ed7e3 Be more lenient when interpreting bogus expressions.
Previously we were asserting that some bogus-y things don't happen.
Unfortunately, these expressions can occur in code that was not
directly written by the user (e.g., comparisons for setting various
machine flags).   To allow for that, we allow the expressions, but
give them undefined values.  So the proof will succeed only if it
does not depend on the values of these bogus comparisons.
2018-03-07 10:22:46 -08:00
Iavor Diatchki
417c34429d Add some support for function calls.
We basically punt, by passing-in a function to use as the implementation of
all functions.  This function is supposed to look at the IP, and
decide what to do.
2018-03-05 16:29:15 -08:00
Iavor Diatchki
32710829f6 Use pointer addition, only when the value is not a bit-vector.
The other version was getting confusing by the NULL pointer.
2018-03-05 13:47:55 -08:00
Iavor Diatchki
4fa262a14c Implement MacawFresh for booleans. 2018-03-05 13:47:21 -08:00
Iavor Diatchki
9094d1bd91 Improve failure message. 2018-03-01 14:36:24 -08:00
Iavor Diatchki
c69349e957 Add support for global memory regions. 2018-03-01 10:00:32 -08:00
Joe Hendrix
54038b5f20
Merge branch 'mem-model' of github.com:GaloisInc/macaw into mem-model 2018-02-26 12:44:07 -08:00
Joe Hendrix
fa6f74b583
Remove unused freshVarsForRegs 2018-02-26 12:42:08 -08:00
Iavor Diatchki
aac5a3e00f Commit the bug fix. 2018-02-21 15:24:25 -08:00
Iavor Diatchki
e3f4e0875b Bugfix and show more info when failing. 2018-02-21 15:06:18 -08:00
Iavor Diatchki
8bf523f8b1 Fill in imitted lemma 2018-02-21 09:47:53 -08:00
Joe Hendrix
0f6d030c86
Initialize variable for storing registers before use. 2018-02-19 12:48:59 -08:00
Iavor Diatchki
b8aa67918b Assocaite global memory varaible name with its value. 2018-02-13 16:44:35 -08:00
Iavor Diatchki
470182dccb Only pass around the memory var during execution, not CFG generation. 2018-02-13 10:14:22 -08:00
Iavor Diatchki
ad5f7ceddb Add write operation 2018-02-12 10:28:39 -08:00
Iavor Diatchki
b57483b1f8 Start on writeMem 2018-02-09 16:59:42 -08:00
Iavor Diatchki
1c07b88ae7 Implement conditional read. 2018-02-09 15:30:06 -08:00
Iavor Diatchki
3c2fdeafe4 Implement reading from memory. 2018-02-09 14:13:39 -08:00
Iavor Diatchki
86c730043e Cleanup pointer manipulation operations. 2018-02-09 11:41:39 -08:00