Commit Graph

194 Commits

Author SHA1 Message Date
Tristan Ravitch
bbd00f7ef2 [ppc] Add division and a few arch-specific statements
The arch-specific statements are for memory synchronization
2017-11-10 14:48:35 -08:00
Tristan Ravitch
48dfa4d192 Remove an accidentally-committed binary file 2017-11-10 08:18:16 -08:00
Tristan Ravitch
c990077d7b Update the semmc submodule
This update includes many more semantics files covering most of the dotted
instruction variants
2017-11-09 23:31:13 -08:00
Tristan Ravitch
9d750c944a Add a new type of test to PowerPC
It runs code discovery over a large-ish binary to test coverage.  We currently
fail due to unsupported instructions (expected).  This test will guide
priorities on implementing new semantics.
2017-11-09 17:18:20 -08:00
Tristan Ravitch
fc1bd8b077 Add support for more instructions
semmc has semantics for many new instructions.  We also added support for
translating the count leading zero functions.
2017-11-09 17:17:51 -08:00
Tristan Ravitch
6ede8a2511 Add some more detail on the instruction semantics writeup 2017-11-09 15:37:05 -08:00
Tristan Ravitch
d5d1d87fd5 Split some shared helpers out of a test module 2017-11-09 10:43:41 -08:00
Tristan Ravitch
1f9ba647cf Add some documentation on adding instruction semantics 2017-11-09 09:56:17 -08:00
Tristan Ravitch
9b9e1654ec Update the submodules to add more semantics
This focuses on the rotate instructions
2017-11-08 15:47:01 -08:00
Tristan Ravitch
e307c9a82a Add a comment in the test suite 2017-11-08 15:46:40 -08:00
Tristan Ravitch
5e150c15a0 Update to the latest semmc
This includes some new semantics required for the test suite
2017-11-08 10:59:43 -08:00
Tristan Ravitch
e5d20c6acf Fix an expected test output
It looks like I counted the bytes wrong the first time
2017-11-08 10:56:13 -08:00
Tristan Ravitch
b9835b9767 Cleanup and documentation pass 2017-11-07 22:46:06 -08:00
Tristan Ravitch
599a357515 Don't export curPPCState 2017-11-07 21:45:04 -08:00
Tristan Ravitch
a03953ecdc Delete some obsolete comments 2017-11-07 21:36:25 -08:00
Tristan Ravitch
6308df3a8f Add a helper to set register values
This helper additionally simplifies constants.  This is very useful for dealing
with simplifying the instruction pointer.  That is required by the rest of
macaw, which expects IP values it wants to explore to be fully reduced.
2017-11-07 21:16:00 -08:00
Tristan Ravitch
71a432ed18 Improve the test suite
Don't just ensure that found blocks are expected: also ensure that all expected
blocks are found.
2017-11-07 20:50:33 -08:00
Tristan Ravitch
c3d0ede125 Import alignment 2017-11-07 20:29:41 -08:00
Tristan Ravitch
65bc1231fb Implement 'identifyCall' for PowerPC
The current heuristic isn't great, but is probably okay for now.  It just checks
to see if the LNK register is an address plus four.  Something more precise
would require knowing the address of the next instruction, but we can't get that
from the IP, which has already been changed due to the call.
2017-11-07 20:23:11 -08:00
Tristan Ravitch
a648a4c50b Improve the formatting for test failures
Now print addresses as hex values
2017-11-07 20:22:49 -08:00
Tristan Ravitch
fed8e00482 [ppc] Fix the offsets in the call test 2017-11-07 20:22:32 -08:00
Tristan Ravitch
f126dbf5fa Add a (currently failing) test for calls 2017-11-07 17:49:53 -08:00
Tristan Ravitch
48ba00870d Add some extra tracing to 'identifyFunction' 2017-11-07 17:49:36 -08:00
Tristan Ravitch
65c940e334 Remove an unused function 2017-11-07 17:49:28 -08:00
Tristan Ravitch
fdcbbeae39 Fix a bug in register value handling
The semantics of each instruction are atomic updates over the register state.
Prior to this commit, changes were not atomic and updates to register values
were visible to later register definitions, which causes a huge number of
problems.  Now, we take a snapshot of the register state at the beginning of the
instruction and read all values we need from that snapshot.  This way, updates
are isolated from one another.
2017-11-07 17:45:00 -08:00
Tristan Ravitch
fc48993507 Update an expected test result
My understanding of how macaw splits up blocks was incorrect when I wrote the
test initially.  Macaw doesn't split blocks just because a jump happens to land
in the middle of the block, so the middle block in this example is actually a
few instructions longer.
2017-11-07 14:32:51 -08:00
Tristan Ravitch
81fbec6bb9 Improve the layout of the frontier calculation 2017-11-07 13:45:40 -08:00
Tristan Ravitch
a4cbd3a9d0 Make the simplifier more powerful
It now recursively traverses its arguments.  This isn't great from an efficiency
perspective, but we need it to be able to simplify instruction pointers computed
from relative jumps (which involve some sign extensions and shifts).
2017-11-07 13:44:41 -08:00
Tristan Ravitch
0b43f5672e Have 'matchConditionalBranch' simplify the values it returns
These values are new values of the IP to explore, and the code consuming these
values expects them to be BV literals (i.e., simplified from expressions to
values).

