$ show unicorn-engine/unicorn
Unicorn Engine is a lightweight, multi-architecture CPU emulation framework derived from QEMU. It provides a pure C API with bindings for Python, Go, Java, Rust, Ruby, .NET, Haskell, Pascal, Zig, and VB6. The engine supports ARM, ARM64, M68K, MIPS, PowerPC, RISC-V, S390X, SPARC, TriCore, and x86 (16/32/64-bit). It is used primarily for security research, reverse engineering, fuzzing, and dynamic analysis of binary code. The architecture is a library with a central C API that exposes memory mapping, register access, hooks (code, block, memory, interrupt, instruction, syscall, TLB), and context save/restore. The core emulation logic is based on QEMU's TCG (Tiny Code Generator) for dynamic binary translation, with a custom glib compatibility layer to eliminate external dependencies. The repository includes extensive regression tests, fuzz targets, and sample programs for each architecture and binding. While the engine is actively maintained and widely used, it carries technical debt from its QEMU fork (based on QEMU 5.0.1) and auto-generated binding constants that may drift from the C API.
The LLM identified 5 files worth highlighting for reuse:
A standalone, self-contained implementation of GLib-compatible data structures (hash tables, lists, trees, arrays, memory allocation, test utilities) that eliminates the need for the GLib library. It is used throughout the Unicorn engine and can be extracted for any C project requiring lightweight, portable versions of these common data structures.
A generic intrusive doubly-linked list implementation with insert, append, remove, exists, and optional delete callback. It is minimal, header-only, and can be reused in any C project for efficient list management without dynamic allocation.
A scalable, read-optimized, lock-free hash table designed for translation block lookup in QEMU/Unicorn. It supports concurrent readers and writers with RCU semantics, and can be extracted for use in other high-performance, read-heavy workloads.
A portable, architecture-aware floating-point emulation library supporting half, single, double, quad, and x87 extended precision formats. It handles NaN propagation, rounding modes, and exception flags, and is used by QEMU and Unicorn for accurate floating-point instruction emulation. It can be reused in any project requiring software floating-point.
A Python script that auto-generates architecture-specific constant files (register enums, instruction IDs, etc.) for all language bindings (Go, Java, Ruby, .NET, Pascal, Zig) from the C header definitions. It ensures consistency across bindings and can be adapted for any project that needs to maintain synchronized constants across multiple languages.