NeurIPS 2026Coming to NeurIPS in Sydney?Explore papers, orals & directions

SLaDe: A Portable Small Language Model Decompiler for Optimized Assembly

Jordi Armengol-Estapé, Jackson Woodruff, Chris Cummins, Michael F. P. O'Boyle

TL;DR

This paper introduces SLaDe, a novel small language model decompiler that achieves state-of-the-art accuracy and readability for optimized assembly code across different architectures (x86 and ARM). By combining a Transformer model with a type inference engine and training on real-world code, SLaDe significantly outperforms existing decompilers, including Ghidra and ChatGPT.

What Problem Does This Paper Address?

Decompilation, the process of converting low-level assembly code back into human-readable source code, is crucial for tasks like legacy code porting and security analysis. However, existing decompilers face significant challenges:

  • Readability: Traditional, rule-based decompilers (like Ghidra) produce code that is often verbose, difficult to understand, and bears little resemblance to the original source.
  • Accuracy: While neural approaches promise better readability, they have historically struggled with generating correct code, often relying on synthetic data and failing to handle real-world complexities like optimizations.
  • Portability: Most decompilers are architecture-specific and require substantial engineering effort to support new Instruction Set Architectures (ISAs) or optimization levels.
  • Type Inference: A major limitation of current tools is their inability to infer variable and function types, often requiring manual programmer intervention.

This paper aims to bridge this gap by developing a decompiler that is accurate, readable, portable across ISAs and optimization levels, and capable of handling type inference.

Methods

SLaDe employs a novel approach that combines a Small Language Model (SLM), specifically a Transformer-based sequence-to-sequence model, with a type inference engine.

  • Transformer Model: SLaDe uses a 200M-parameter Transformer trained on pairs of assembly and C code. It features a custom tokenizer designed for code, dropout-free regularization, and is trained on real-world, optimized assembly.
  • Type Inference: A key innovation is the integration of a type inference engine (PsycheC). Since the Transformer model might generate code with undefined types (especially for external functions or non-standard types), PsycheC analyzes the generated code and infers the necessary types to make it compilable.
  • Training Data: The model is trained on a large dataset derived from AnghaBench and ExeBench, comprising approximately 4 million function pairs. This real-world code is crucial for achieving portability and handling optimizations.
  • Inference: During inference, SLaDe generates a C code hypothesis, which is then passed to the type inference engine. The resulting compilable code is then validated using input/output (IO) examples.

Datasets

  • Training: The model is trained on an expanded version of the AnghaBench dataset, combined with function-level assembly from ExeBench, totaling around 4 million function pairs.
  • Evaluation: SLaDe is evaluated on two benchmark suites:
  • ExeBench: A large-scale dataset of approximately 4,000 functions, used to evaluate performance across different ISAs (x86, ARM) and optimization levels (-O0, -O3).
  • Synth Benchmarks: A smaller set of benchmarks used for detailed analysis and to evaluate performance on simpler code structures.

The paper emphasizes that the evaluation benchmarks were not present in the training set, ensuring a fair assessment of generalization capabilities.

Key Insights and Ideas

  • Portability is Achievable: SLaDe demonstrates that a single neural model can be trained to decompile code across different ISAs (x86 and ARM) and optimization levels with minimal engineering effort, a significant advantage over traditional decompilers.
  • Type Inference is Crucial for Accuracy: The integration of a type inference engine is vital. It allows SLaDe to produce code that is not only readable but also compilable and executable, addressing a major weakness of previous neural decompilers.
  • Real-World Data Matters: Training on real-world, optimized assembly code, rather than synthetic programs, is key to SLaDe's superior performance and generalization capabilities.
  • Small Models Can Be Powerful: Despite being a "small" language model (200M parameters), SLaDe outperforms much larger models like ChatGPT on this specific task, highlighting the importance of task-specific training and architecture.

Key Results

SLaDe demonstrates significant improvements over existing methods:

  • Accuracy:
    • Up to 6x more accurate than Ghidra on ExeBench (x86, -O3).
  • Up to 4.2x more accurate than ChatGPT on ExeBench (x86, -O3).
  • On ARM, SLaDe is more than 2x as accurate on -O0 and more than 6x more accurate at -O3 compared to Ghidra.
  • Readability (Edit Similarity):
    • Generates code with 1.65x to 3.68x higher edit similarity to the original source than Ghidra.
  • Generates code with 1.07x to 3.83x higher edit similarity than ChatGPT.
  • Impact of Type Inference: On average, the type inference algorithm improves SLaDe's performance by 14%, enabling more decompiled examples to compile.
  • Optimization Impact: While optimizations generally degrade performance for all methods, SLaDe shows a less severe decline compared to Ghidra and ChatGPT.

Limitations and Future Work

  • Limitations:
    • SLaDe's failures are often due to incorrectly predicting arguments for externally declared functions or mistyping variables (e.g., mistaking float for matrix variables).
  • The IO evaluation requires executing potentially unsafe code, necessitating a sandbox environment.
  • The performance of neural schemes can be sensitive to the distribution of training examples, showing a steeper decline than Ghidra with increasing assembly length.
  • Future Work:
    • Increase the scope of decompilation to larger program units.
  • Explore the use of pre-training and program repair techniques to further improve accuracy.
  • Investigate hybrid approaches that integrate learnable (neural) and analytic (rule-based) methods, particularly for type inference.

Summary updated

BibTeX
@inproceedings{armengolestape2024slade,
  author = {Jordi Armengol-Estapé and Jackson Woodruff and Chris Cummins and Michael F. P. O'Boyle},
  title = {{SLaDe: A Portable Small Language Model Decompiler for Optimized Assembly}},
  booktitle = {Cgo},
  year = {2024},
  doi = {10.1109/cgo57630.2024.10444788},
}
Figure