Home

Awesome

Drob - Dynamic Rewriter and Optimizer of Binary code

This library implements application-guided rewriting of binary functions at runtime. Binary functions can be optimized and specialized based on runtime information. In contrast to transparent binary optimization, only selected binary functions are rewritten. No metadata (e.g. debug information) is required.

Drob is not designed to insert arbitrary new code (e.g., instrumentation) into existing binary code, rather to rewrite and optimize existing code by dropping or replacing instructions. Drob implements the following optimizations:

Internally, binary code is converted into an architecture-specific intermediate representation, on which analyses and optimizations are performed.

A rewritten function has the same signature as the original binary function. The same parameters have to be supplied when calling the rewritten binary function.

!!! PROTOTYPE QUALITY !!!

This library was created as a prototype in the context of a Master's thesis at the TUM (Technical University of Munich). Besides some tests and some benchmarks, it hasn't seen much testing. Especially, only a very small subset of the x86-64 ISA is modeled yet.

General Restrictions

The focus is on binary code generated by a compiler. For now only the entry function is analyzed and optimized. Called functions can be rewritten, but not optimized. Optimizing called functions can be supported in the future in many cases by inlining all non-recursive functions into the entry function.

x86-64 Restrictions

Driven by benchmarks and simple tests, only a subset of x86-64 instructions and features is supported in Drob. Besides basic instructions (MOV, ADD, XOR), support for some Intel SSE instructions has been added.

Not supported for now are

Instructions accessing global variables via RIP-relative addressing can under some conditions not be rewritten. Some unmodeled instructions can be rewritten, however prohibit optimizations.

License

LGPLv3+

Drob uses the Intel XED decoder on x86-64, release under the Apache License 2.0.

Copyright

David Hildenbrand davidhildenbrand@gmail.com