The static instrumentation of machine code, also known as binary rewriting, is a power technique, but suffers from high runtime overhead compared to compiler-level instrumentation. Recent research has shown that tools can achieve near-to-zero overhead when rewriting binaries (excluding the overhead from the application specific instrumentation). However, the users of binary rewriting tools often have difficulties in understanding why their instrumentation is slow and how to optimize their instrumentation. We are inspired by a traditional program optimization workflow, where one can profile the program execution to identify performance hot spots, modify the source code or apply suitable compiler optimizations, and even apply profile-guided optimization. We present profile-guided, Multi-Version Binary Rewriting to enable this optimization workflow for static binary instrumentation. Our new techniques include three components. First, we augment existing binary rewriting to support call path profiling; one can interactively view instrumentation costs and understand the calling contexts where the costs incur. Second, we present Versioned Structure Binary Editing, which is a general binary transformation technique. Third, we use call path profiles to guide the application of binary transformation. We apply our new techniques to shadow stack and basic block code coverage. Our instrumentation optimization workflow helps us identify several opportunities with regard to code transformation and instrumentation data layout. Our evaluation on SPEC CPU 2017 shows that the geometric overhead of shadow stack and block coverage is reduced from 7.6% and 161.3% to 1.4% and 4.0%, respectively. We also achieve promising results on Apache HTTP Server, where the shadow stack overhead is reduced from about 20% to 3.5%.
翻译:机器代码的静态仪表工具(又称二进制重写)是一种电动技术,但与编译器仪器相比,其运行时间管理管理费用高,但与编译器仪器相比,它受到高运行时间管理管理费用的影响。最近的研究显示,当重写二进制工具(不包括应用程序专用仪表的间接费用)时,工具可以达到近至零管理费用。然而,二进制重写工具的用户往往难以理解为什么其仪表工作缓慢,以及如何优化其仪表工作。我们受到传统的程序优化工作流程的启发,在这个流程中,我们可以描述程序执行过程以确定性能热点,修改源代码或应用适当的编译器优化,甚至应用配置制式调整程序。我们展示了配置制导的多动版,多动版版重写了用于静态二进制书仪表的流程流程。首先,我们增加了现有的二进制书写方法,可以查看仪表成本所在的调控件环境。第二,我们展示了版本结构Binary编辑,这是一个普通的二进制转换技术。第三,我们用路图图图,我们分别指导了Storical Stil 和Sloveill Servidudustration 。我们用了一些的版本的版本,我们用了几个的版本的版本的版本的版本,我们用了一些系统化的版本的版本的版本,我们用了一些版本的版本的版本的版本的版本的版本和版本,我们的工具,我们用了制的版本的版本。