Files
lifting-bits-remill/remill/CFG/BlockHasher.cpp
T
Peter Goodman 7dd87902ea Vmill (#106)
* Initial commit of x86 program snapshotter. Haven't yet figured out how to save a core dump to a specific file.

Now finds and saves core dumps (in a sketchy way).

Kind of but didn't really fix remill-disass with core dumps. It almost seems like a bunch of stuff is missing from within a core dump. It may be the case that it will be simpler to use binary ninja directly on snapshot files.

Working toward the executor.

Have snapshot creation and loading working. Next up: decoding the first few instructions!

Starting to serverize remill and setting up lines of communicating between vmill and remill. Going to move on to finally implementing remill-opt.

Changed a bazillon things.

Fixed the dead register backward data-flow analysis.

Fixed soem bugs, added GEP re-association, working toward inserting stores that will kill values.

Got interprocedual dead store elimination working! :-D

Finally...dead store elimination

remill-opt is done.

Added Lifter interface

Spec'ing out the translation engine.

Got the dynamic decoder working!

Got bitcode caching working

Added caching layer for bytecode compilation.

Decided on how to access reg state and allocas in functions. The bytecode will treat the state struct and the alloca'd data as a contiguous, opaque, byte-addressible area.

Compiler seems to work

Refactor

Great progress...goodnight

Made it up to the first syscall

Fixed call to a hypercall intrinsics

Bug fixes, minor change to the CFG proto.

Refacotorings and changes

* Switching to trying nativeexec, and made memory32 map snapshot into low 32-bits of address space, preserving original addresses of program.

* About to make some interesting changes, so save save save

* Refactor done, now time to produce shared libraries

* Got initial execution of some stuff in PHP working.. it either seems like the code is in an infinite loop, or just horribly slow, not sure. Otherwise, amazing progress.

* Got initial compiling to a runtime dynamic library working

* Separated most DEF_ISEL_SEMs and tests still pass. Goodnight!

* Got incremental optimization and compilation working.

* Got caching of the bitcode file to disk working and periodically collapsing the shared libraries into a single library. OUT.

* Fixed some bugs

* Commit before the storm

* Made the JIT work again, still not that fast though.

* Minor logging fix

* Log an error that we're executing a missing instruction.

* JIT compile the whole module first, then incrementally JIT compile function partitions. Also, link in libm.

* Added new syscall

* Added breakpoint sync hypercall, useful for testing.

* Got a php5.4 unserialize bug to reproduce. Added remill-pinshot, which will use PIN to take a snapshot and print out a register trace. This is useful for debugging divergences. Fixed up the semantics of some instructions, and added semantics and tests for PSRLDQ.

* Simplifications to remill that removes all the various basic block arrays, and uses meta-data instead.

* Made cmake take over the test system

* Working on mega refactor to eventually permit klee support

* Made all semantics code return memory pointer; I think this makes LLVM's optimizer a bit happier. Made the __remill_sub_N things into global constants, referencing the actual functions, that have private linkage. Slowly getting back in the direction of execution. I've got some bitcode translation working (with a hard-coded address for my local php version). The address space stuff seems to work so far.

* Missing files.

* Other minor fixes

* rtti-related fixes for gtest

* minor travis config change

* minor travis config change

* sendfile no longer needed

* Disable building vmill on non-linux platforms

* Disable 32-bit test builds on macOS.

* Trying to get symbol names on mac right.

* Minor fix to save state code for tests, disable testing on macOS builds because of symbol mismatches in gtest.

* Fixup remill-disass to use the simplified proto structure. Something may be wrong with remill-opt, or installing remill opt. Remove caching from travis.
2017-03-23 15:49:33 -04:00

30 lines
783 B
C++

/* Copyright 2017 Peter Goodman (peter@trailofbits.com), all rights reserved. */
#include "remill/CFG/BlockHasher.h"
#include "remill/CFG/CFG.h"
#include "third_party/murmurhash/MurmurHash2.h"
namespace remill {
BlockHasher::BlockHasher(void)
: BlockHasher(0) {}
BlockHasher::BlockHasher(uint64_t seed_)
: seed(seed_) {}
uint64_t BlockHasher::HashBlock(const cfg::Block &block) const {
std::string data;
for (const auto &inst : block.instructions()) {
auto pc = inst.address();
auto pc_ptr = reinterpret_cast<char *>(&pc);
auto &bytes = inst.bytes();
data.insert(data.end(), pc_ptr, pc_ptr + sizeof(pc));
data.insert(data.end(), bytes.begin(), bytes.end());
}
return MurmurHash64A(data.data(), data.size(), seed);
}
} // namespace remill