Commit Graph

242 Commits

Author SHA1 Message Date
Joe Hendrix
3dc9463b8d
Remove unused control register code. 2019-09-09 00:50:07 -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
0ad6ed8a85
Minor cleanup 2019-08-29 23:50:25 -07:00
Joe Hendrix
0767302c21
Add .gitignore for assembly files. 2019-08-27 16:42:08 -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
c2545b1bb1
Work-in-progres: Cleanups to discovery for jumpbounds improvements. 2019-08-23 01:11:52 -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
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
06b0390cfd
Fix missing import in x86 2019-07-01 17:13:06 -07:00
Joe Hendrix
17c09c974f
Bump submodules; clarify stack offset abstract values 2019-07-01 16:35:47 -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
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
c6a7ba7cd6
Rename pblock fields to be more descriptive. 2019-04-29 22:21:10 -07:00
Joe Hendrix
327003ae56
Fix test case. 2019-04-29 22:04:21 -07:00
Joe Hendrix
3331a19571
Drop support for branches within blocks. 2019-04-28 13:19:20 -07:00
Joe Hendrix
2d12aea63b
Merge branch 'jhx/bump-submodules' into jhx/cond-write 2019-04-26 10:38:50 -07:00
Joe Hendrix
89f89e9ce6
This adds a conditional memory write to macaw. 2019-04-17 11:15:12 -07:00
Joe Hendrix
ec15debe20
Minor updates 2019-04-12 11:24:37 -07:00
Joe Hendrix
ef6951458a
Add pop tests. 2019-04-04 09:42:11 -07:00
Joe Hendrix
092cbc2e26
Minor fixes to tests 2019-04-03 16:44:00 -07:00
Joe Hendrix
3e763cc7a1
Add ret test 2019-04-03 16:43:42 -07:00
Joe Hendrix
74e8c6580e
Merge pull request #32 from GaloisInc/jhx/x86_tests
Add tests for btc/btr/bts
2019-04-03 13:59:50 -05:00
Joe Hendrix
036944d42e
Add btc/btr/bts tests 2019-04-03 08:24:57 -07:00
Joe Hendrix
a6149fa95f
Add x86-support to travis 2019-03-26 08:21:01 -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
Joe Hendrix
e8d2efcaae
Implement bitcast changes to macaw-symbolic 2019-02-26 17:53:34 -08:00
Joe Hendrix
c950affd65
Fix build errors made in previous commit. 2019-02-20 15:57:56 -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
d3947f32b4
Support ZMM, bitcasting, and fixed length vectors. 2019-02-14 11:06:45 -08:00
Luke Maurer
cbda1717cc Fix for GHC versions < 8.8
`MonadFail` being a forward-compatibility measure, overriding
`Control.Monad.Fail.fail` in GHC versions <= 8.6 doesn't do anything
unless `Control.Monad.Fail.fail` is invoked explicitly (or the importing
module happens to have `-XMonadFailDesugaring` on).
2019-02-12 18:24:41 -08:00
Langston Barrett
274808a8ae update parameterized-utils submodule 2019-02-11 11:47:19 -08:00
Tristan Ravitch
05249a4632 Change some calls to fail into translation errors
These `getCallTarget` and `doJump` were calling `fail` if they saw an argument
type that we hadn't thought to handle yet.  This change turns those errors into
TranslationError statements, allowing macaw to continue exploring code.

