Commit Graph

340 Commits

Author SHA1 Message Date
Joe Hendrix
1510c247e3 Add MkTuple primitive. 2020-11-06 13:02:09 -08:00
Lisanna Dettwyler
47544e4b2d Fix warnings in GHC 8.10 2020-10-20 13:53:22 -07:00
Ben Selfridge
039b8497fc
updates what4, crucible, etc. (#146)
* update to bv-sized branch of what4 and other things

* removed parameterized-utils submodule completely

* Updates submodules

* Fixes macaw-symbolic w.r.t. crucible-llvm changes

Co-authored-by: Ben Selfridge <ben@000548-benselfridge.local>
2020-06-16 16:49:55 -07:00
Sam Breese
02c6cc3cb5
Handle bitwise operations on stack offset abstract values (#136)
- Generalize handling of bitwise operations to also apply them to stack offsets
- Use the extended bitwise handling on AND
2020-05-28 14:04:06 -04:00
Ben Selfridge
76868cf457
Fixed buggy rewrite rules involving testBit/shifts (#132)
* Fixed buggy rewrite rule involving testBit/shifts
2020-05-05 15:45:36 -07:00
Tristan Ravitch
e536e43f1b Introduce macaw-aarch32 and macaw-aarch32-symbolic
These packages replace the old macaw-arm (which has been removed).  The only
change to the core macaw is to introduce a `Lift` instance for the Endianness
data type, which is used in macaw-semmc.

The macaw-aarch32 package uses the official ARM semantics (via the
asl-translator package).  In its current state, macaw-aarch32 seems to handle
the common idioms of simple ARM binaries.  Position independent executables have
not been tested yet.  The semantics and disassemblers for Thumb are present, but
not integrated into code discovery at this time.  There are some tests in
macaw-aarch32.  Compile times are longer than necessarily desired.
macaw-aarch32 can be compiled in two modes: lite mode (cabal flag -fasl-lite),
which uses a restricted set of instructions for testing, and takes less time to
compile.  The full instruction set is the default, though there are a few
undefined functions that are not yet handled for the full set, mostly relating
to floating point operations.

The macaw-aarch32-symbolic package is currently a stub, but is implemented to
provide a few necessary instances.
2020-04-12 19:53:00 -07:00
Tristan Ravitch
958aeaa3ed Remove the nested mux match rule from macaw core
We can now do enough rewriting in the ARM backend that it isn't needed.  This
adds extra ARM rewriting rules and a term cache to make matching easier.
2020-04-08 19:46:32 -07:00
Daniel Matichuk
77e721ac0e add support for redundant nested muxes 2020-04-04 22:24:47 -07:00
Daniel Matichuk
5dab9c5209 Merge remote-tracking branch 'origin/master' into feature/asl 2020-04-03 23:38:19 -07:00
Ben Selfridge
8afc18dc62 feature/asl: BROKEN BUILD -- updated asl-translator, need to fix 2020-04-03 18:33:31 -07:00
Joe Hendrix
14da5837a6 Remove spurious warnings from function args. 2020-03-25 23:20:53 -07:00
Joe Hendrix
2f93b70946 Fix register-use; add null terminated string reader to Memory. 2020-03-20 18:22:48 -07:00
Tristan Ravitch
e024646860
macaw-refinement (#114)
This commit updates macaw-refinement to work with the latest macaw/crucible and makes a few improvements along the way.

The major changes involved in this are:
* Block labels were removed from macaw, so we had to come up with an alternative approach to making synthetic blocks to represent dispatch resolved by macaw-refinement that is not really a jump table. We considered adding a new terminator that encoded "computed IP-based dispatch", but there was concern about the impact on client code. Instead, we added a field to the `DiscoveryFunInfo` that records "external" resolutions to indirect control flow (e.g., as by an SMT solver in macaw-refinement). The hook by which we feed SMT-based resolutions back into macaw was modified accordingly (`addDiscoveredFunctionBlockTargets`).
* Solver invocation changed to allow solver selection and parallel solver application.
* Logging is now done via the `lumberjack` library.
* macaw-symbolic now uses the "external" resolutions in `DiscoveryFunInfo` while building crucible CFGs.
* The path creation code in macaw-refinement was simplified significantly and the approach to path creation has been documented.
* The run-refinement tool is now more featureful.
* The test suite is a bit more structured and no longer depends on the printed output of the discovery process.
2020-03-12 17:15:08 -07:00
Ben Selfridge
deb6d2b161 feature/asl: lifted endianness out of macaw-semmc TH 2020-03-09 16:07:07 -07:00
Tristan Ravitch
c825332f39
Update/ghc 8.8 (#112)
Updates for GHC 8.8

The two main classes of update are related to MonadFail and type alias expansion.

The MonadFail updates introduce explicit MonadFail instances and backward-compatible `fail` implementations under `Monad` for older GHC versions.

The type alias expansion rules changed in GHC 8.8 in a way that breaks the `Simple Lens` idiom; instead, we have to use `Lens'`.  Lens started supporting this alias in version 3.8, which was released in 2013.

This change includes necessary submodule updates, as well as the update for the split of what4 into its own repository.
2020-03-03 13:28:26 -08:00
Joe Hendrix
54a9f93431 Remove invariant type from registeruse 2020-02-07 00:19:19 -08:00
Joe Hendrix
5925c4f68f Code cleanups 2020-02-06 19:26:46 -08:00
Joe Hendrix
00303e8f40 Fix warnings; code cleanups. 2020-02-06 19:26:46 -08:00
Joe Hendrix
46be7aa52b Implement new registerUse analysis.
The new registerUse analysis uses a three phase process:

Phase 1 computes invariants about the start state of each block.  It
will indicate when registers/stack locations store stack offsets, and
where callee saved registers are stashed.  It also memoizes
information about stack reads and writes to simplify later passes.

Phase 2 is a demand analysis that computes which registers and stack
locations must be available to execute the program.  It then
propagates those constraints across blocks in the function.

Phase 3 combines the information into a form relevant for function
recovery.
2020-02-06 19:26:46 -08:00
Joe Hendrix
9433737292 Bump macaw base version 2020-02-06 19:16:23 -08:00
Joe Hendrix
0236aa5d9a Introduce separate stack-analysis algorithm. 2020-02-06 19:16:23 -08:00
Tristan Ravitch
c1d4155f3d
Merge branch 'master' into tr/block-classifier-context-type 2019-12-06 10:56:44 -08:00
Joe Hendrix
145bca4591
Add reopt dependency analysis to macaw. 2019-12-04 15:23:44 -08:00
Tristan Ravitch
5509548372 Change the BlockClassifierContext in Discovery into a datatype (from a tuple)
I'm about to add a new field, and the 7-tuple was a bit confusing.
2019-11-27 11:57:13 -08:00
Joe Hendrix
df9b5bbe27
Support for offset jump tables. 2019-11-19 14:52:58 -08:00
Tristan Ravitch
1c5abc6728 Documentation updates in macaw-base 2019-11-12 17:27:14 -08:00
Joe Hendrix
1cc36b4d0c
Propagate correct stack value after call. 2019-10-28 13:49:00 -07:00
Joe Hendrix
cf8c33398e
Additional exports; bounds pretty printing. 2019-10-28 13:47:59 -07:00
Joe Hendrix
81d0469fbe
Group mod/div x86 functions. 2019-10-21 14:59:43 -07:00
Joe Hendrix
d5a51ff9c3
Cleanups to jump bounds. 2019-10-17 23:33:57 -07:00
Joe Hendrix
26f29f3005
Generalizations to support reopt. 2019-10-16 13:57:19 -07:00
Joe Hendrix
d16f2b2ea0
Remove spurius calls to error in AbsState bvsbb. 2019-10-02 12:32:42 -07:00
Kevin Quick
4536e9d33e
[base] Fix GHC 8.4.4 haddock 2019-10-01 14:09:18 -07:00
Joe Hendrix
5e834122d1
Segment register updates; stack offset calculation. 2019-09-20 13:58:05 -07:00
Joe Hendrix
94549ef6cb
Update minor version for precondition addition. 2019-09-04 23:29:14 -07:00
Joe Hendrix
df95e65987
Various changes to support VCG.
The changes include:

  Clean up elf loading to fix a bug in rel addend parsing.

  Introduce block preconditions for populating reopt-vcg fields.

  Change load options to match reopt's interface.
2019-09-04 23:21:23 -07:00
Joe Hendrix
28e3624ca6
Bump parameterized-utils version 2019-08-30 00:02:23 -07:00
Joe Hendrix
5a8d7d5f07
Update cached fold to use CValue constructor. 2019-08-29 23:50:25 -07:00
Kevin Quick
a2af885b67
Cannot haddock tuple fields, so use pre-type haddock over entire tuple.
This is less satisfying because it separates the documentation from
the fields, but it seems to be necessary for haddock to work.
2019-08-28 10:07:13 -07:00
Kevin Quick
8f32297a35
Haddock works better with constructor pre-documentation.
I believe this is due to an ambiguity of whether the
post-documentation reference is to the previous constructor or just
the last argument of the previous constructor.  By moving the haddocks
to be a pre-doc this seems to work better.
2019-08-28 09:59:15 -07:00
Kevin Quick
bc9d5433ee
Haddock requires indentation to match the constructor argument. 2019-08-28 09:58:35 -07:00
Kevin Quick
f342c9d000
Haddock cannot document constructor fields with strictness annotations.
It also cannot handle the UNPACK pragma, which could probably be
removed since -funbox-small-strict-fields is on by default, but
haddock would still fail for the strictness annotation.

By moving the haddocks to the constructor instead of the individual
fields the strictness restriction can be avoided.
2019-08-28 09:56:01 -07:00
Joe Hendrix
433df7399e
Additional Hashable instances for Macaw/hashtable compatibility. 2019-08-27 16:40:16 -07:00
Joe Hendrix
821d434370
Add support for equalities in jump table bounds. 2019-08-27 16:39:41 -07:00
Joe Hendrix
8376ecbed6
Fix warnings. 2019-08-23 09:57:54 -07:00
Joe Hendrix
c2545b1bb1
Work-in-progres: Cleanups to discovery for jumpbounds improvements. 2019-08-23 01:11:52 -07:00
Joe Hendrix
b1c6fb8b77
Fix parameterized-utils dependency 2019-08-21 23:59:22 -07:00
Joe Hendrix
494aff6ff0
This makes a number of changes to abstract domains.
The goal is to support a jumptable testcase that is not supported by
the current jump bounds check.  The jump bounds check needs to be
augmented so that it understands equality relationships between stack
values and registers, and bounds on both.

This patch tracks when a register points to a concrete stack offset.

As part of this, we droped the AbsDomain instance for AbsBlockState.
Clients should now likely use `fnStartAbsBlockState` in lieu of `top`.

The other client visible change is that the ClassifyFailure
constructor now has an extra argument with details about why
classification failure occured.
2019-08-21 23:29:16 -07:00
Joe Hendrix
e8c4d39840
Introduce MemInt 2019-08-21 23:17:18 -07:00
Kevin Quick
84a14372cd
Fix parse error for haddock. 2019-08-12 22:11:25 -07:00
Joe Hendrix
f03fdce04b
Remove other unpack 2019-08-12 12:51:09 -07:00
Joe Hendrix
68d881c96f
Fix warnings 2019-08-12 11:44:39 -07:00
Joe Hendrix
073e774a43
Introduce CValue; clarify function arguments fields.
This introduces a new datatype CValue for representing constants
in Macaw programs, modifies the existing Value datatype to use then,
and introduces patterns for compatibility with existing datatypes.

The patch also updates the function argument analysis to use more
explicit argument passing rather than monadic updates.  The intent is
to help clarify when data is initialized rather than updated.

Finally this updates a README and does some minor updates.
2019-08-06 09:37:41 -07:00
Joe Hendrix
dfd92b047a
Add support for additional ARM relocations. 2019-08-01 09:43:36 -07:00
Joe Hendrix
a99d999fd0
Update for android compatibility 2019-07-29 11:41:50 -07:00
Joe Hendrix
bb66fd64ec
Merge branch 'master' into jhx/absstate 2019-07-12 00:31:46 +01:00
Kevin Quick
01c2d5d387
Add mhnf rewriting.
The parseFetchAndExecute in Discovery attempts to identify ParsedITE
terminal statements by examining the value of the ip_reg via
valueAsApp and pattern matching on a Mux statement.  This patch adds
specific handling in the Macaw CFG Rewriter to attempt to float Mux
statements upwards (aka "Mux Head Normal Form") so that they will be
the top-most ip_reg value and therefore be recognized as a ParsedITE
terminator.

For macaw-ppc testing of the 988KB gzip binary, this increased the
number of blocks found from 1339 to 37950 (and increased the test
runtime from 1.36s to 88.14s).
2019-07-10 23:59:11 -07:00
Joe Hendrix
a7a145be77
Fix compilation bugs in bcinc. 2019-07-03 13:50:01 -07:00
Joe Hendrix
b604cb28f1
Merge remote-tracking branch 'origin/master' into jhx/absstate 2019-07-03 13:24:46 -07:00
Joe Hendrix
52cf172c69
Minor layout/clarity updates. 2019-07-03 13:22:40 -07:00
Kevin Quick
1d03a7b3b6
[base] update ParsedIte/ParsedBranch reference in comment. 2019-07-02 11:09:16 -07:00
Joe Hendrix
f2249ffc23
Bump macaw-base version for export 2019-07-01 16:47:46 -07:00
Joe Hendrix
17c09c974f
Bump submodules; clarify stack offset abstract values 2019-07-01 16:35:47 -07:00
Joe Hendrix
cbb3814017
Fix warnings. 2019-06-13 09:33:58 -07:00
Joe Hendrix
c4870f9a37
Merge remote-tracking branch 'origin/master' into jhx/funargs 2019-06-12 15:51:55 -07:00
Joe Hendrix
dba7a2e88d
Bump submodules; version dependencies 2019-06-12 15:49:05 -07:00
Joe Hendrix
ee6f1379ae
Additional cleanup to function args; bump versions.
This also provides some exports needed by Reopt.
2019-06-12 15:26:19 -07:00
Kevin Quick
7bacee3e9d
[base] fix haddock syntax error. 2019-06-05 14:40:59 -07:00
Joe Hendrix
d3c23cbe55
Remove CPP extension 2019-06-05 15:55:29 -04:00
Joe Hendrix
ee137cccc4
Cleanup warnings. 2019-06-05 15:31:03 -04:00
Joe Hendrix
4368ed6239
Fix parameterized-utils and bump version. 2019-06-05 09:50:12 -04:00
Joe Hendrix
c3f747aa86
Update dependencies/minor corrections. 2019-06-05 09:02:25 -04:00
Joe Hendrix
d58292feda
Generalize function argument analysis.
This patch focuses on function argument analysis, but includes some
other cleanups.

The main changes are to add additional comments and cleanups to the
function argument analysis code.  This also extends the analysis so
that we can annotate the types of some of the functions and use those
types during analysis.

As part of this we tighten the PLTStub checking, and clean up the
elfloader in some minor ways.
2019-06-05 04:42:02 -04:00
Joe Hendrix
5c097b45b7
Continue exporting width equality proofs comparison/equality. 2019-05-30 22:54:49 -07:00
Joe Hendrix
5221880b10
This makes a few minor changes primarily for reopt.
WidthEqProofs are now irrelevant.  Two proofs with the same
coercision source and destination will be equal.  This allows us to
add a transitivity constructor without introducing spurious
inequalities, and will in the future allow us to collapse multiple
bitcasts into a single bitcast.

adjustedLoadRegionIndex is exported for reopt.

TypeRepr now has a pretty instance.
2019-05-30 10:31:45 -07:00
Joe Hendrix
f0f5d0e123
Improve jump table bounds accuracy.
This adds functionality to the jump table bounds to work with trunc
that was deliberately removed in the last patch due to buggy code.
2019-05-14 21:03:08 -07:00
Joe Hendrix
0b7dae7add
Merge remote-tracking branch 'origin/jhx/no-branch' into jhx/no-branch 2019-05-14 17:48:37 -07:00
Joe Hendrix
1607e83eef
Minor refactoring; improved branch abstract state propagation.
This primarily refines the abstract state propagated to branch
pairs.  It was needed on the ARM platform to support the IT blocks
with the changes to the Core representation in macaw-base 0.3.6.

This also includes a few simplifications added and comment
improvements.
2019-05-14 17:45:30 -07:00
Joe Hendrix
6299fa489b
Fix bug in AbsState.trunc 2019-05-11 16:29:54 -07:00
Joe Hendrix
ca2ca7d130
Merge remote-tracking branch 'origin/master' into jhx/no-branch 2019-05-06 10:54:35 -07:00
Joe Hendrix
56cadae3ae
Update submodules 2019-05-02 14:29:10 -07:00
Joe Hendrix
d20a3a9820
Update elf loader to use dynamic symbol table. 2019-05-02 12:36:43 -07:00
Joe Hendrix
008a53f3db
Add parsedTermSucc 2019-04-30 13:09:39 -07:00
Joe Hendrix
c6a7ba7cd6
Rename pblock fields to be more descriptive. 2019-04-29 22:21:10 -07:00
Joe Hendrix
581a01b5ef
Delete BlockLabel now that it is unused. 2019-04-29 21:57:41 -07:00
Joe Hendrix
70ea5b9036
Remove ParsedIte 2019-04-29 20:46:54 -07:00
Joe Hendrix
8aa4650683
Introduce ParsedBranch constructor. 2019-04-29 10:49:00 -07:00
Joe Hendrix
3331a19571
Drop support for branches within blocks. 2019-04-28 13:19:20 -07:00
Joe Hendrix
89f89e9ce6
This adds a conditional memory write to macaw. 2019-04-17 11:15:12 -07:00
Joe Hendrix
4513a92848
Update comments. 2019-04-08 16:31:28 -07:00
Joe Hendrix
62d27d629d
Update to latest elf-edit; bump other submodules. 2019-04-08 16:21:08 -07:00
Joe Hendrix
82b96fb62a
Fix warnings; improve PLTStub comment. 2019-03-25 19:27:46 -07:00
Joe Hendrix
f1f16b7509
Remove warnings 2019-03-22 14:40:14 -07:00
Joe Hendrix
51333f4612
Deprecate outdated disassemble block functions. 2019-03-14 10:41:11 -07:00
Daniel Wagner
b6778a80c1 comparisons with max or min values are easy 2019-03-04 14:38:31 -05:00
Joe Hendrix
e8d2efcaae
Implement bitcast changes to macaw-symbolic 2019-02-26 17:53:34 -08:00
Joe Hendrix
00096344a7
Support float/vector in reads/writes; Use floating point types. 2019-02-20 15:40:59 -08:00
Joe Hendrix
35af2a5c3a
Rename VectorTypeRepr to VecTypeRepr 2019-02-19 10:18:12 -08:00
Joe Hendrix
3b7e12de16
Update to fix build process. 2019-02-15 00:28:35 -08:00
Joe Hendrix
d3947f32b4
Support ZMM, bitcasting, and fixed length vectors. 2019-02-14 11:06:45 -08:00