Abstract
Decompilation aims to recover the source code form of a binary executable, a critical task for malware analysis, vulnerability detection, and code reuse. A prominent challenge is recovering meaningful variable names from stripped binaries. We propose a novel method, GENNM, which leverages the synergy of large language models (LLMs) and program analysis. While LLMs encode rich knowledge, their limited input size often precludes sufficient global context. Our approach divides the task into multiple LLM queries and uses program analysis to correlate and propagate results. Evaluation shows that 75% of recovered names are considered good by users, and our technique outperforms state-of-the-art methods by 16.5% in precision and 20.23% in recall.
Introduction: The Challenge of Stripped Binaries
When software is compiled, human-readable metadata like variable names are typically removed to save space or protect intellectual property. This "stripping" process creates a significant barrier for reverse engineers. Traditional machine learning approaches treat variable renaming as a classification task, selecting names from a fixed vocabulary. However, this leads to three primary issues: a "closed vocabulary" that cannot generate new names, a "long-tail bias" favoring generic terms (e.g., buffer or ptr), and "local blindness" where the model lacks context from the broader program's call graph.
Methodology: From Classification to Generation
The GENNM framework shifts the paradigm from classification to generation using a sequence-to-sequence architecture based on models like CodeGemma and CodeLlama. This allows the model to compose descriptive names from sub-word tokens rather than picking from a static list.
Symbol Preference Optimization (SymPO)
To address the long-tail bias, we introduced Symbol Preference Optimization (SymPO). Inspired by alignment techniques like Direct Preference Optimization (DPO), SymPO explicitly trains the model to prefer specific, descriptive names over generic ones. For instance, if a model predicts buffer where the ground truth is packet, SymPO adjusts weights to favor the more precise term in that specific context.
Context-Aware Propagation
GENNM employs iterative inference and validation. It predicts names for a function, propagates those names across the call graph, and uses a data-flow-based validation algorithm. This mimics the workflow of human experts who use function calls and interactions—such as seeing a variable passed to send_packet()—to deduce its purpose.
Key Insights: The Power of Context and Preference
A core finding is that human developers combine common concepts into unique names. Generative models excel at this by assembling names from frequent sub-tokens. Furthermore, global context is vital; a variable's role often becomes clear only when viewed through its interaction with other functions in the "neighborhood."
Evaluation and Results
GENNM was tested against the DIRTY and VarCorpus benchmarks, using string similarity to ensure honest measures of generalization. Key findings include:
- Superior Precision: GENNM outperforms previous leaders like VarBERT and ReSym by 5.6 to 11.4 percentage points.
- Handling Unseen Data: In predicting names never seen during training, GENNM achieved a 168% improvement in precision compared to baselines (jumping from 8.5% to 22.8%).
- Efficiency vs. Scale: Specialized fine-tuning allowed GENNM (2B or 7B parameters) to outperform massive models like GPT-4 by 11.3 points, proving that domain-specific training beats raw model size for decompilation tasks.
Conclusion and Future Work
While GENNM significantly advances variable name recovery, challenges remain with highly optimized binaries (-O2, -O3) which obscure code structure. Future research will focus on deeper semantic understanding of complex data structures and improving robustness across diverse compiler optimization levels.
Summary updated