This came up recently in a glibc-based example where macaw ended up exploring
unaligned code and creating a strange jump to a far pointer, which doesn't make
much sense in x86_64 mode.
2019-01-23 13:22:03 -08:00
Joe Hendrix
a5e3ba7247
Additional exports 2019-01-22 15:51:38 -05:00
Joe Hendrix
3eb92f34e1
Add x86_tests 2019-01-22 13:25:37 -05:00
Joe Hendrix
0eac4d6b49
Remove blockAddr; update dependencies 2019-01-22 05:07:52 -05: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
Kevin Quick
98807daee2
Added -Wcompat for warnings about future compatibility. 2019-01-10 13:43:27 -08:00
Joe Hendrix
ebc5d9575e
Merge remote-tracking branch 'public/master' into jhx/plt-support 2018-12-04 08:04:32 -08:00
Joe Hendrix
f03941d607
Add test-plt test case, and fix discovery to use trust symbols. 2018-12-04 00:04:23 -08:00
Andrei Stefanescu
3f39c614e9 Add support for RepMovs and RepStos. 2018-11-27 02:23:36 -08:00
Kevin Quick
1d7cdc87eb
Implement NoStarIsType and MonadFail for GHC 8.6. 2018-11-21 00:08:33 +00:00
Joe Hendrix
c4b7252c77
Add specialized terminal statement for PLT stubs. 2018-11-16 13:40:40 -05:00
Joe Hendrix
23fe50bd45
Fix stack offset. 2018-11-12 15:28:32 -05:00
Joe Hendrix
bb63f9f859
This fixes tail call detection, and allows architecture-specific checks. 2018-11-12 11:56:44 -05:00
Kevin Quick
ceba0bfa67
[x86] Update memory references to remove deprecated uses. 2018-10-31 13:48:06 -07:00
Kevin Quick
db17327121
[x86] Add andnps semantics with consolidation of binary bitwise support. 2018-10-31 11:50:15 -07:00
Kevin Quick
6d996f7739
[x86] Add shld and shrd instruction semantics. 2018-10-31 11:49:14 -07:00
Kevin Quick
1ca2c5582c
[x86] Fix cvtsd2ss instruction mnemonic. 2018-10-31 11:48:18 -07:00
Kevin Quick
3c76f404af
[x86] Comment fixes. 2018-10-31 11:47:52 -07:00
Kevin Quick
6212a69233
[x86] Add semantics for sqrtss and sqrtsd. 2018-10-31 11:46:01 -07:00
Joe Hendrix
4594938dfd
Make decoding position independent; Support translating fixed blocks. 2018-10-25 13:36:21 -07:00
Tristan Ravitch
0513ae7a39 x86: Add some more missing signed immediate handling cases in getAddrRegSegmentOrImm
This is not currently an error, as this function is only used in the definition
of the semantics for push, which doesn't accept a signed immediate value.  This
fix is defensive in case someone decides to re-use this helper in another
context where the missing cases could cause a problem.
2018-10-24 10:25:18 -07:00
Tristan Ravitch
d6060e51be x86: Fix a bug affecting imul (and add a test case)
We were hitting a translation error for imul in another application - this test
case is a reduced example demonstrating the problem.

The root cause was that there were a few missing cases for the new signed
immediate values from flexdis; this caused a fallthrough that mis-identified
signed immediates as non-immediates, triggering an error.
2018-10-24 10:23:51 -07:00
Tristan Ravitch
cc165d7316 x86: Make the test suite more verbose on translation errors
This makes debugging easier
2018-10-24 10:22:21 -07:00
Tristan Ravitch
563547fee5 Add semantics for minss, maxss, minsp, and maxsp (x86) 2018-10-23 15:18:40 -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
Joe Hendrix
18e36f84aa
Ensure X86 register names are unique 2018-10-03 11:36:44 -07:00
Andrei Stefanescu
c5f0806751 Add symbolic semantics to X86 SSE floats. 2018-09-18 22:07:17 -07:00
Andrei Stefanescu
bd906c85a9
Merge pull request #13 from GaloisInc/floating-point
Add support for floating-point.
2018-09-06 14:05:23 -07:00
Nathan Collins
b6bc9c91e7 Generate MacawArchStateUpdate stmts in Crucible IR
By adding `asAtomicStateUpdate` in analogy with
`Data.Macaw.SemMC.Generator.asAtomicStateUpdate` and its use in
`Data.Macaw.PPC.Disassemble`.
2018-08-30 14:49:37 -07:00
Andrei Stefanescu
e2ea117465 Propagate Macaw float type changes to X86 semantics. 2018-08-27 11:37:01 -07:00
Joe Hendrix
230b318dcf
Updates to discovery 2018-08-14 23:29:02 -07:00
Kevin Quick
c56f66a150
[x86] Fix/update haddock documentation. 2018-07-28 15:28:28 -07:00
Joe Hendrix
e4a27d7bbc
Merge branch 'master' of github.com:GaloisInc/macaw 2018-07-27 00:28:50 -07:00
Joe Hendrix
c6a1ecba6c
Rename MemSet to RepStos to reflect underlying x86 function. 2018-07-27 00:24:24 -07:00
Tristan Ravitch
4e78ec3b8a x86: Haddock fixes 2018-07-26 20:32:32 -07:00
Joe Hendrix
3906cbd501
Change MemCopy to RepMovS primitive. 2018-07-24 14:13:44 -07:00
Joe Hendrix
901446bda5
Add test case for object jump table. 2018-07-20 18:16:52 -07:00
Joe Hendrix
0d0898c644
Add support for parsing jump tables with relocations in entries.
This also adds simplification rules and some refactoring of existing
interfaces
2018-07-20 09:57:06 -07:00
Joe Hendrix
f1c5b10fd5
Extend relocation support and 1-1 x86 block association. 2018-07-18 16:57:17 -07:00
Joe Hendrix
6391a87db1
Merge branch 'master' of github.com:GaloisInc/macaw 2018-06-12 16:20:55 -07:00
Daniel Wagner
f4d4e381b7 have a way to align potentially misaligned IPs 2018-06-11 10:30:32 -04:00
Joe Hendrix
494f6c176d
Updates to Macaw. 2018-06-06 11:48:45 -07:00
Daniel Wagner
d0566fe03b lay some groundwork for jump table detection on PPC 2018-05-30 15:50:16 -04:00
Jason Dagit
d0d30f038d Merge branch 'master' of github.com:GaloisInc/macaw 2018-05-29 18:36:35 -07:00
Jason Dagit
e9756ed6a9 Semantics: fix repnz termination condition 2018-05-29 18:36:26 -07:00
Daniel Wagner
588e92cc01 add a few jump target formats 2018-04-24 17:05:17 -04:00
Joe Hendrix
000c2f900e
Move macaw stack.yaml to root for similiarity with other Galois packages. 2018-04-24 09:05:36 -07:00
Joe Hendrix
6267122136
Add packages to stack.yaml 2018-04-24 08:25:13 -07:00
Joe Hendrix
9259a7e1f3
Update stack to reflect actual ghc version. 2018-04-23 11:57:24 -07:00
Joe Hendrix
4c290c2a33
Update to build with ghc 8.2.1 2018-04-23 11:56:01 -07:00
Joe Hendrix
097edda1ef
Relocation support; various cleanups.
This patch adds initial support for relocations in Macaw code
discovery, and adds other refactoring.

