
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