GithubHelp home page GithubHelp logo

00mjk / drob Goto Github PK

View Code? Open in Web Editor NEW

This project forked from davidhildenbrand/drob

0.0 0.0 0.0 1.17 MB

DROB (Dynamic Rewriter and Optimizer of Binary code)

License: GNU Lesser General Public License v3.0

Makefile 0.63% C++ 93.32% C 5.67% Meson 0.39%

drob's Introduction

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:

  • Simple loop unrolling (single-superblock loops)
  • Block layout optimizations
  • Dead code elimination
  • Dead register write elimination
  • Memory operand address optimizations
  • Instruction specialization

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.

  • Only x86-64 is supported
  • Only the System V AMD64 ABI for x86-64 (a.k.a. Linux) is supported.
  • Privileged instructions and registers are not supported.
  • Self-modifying code is not supported.
  • Exceptions and signals are not supported.
  • ROP and non-local branches are not supported.
  • ICFG reconstruction is kept very simple (e.g. indirect branches or calls like in jump tables cannot be resolved, however such code can be partially rewritten).
  • Functions that do crazy things with the stack pointer are not supported.

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

  • Intel AVX instructions including VEX prefixes
  • Intel MMX instructions
  • Legacy x87 FPU instructions including registers
  • LOCK, REPNE, REP and segment override prefixes.
  • Segmentation.
  • Advanced instructions like the INT instruction
  • Advanced features like Intel MPX.

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 [email protected]

drob's People

Contributors

davidhildenbrand avatar aengelke avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.