aengelke / instrew

A high performance LLVM-based dynamic binary instrumentation framework
GNU Lesser General Public License v2.1
239 stars 38 forks source link

Instrew — LLVM-based Dynamic Binary Translation

builds.sr.ht status

Instrew is a performance-targeted transparent dynamic binary translator(/instrumenter) based on LLVM. Currently supported source/guest architectures are x86-64, AArch64, and RISC-V64 (rv64imafdc); supported host architectures are x86-64 and AArch64. The original code is lifted to LLVM-IR using Rellume, where it can be modified and from which new machine code is generated using LLVM's JIT compiler.

Using Instrew

After cloning and checking out submodules, compile Instrew as follows:

mkdir build
meson build -Dbuildtype=release
ninja -C build
# optionally, run tests
ninja -C build test

Afterwards, you can run an application with Instrew. Statically linked applications often have a significantly lower translation time. New glibc versions often tend to use recent syscalls that are not yet supported, therefore warnings about missing system calls can sometimes be ignored.

./build/server/instrew /bin/ls -l

You can also use some options to customize the translation:

Example:

./build/server/instrew -profile -targetopt=0 /bin/ls -l

Architecture

Instrew implements a two-process client/server architecture: the light-weight client contains the guest address space as well as the code cache and controls execution, querying rewritten objects as necessary from the server. The server performs lifting (requesting instruction bytes from the client when required), instrumentation, and code generation and sends back an ELF object file. When receiving a new object file, the client resolves missing symbols and applies relocations.

Publications

License

Instrew is licensed under LGPLv2.1+.