Introduction
Decompilation—the process of transforming binary executables back into human-readable source code—is a cornerstone of reverse engineering, security auditing, and legacy software maintenance. However, it remains a notoriously difficult "lossy" process. Compilation typically strips away variable names, comments, and high-level logical structures, often replacing them with optimized assembly that bears little resemblance to the original source.
Traditional decompilers like Hex-Rays or RetDec rely on manually defined, brittle rules to map assembly back to high-level code. These systems suffer from high engineering overhead and often produce "spaghetti code" that is functionally correct but semantically opaque. In "A Neural-based Program Decompiler," Fu et al. introduce Coda, a framework that treats decompilation as a structured machine translation task, leveraging a two-stage neural architecture to recover both program functionality and semantics.
The Coda Architecture
Coda moves beyond standard Sequence-to-Sequence (Seq2Seq) models by incorporating structural priors of programming languages. The framework operates in two distinct phases: code sketch generation and iterative error correction.
Phase 1: Code Sketch Generation
Instead of treating assembly and source code as flat text, Coda utilizes an instruction-type aware encoder. This component employs specialized Recurrent Neural Networks (RNNs) for different instruction categories (e.g., memory, arithmetic, branch), allowing the model to capture the specific semantics of various operations.
The decoder is similarly specialized; rather than generating tokens linearly, it produces an Abstract Syntax Tree (AST). This structural constraint ensures that the generated "sketch" adheres to the formal grammar of the target high-level language. An attention mechanism further assists by allowing the decoder to "look back" at relevant assembly instructions and parent AST nodes during the generation process.
Phase 2: Iterative Error Correction
Neural models occasionally introduce logical "typos." To address this, Coda implements a Neural Error Predictor (EP). When a generated sketch fails to match the target behavior, the EP identifies potential errors. Coda then employs a "compiler-in-the-loop" strategy: it generates candidate fixes, compiles them, and compares the resulting binary to the original using Levenshtein edit distance. If a fix reduces this distance, it is accepted, and the process iterates until the code is functionally identical to the original.
Experimental Evaluation
The authors evaluated Coda across several benchmarks, including Karel (control flow), Math (data dependency), and Normal Expressions (expression reconstruction). The model was trained on 50,000 pairs of high-level programs and their corresponding MIPS and x86-64 assembly.
As shown in the results, Coda (represented by the Inst2AST+Attn configuration) achieves near-perfect accuracy on many benchmarks, vastly outperforming standard Seq2Seq models which often struggle to exceed 12% accuracy on complex tasks. On real-world benchmarks like the PyTorch C++ API and Hacker’s Delight, Coda achieved 100% accuracy, demonstrating its ability to handle human-written logic.
Conclusion
Coda represents a paradigm shift in decompilation. By combining the flexibility of neural networks with the rigid verification of traditional compilers, it achieves an average program recovery accuracy of 82%. Furthermore, the model is remarkably efficient; at approximately 10MB, it is 500 times smaller than traditional toolkits like RetDec. While challenges remain in scaling to large binaries and complex pointer structures, Coda provides a scalable, architecture-agnostic path forward for making binary code transparent and auditable.
Summary updated