Skip to main content
QUICK REVIEW

[Paper Review] Augmenting Decompiler Output with Learned Variable Names and Types

Qibin Chen, Jeremy Lacomis|arXiv (Cornell University)|Aug 13, 2021
Software Engineering ResearchComputer Science57 references11 citations
TL;DR

This paper introduces DIRTY, a deep learning approach that enhances decompiler output by automatically predicting meaningful variable names and types using statistical modeling of human-written C code. Trained on a large GitHub dataset, DIRTY achieves 66.4% accuracy in recovering original variable names and 75.8% for original types, significantly outperforming prior methods by leveraging contextual patterns in code structure and naming conventions.

ABSTRACT

A common tool used by security professionals for reverse-engineering binaries found in the wild is the decompiler. A decompiler attempts to reverse compilation, transforming a binary to a higher-level language such as C. High-level languages ease reasoning about programs by providing useful abstractions such as loops, typed variables, and comments, but these abstractions are lost during compilation. Decompilers are able to deterministically reconstruct structural properties of code, but comments, variable names, and custom variable types are technically impossible to recover. In this paper we present DIRTY (DecompIled variable ReTYper), a novel technique for improving the quality of decompiler output that automatically generates meaningful variable names and types. Empirical evaluation on a novel dataset of C code mined from GitHub shows that DIRTY outperforms prior work approaches by a sizable margin, recovering the original names written by developers 66.4% of the time and the original types 75.8% of the time.

Motivation & Objective

  • To address the lack of meaningful variable names and types in decompiler output, which hinders reverse engineering and program comprehension.
  • To recover lost high-level abstractions—specifically variable names and types—by modeling patterns in human-written C code.
  • To improve the readability and understandability of decompiled binaries by generating semantically meaningful identifiers and type annotations.
  • To overcome the limitations of deterministic decompilation, which cannot recover original names or custom types due to information loss during compilation.
  • To evaluate the effectiveness of learned naming and typing on a novel, large-scale dataset of real-world C programs from GitHub.

Proposed method

  • DIRTY uses a transformer-based sequence-to-sequence model trained on a large-scale dataset of C code mined from GitHub to predict variable names and types from decompiled function text.
  • The model leverages contextual information from the surrounding code structure, including variable usage patterns, function signatures, and data layout, to infer likely names and types.
  • For type prediction, DIRTY considers memory layout constraints and uses a BPE (Byte Pair Encoding) tokenization strategy to handle out-of-vocabulary types, though preliminary experiments showed this reduced accuracy and increased inference time.
  • The approach models naming and typing patterns by learning from repetitive, contextually consistent naming conventions in real-world code, enabling generalization to unseen but structurally similar variables.
  • The model is fine-tuned on decompiled function text, where input is the decompiled C-like code and output is the predicted name and type for each variable.
  • To handle rare or unseen types, the method explores BPE-based decomposition of complex types, though this is noted as a trade-off between coverage and performance.

Experimental results

Research questions

  • RQ1Can learned models effectively recover original variable names from decompiled C code when no source is available?
  • RQ2To what extent can deep learning models infer correct variable types based on code context and memory layout?
  • RQ3How does the performance of DIRTY compare to prior state-of-the-art approaches in variable name and type recovery?
  • RQ4What impact does BPE-based tokenization have on predicting unseen or complex types in decompiled code?
  • RQ5Can DIRTY generalize to non-C programs when decompiled to C, and how well does it handle higher-level language constructs like C++ classes?

Key findings

  • DIRTY recovers the original variable names used by developers with 66.4% accuracy on a held-out test set of decompiled functions.
  • The model achieves 75.8% accuracy in recovering the original variable types, significantly outperforming prior approaches.
  • Empirical evaluation shows that DIRTY's performance is robust across diverse codebases, with strong generalization to unseen functions and variable patterns.
  • The use of BPE for type decomposition improved coverage of rare types but reduced overall prediction accuracy and increased inference time, suggesting trade-offs in design.
  • DIRTY demonstrates strong performance on C++-related types such as std::string, indicating partial support for higher-level language constructs when decompiled to C.
  • The model's effectiveness is limited by input length constraints, though only 8.8% of functions exceed the 512-token limit, suggesting minimal data loss in practice.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.