import-trace: introduce RandomJumpImporter

The random jump importer defines trace events, that indicate all
possible jumps into a specific instruction range. The region where
jumps should start can be defined by a memory map given with
--jump-from. For each instruction declared in that memory range, all
possible jumps to a memory region specified by with --jump-to are
inserted. The target of the jump is saved in the data_address
field. So all database tools work as expected.

for each event E \in region(--jump-from):
    foreach Instruction in region(--jump-to):
         insert_trace(injection_instr = E.IP(), data_address = Instruction.addr)

Change-Id: Ie163968acae47fc6c946fc77774c47ee07950bab
This commit is contained in:
Christian Dietrich
2013-07-04 13:39:02 +02:00
parent f47d50b182
commit 6c9bb21ab3
4 changed files with 191 additions and 0 deletions

View File

@ -11,6 +11,7 @@
#ifdef BUILD_LLVM_DISASSEMBLER
#include "InstructionImporter.hpp"
#include "RegisterImporter.hpp"
#include "RandomJumpImporter.hpp"
#endif
@ -127,9 +128,14 @@ int main(int argc, char *argv[]) {
} else if (imp == "InstructionImporter" || imp == "code") {
LOG << "Using InstructionImporter" << endl;
importer = new InstructionImporter();
} else if (imp == "RegisterImporter" || imp == "regs") {
LOG << "Using RegisterImporter" << endl;
importer = new RegisterImporter();
} else if (imp == "RandomJumpImporter") {
LOG << "Using RandomJumpImporter" << endl;
importer = new RandomJumpImporter();
#endif
} else {
LOG << "Unkown import method: " << imp << endl;
@ -141,7 +147,16 @@ int main(int argc, char *argv[]) {
importer = new MemoryImporter();
}
if (importer && !(importer->cb_commandline_init())) {
std::cerr << "Cannot call importers command line initialization!" << std::endl;
exit(-1);
}
if (cmd[HELP]) {
// Since the importer might have added command line options,
// we need to reparse all arguments in order to prevent a
// segfault within optionparser
cmd.parse();
cmd.printUsage();
exit(0);
}