* It introduces a SymbolValue constructor to represent references to
  symbols within Macaw.
* The various cases for x86 mov are made explicit after the flexdis refactor
  broke the previous code.  We should now support segment register movs and
  give better error messages when seeing mov with control or debug registers.
* The generic exception operation is replaced with Hlt and UD2 terminal
  x86-specific statements.
* CodeAddrReason is split into FunctionExploreReason and BlockExploreReason to
  clarify whether a function or block was discovered.
* The Macaw pretty printer is changed to use write_mem in place of pointer syntax.
* Various other refactoring is made to clarify code.
2018-04-23 11:24:21 -07:00
Joe Hendrix
0b8e95b0b0
Merge branch 'master' of github.com:GaloisInc/macaw 2018-04-17 16:02:28 -07:00
Tristan Ravitch
43688edef9 Fix a haddock parse error
Postfix haddock comments on GADT constructors (or constructor arguments) are not
yet supported.
2018-04-10 09:51:10 -07:00
Joe Hendrix
81e9c168af
Update submodules 2018-04-05 09:10:39 -07:00
Joe Hendrix
2feebceddc
Refactor relocation support; support .rel and some object symbols. 2018-04-05 09:06:12 -07:00
Tristan Ravitch
4bd307e41d x86: Have the x86 backend emit the ArchState metadata statment
This statement will be used for architecture-independent analysis of macaw
(or possibly crucible) values in machine registers.
2018-03-30 10:35:47 -07:00
Joe Hendrix
a258cf7b2b
Update submodule 2018-03-29 17:43:33 -07:00
Joe Hendrix
9f49b7327a
Bump elf-edit 2018-03-29 16:40:26 -07:00
Joe Hendrix
265f61e206
Merge branch 'master' of github.com:GaloisInc/macaw 2018-03-29 16:30:29 -07:00
Joe Hendrix
16d975d81f
Update submodules 2018-03-29 15:34:57 -07:00
Joe Hendrix
007405db1d
Improve robustness of elf loader, and start trying to parse relocations in objects. 2018-03-29 15:21:31 -07:00
Tristan Ravitch
6152912518 x86: Improve the testing harness
The tests now check to make sure that no blocks end in a classification failure.
This exposed a problem where some simple cases (where the return address was
read from the stack) where we were getting classification failures.

It turns out that the problem was due to the code being PIE and loaded at a very
low address.  This made a number of small constants look like code pointers,
which threw off the abstract interpretation.

The fix is to load the test binaries at a large offset (0x400000 or so) to
reduce the likelihood of overlap.
2018-03-28 16:54:35 -07:00
Iavor Diatchki
777fad441d Make it build with the Haskell2010 option 2018-03-27 11:01:18 -07:00
Iavor Diatchki
37c951722d Merge branch 'master' of github.com:GaloisInc/macaw 2018-03-27 10:51:53 -07:00
Kevin Quick
789841f9fe
[x86] Constent use of language specification in cabal file.
Also updates the minimum cabal version.  This eliminates warnings
regarding this cabal file.
2018-03-27 10:41:18 -07:00
Kevin Quick
377c3d1a2b
Use architecture-specific identifyReturn in Discovery process.
Instead of inline analysis of whether the instruction pointer has been
updated to contain the ReturnAddr symbolic value, defer the
determination of the call return to the (previously defined but
unused) architecture-specific handling.  This allows architectures
like ARM that perform modifications on the values loaded to the
instruction pointer (e.g. clearing lower bits) to provide their own
recognition of a return operation.

Also modifies the signature of identifyReturn to return a Sequence of
statements to match the identifyCall type signature.

Replaces the previously unused identifyX86Return with the inline
detection of IP == ReturnAddr.
2018-03-27 10:35:55 -07:00
Iavor Diatchki
f54f0a13ba Add some support for unpack; no symbolic implementation yet. 2018-03-26 18:51:19 -07:00