Modular Decompilation of Low-Level Code by Partial Evaluation

Decompiling low-level code to a high-level intermediate representation facilitates the development of analyzers, model checkers, etc. which reason about properties of the low-level code (e.g., bytecode, .NET). Interpretive decompilation consists in partially evaluating an interpreter for the low-level language (written in the high-level language) w.r.t. the code to be decompiled. There have been proofs-of-concept that interpretive decompilation is feasible, butt here remain important open issues when it comes to decompile a real language: does the approach scale up? is the quality of decompiled programs comparable to that obtained by ad-hoc decompilers? do decompiled programs preserve the structure of the original programs? This paper addresses these issues by presenting, to the best of our knowledge, the first modular scheme to enable interpretive decompilation of low-level code to a high-level representation, namely, we decompile bytecode into PROLOG. We introduce two notions of optimality. The first one requires that each method/block is decompiled just once. The second one requires that each program point is traversed at most once during decompilation. We demonstrate the impact of our modular approach and optimality issues on a series of realistic benchmarks. Decompilation times and decompiled program sizes are linear with the size of the input bytecode program. This demostrates empirically the scalability of modular decompilation of low-level code by partial evaluation.

[1]  Jürgen Giesl,et al.  Automated Termination Proofs with AProVE , 2004, RTA.

[2]  Elvira Albert,et al.  Verification of Java Bytecode Using Analysis and Transformation of Logic Programs , 2007, PADL.

[3]  John W. Lloyd,et al.  Partial Evaluation in Logic Programming , 1991, J. Log. Program..

[4]  Yoshihiko Futamura,et al.  Partial Evaluation of Computation Process--An Approach to a Compiler-Compiler , 1999, High. Order Symb. Comput..

[5]  Jorge A. Navas,et al.  A Flexible, (C)LP-Based Approach to the Analysis of Object-Oriented Programs , 2008, LOPSTR.

[6]  J. Lloyd Foundations of Logic Programming , 1984, Symbolic Computation.

[7]  John P. Gallagher,et al.  Analysis of Imperative Programs through Analysis of Constraint Logic Programs , 1998, SAS.

[8]  Manuel V. Hermenegildo,et al.  Efficient Local Unfolding with Ancestor Stacks for Full Prolog , 2004, LOPSTR.

[9]  Peter Sestoft,et al.  Partial evaluation and automatic program generation , 1993, Prentice Hall international series in computer science.

[10]  John P. Gallagher,et al.  Abstract Interpretation of PIC Programs through Logic Programming , 2006, 2006 Sixth IEEE International Workshop on Source Code Analysis and Manipulation.

[11]  Michael Leuschel,et al.  Supervising Offline Partial Evaluation of Logic Programs Using Online Techniques , 2006, LOPSTR.

[12]  K. Rustan M. Leino,et al.  BoogiePL: A typed procedural language for checking object-oriented programs , 2005 .

[13]  Wim Vanhoof,et al.  Specialising Interpreters Using Offline Partial Deduction , 2004, Program Development in Computational Logic.

[14]  Alfred V. Aho,et al.  Compilers: Principles, Techniques, and Tools , 1986, Addison-Wesley series in computer science / World student series edition.

[15]  Wim Vanhoof,et al.  Offline specialisation in Prolog using a hand-written compiler generator , 2002, Theory and Practice of Logic Programming.

[16]  John Launchbury,et al.  A natural semantics for lazy evaluation , 1993, POPL '93.

[17]  Akihiko Takano Y.Futamura : Partial Evaluation of Computation Process : An Approach to a Compiler-Compiler , 2002 .

[18]  Michael Leuschel,et al.  Homeomorphic Embedding for Online Termination of Symbolic Methods , 2002, The Essence of Computation.

[19]  John P. Gallagher,et al.  Non-leftmost Unfolding in Partial Evaluation of Logic Programs with Impure Predicates , 2005, LOPSTR.

[20]  Elvira Albert,et al.  Improving the Decompilation of Java Bytecode to Prolog by Partial Evaluation , 2007, Bytecode@ETAPS.

[21]  John P. Gallagher,et al.  Using regular approximations for generalisation during partial evalution , 1999, PEPM '00.

[22]  Laurie Hendren,et al.  Soot---a java optimization framework , 1999 .

[23]  John P. Gallagher,et al.  Tutorial on specialisation of logic programs , 1993, PEPM '93.

[24]  John P. Gallagher,et al.  Type-Based Homeomorphic Embedding and Its Applications to Online Partial Evaluation , 2008, LOPSTR.

[25]  Elvira Albert,et al.  Cost Analysis of Java Bytecode , 2007, ESOP.