The simplifier isn't currently powerful enough to simplify everything we throw
at it, but this is at least the right place to apply it.  If we don't simplify
here, the core of macaw won't know how to follow the IP changes and will miss
blocks.
2017-11-07 11:36:50 -08:00
Tristan Ravitch
32d37e1a31 Delete an obsolete comment 2017-11-07 11:36:36 -08:00
Tristan Ravitch
ec9695d29b Fix the initial PreBlock state w.r.t. block ids
We were initializing the next PreBlock ID as 0, which caused that block id to be
reused later (the initial block is given ID 0)
2017-11-07 11:28:01 -08:00
Tristan Ravitch
e405e23b93 Fix a bug where we were generating macaw bitvector literals with negative integer components
Apparently this is not allowed, and caused an assertion failure in a pretty printer.
2017-11-07 11:24:57 -08:00
Tristan Ravitch
008c422917 Update to the latest semmc
This includes semantics for generalized branch conditional
2017-11-06 22:25:12 -08:00
Tristan Ravitch
48bfd87165 Add a missing register (XER) to the macaw register state 2017-11-06 19:44:19 -08:00
Tristan Ravitch
fcb694ccb9 Add a test for conditional branches
It doesn't pass yet.  It is hung up on an unsupported register type (Crrc, used
in a compare).
2017-11-06 17:19:16 -08:00
Tristan Ravitch
11a754b3ed Add support for conditional branches 2017-11-06 17:18:59 -08:00
Tristan Ravitch
8db18882fa Factor out the implementations of some of the TH translations
These operations generate a lot of code, so it is helpful to factor them out and
reduce the burden on the type checker.  Factoring these two definitions out cuts
the generated code nearly in half.
2017-11-06 15:43:32 -08:00
Tristan Ravitch
6a45dc0893 [ppc] Fix an issue with floating point translation
The change is actually in the semantics (semmc), where we were extracting the
wrong part of the 128 bit vector registers to operate on.  Many operations were
being simplified to zero, which manifest as unused fprc registers.
2017-11-06 14:25:54 -08:00
Tristan Ravitch
15078b2bde Remove more unused imports 2017-11-06 10:22:16 -08:00
Tristan Ravitch
4e1db21b08 Remove another piece of commented-out code 2017-11-06 10:15:18 -08:00
Tristan Ravitch
15b3ba466d Remove some unused imports 2017-11-06 10:14:33 -08:00
Tristan Ravitch
e2e3744808 Remove an unused value 2017-11-06 10:13:49 -08:00
Tristan Ravitch
0ed78396cf Remove some obsolete commented-out code 2017-11-06 10:13:06 -08:00
Tristan Ravitch
a9baec5d39 Port to the latest macaw
This makes the architecture-specific terminator statement handling actually work
2017-11-06 10:11:34 -08:00
Tristan Ravitch
5e47bf6ce9 Improve the PPC test suite
It now checks to ensure that expected blocks are actually the expected number of bytes
2017-11-05 20:51:57 -08:00
Tristan Ravitch
0c81c13570 Remove an unused simplifier 2017-11-05 20:19:37 -08:00
Tristan Ravitch
b726a5ab7c Add semantics for TRAP (no arguments) 2017-11-04 23:00:28 -07:00
Tristan Ravitch
17d00036f1 Fix a bug with the syscall instruction semantics
The previous implementation missed an IP update, which is required to prevent
macaw from treating the syscall instruction as its own basic block.  Also factor
out the implementation of SC so that we can re-use it later for TW.
2017-11-04 22:42:01 -07:00
Tristan Ravitch
e765345a7b Add support for the Syscall arch-specific terminator 2017-11-04 16:23:12 -07:00
Tristan Ravitch
eaaa4abce7 Switch to a ContT-based PPCGenerator monad
This is required to support both block splitting and early returns due to other
block terminators.
2017-11-04 13:38:57 -07:00