
AI-powered reverse-engineering of Rosetta (2 for Linux). Disclaimer: due to the user agreement, I will not touch the code. All is done by AI, so there might be messy implementation.
A comprehensive reverse-engineering effort to understand and document Apple's Rosetta 2 binary translation technology.
In November 2020, Apple announced their first Apple Silicon Macs, marking a historic transition from Intel x86_64 processors to their own ARM-based M1 chips. This was Apple's third major architecture transition:
Each transition required a binary translation solution to run existing software during the migration period. Rosetta 2 is Apple's most sophisticated binary translation system yet.
Rosetta (2006-2011) was Apple's first dynamic binary translation software, enabling PowerPC applications to run on Intel-based Macs.
Rosetta was removed in Mac OS X 10.7 (Lion), completing the Intel transition.
Rosetta 2 is Apple's advanced dynamic binary translation technology that enables applications compiled for Intel x86_64 Macs to run on Apple Silicon (ARM64) Macs.
┌─────────────────────────────────────────────────────────────┐
│ User Application (x86_64) │
├─────────────────────────────────────────────────────────────┤
│ Rosetta 2 Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Translator │ │ Runtime │ │ System Call │ │
│ │ (AOT/JIT) │ │ Library │ │ Translation │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ macOS Kernel (ARM64) │
├─────────────────────────────────────────────────────────────┤
│ Apple Silicon Hardware │
└─────────────────────────────────────────────────────────────┘
Ahead-of-Time (AOT) Translation
Just-in-Time (JIT) Translation
Instruction Set Translation
System Call Translation
Runtime Support
Rosetta 2 is located at:
/Library/Apple/usr/libexec/oah/
├── rosetta # Main translator binary
├── rosettad # Rosetta daemon
└── librosetta.* # Runtime libraries
The oah directory stands for "Old Architecture Hardware" - a continuation from the PowerPC transition era.
On Apple Silicon Macs, Rosetta 2 is not installed by default. It's triggered in two ways:
First Launch Prompt
The "Rosetta" software is not installed on your Mac.
Rosetta translates apps from Intel-based Macs for use on Apple Silicon Macs.
Command-Line Installation
softwareupdate --install-rosetta --agree-to-license
| Component | Description |
|---|---|
RosettaLinux/rosetta | Core ARM64 binary containing translation engine |
RosettaLinux/rosettad | System daemon managing translation services |
debugserver -> /usr/libexec/rosetta/debugserver | Debugging support for translated processes |
libRosettaRuntime | Runtime library linked during translation |
translate_tool -> /usr/libexec/rosetta/translate_tool | Translation tool for building translated binaries |
┌──────────────────────────────────────────────────────────────────┐
│ Phase 1: Binary Loading │
│ ─────────────────────────────────────────────────────────────── │
│ 1. Load x86_64 Mach-O binary │
│ 2. Parse segments, sections, symbols │
│ 3. Validate code signatures │
│ 4. Map into translation context │
└──────────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────┐
│ Phase 2: AOT Translation │
│ ─────────────────────────────────────────────────────────────── │
│ 1. Disassemble x86_64 code sections │
│ 2. Translate instructions to ARM64 │
│ 3. Apply optimizations │
│ 4. Store in translation cache (~/.oah) │
└──────────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────┐
│ Phase 3: Runtime Execution │
│ ─────────────────────────────────────────────────────────────── │
│ 1. Load translated ARM64 code │
│ 2. Set up x86_64 emulation context │
│ 3. Handle JIT translations for dynamic code │
│ 4. Translate syscalls on-the-fly │
└──────────────────────────────────────────────────────────────────┘
Register Mapping
Memory Ordering
Vector Instructions
Calling Conventions