This patch contains a simple prototype for Syringe, an LLVM based framework for behavior injection. The goal of this work is to allow developers to change how a program can behave at runtime by allowing them to dynamically change how targeted functions behave. We accomplish this by modifying a targeted function's body to make an indirect call through a runtime controlled implementation pointer, which can point to either the original function body or to an alternate function determined at compile time. This allows us to dynamically enable and disable different functionality as the program runs, without limiting the variety of new behaviors supported by our tool. We add new annotations to mark the targets for injection, and their alternate behaviors. Additionally, we support configuration through YAML files, to avoid changing existing source code. One nice aspect of our approach is that injection sites(targets for new behaviors), and injection payloads(the new behaviors) can exist in separate translation units, and have their interactions codified at link time. While Syringe is designed to be somewhat general, its main use case is for supporting out of production use for activities like dynamic fault injection.
See the RFC on CFE-dev for more information: http://lists.llvm.org/pipermail/cfe-dev/2018-September/059260.html