Introduction
Modern software is frequently characterized by "bloat," containing numerous features and execution paths that remain unused by the majority of users. This excess code not only consumes unnecessary storage and memory but also degrades performance and expands the security attack surface. Program specialization via partial evaluation offers a solution by pre-computing parts of a program based on known static inputs. However, applying these techniques to stripped binaries—executables lacking source code or symbolic information—presents a significant challenge. In such environments, the lack of high-level data abstractions forces the specializer to manage the entire machine state (stack, heap, and globals), which is traditionally computationally expensive and slow.
Methodology: GenXGen[MC]
The authors present GenXGen[MC], a novel "generating-extension-generator" designed to specialize machine code efficiently. Unlike traditional interpreters, GenXGen[MC] produces a program-specific specializer that executes natively. Its architecture relies on three key technical innovations:
OS-Assisted State Management
To handle the "state explosion" problem, GenXGen[MC] leverages the Linux fork() system call. By utilizing the operating system's Copy-on-Write (CoW) mechanism, the specializer can create nearly instantaneous snapshots of the program's memory state. Physical memory is only duplicated when a page is modified, allowing for efficient exploration of multiple execution paths without the overhead of manual memory copying.
Probabilistic State Hashing
Detecting previously visited states is critical for termination in partial evaluation. GenXGen[MC] employs Rabin fingerprinting to generate 128-bit hashes of the entire memory state. A key departure from traditional formal methods is the abandonment of collision resolution. With a 128-bit hash, the probability of a collision is approximately $2^{-56}$, which is considered negligible for practical applications. This allows for $O(1)$ state equality checks, drastically reducing the time complexity of state management.
Incremental Updates via Kernel Instrumentation
To further optimize performance, the system tracks memory modifications at the page level by instrumenting the kernel's page-fault handler. This allows the Rabin hash to be updated incrementally based only on changed pages during a basic block's execution, rather than re-scanning the entire address space.
Evaluation and Results
The system was evaluated using seven microbenchmarks (e.g., power, dotproduct, matcher) and three real-world command-line utilities (gnu-wc, gnu-env, and a printf client).
Performance Gains
The integration of Rabin fingerprinting yielded dramatic improvements in specialization speed. In one instance, a task that required 12 hours using traditional methods was completed in just 3 seconds. Furthermore, the specialized "residual" programs demonstrated significant runtime performance improvements. For example, the matcher utility (illustrated in Figure 2) achieved a 9x speedup, while the stack microbenchmark saw a 5,500x speedup by eliminating redundant memory operations.
Memory Efficiency
The use of CoW significantly reduced memory overhead. In the gnu-env benchmark, the actual memory overhead was reduced from a theoretical million pages to just two pages, demonstrating the effectiveness of OS-level optimizations in program analysis.
Conclusion and Future Work
GenXGen[MC] demonstrates that native execution combined with probabilistic state management can overcome the traditional bottlenecks of machine-code specialization. While the system currently relies on static analysis tools like CodeSurfer/x86—which can be limited by complex library calls—the underlying principles of OS-assisted CoW and Rabin fingerprinting provide a robust framework for future debloating efforts. Ongoing work includes extending these techniques to source-code specialization (GenXGen[C]) to handle memory-unsafe languages more effectively.
Summary updated