Overview
iSH includes experimental support for running x86_64 (64-bit) code alongside the primary x86 (32-bit) emulation. This port extends the emulator to handle 64-bit registers, addressing modes, and instructions while maintaining compatibility with the existing 32-bit infrastructure.Building with 64-bit Support
Meson Configuration
To build iSH with 64-bit guest support, use theguest_arch option:
ISH_GUEST_64BIT preprocessor flag throughout the codebase:
Dependencies
The 64-bit port requires Zydis, a fast x86/x86_64 disassembler library, for instruction decoding:Architecture Changes
CPU State Extensions
The CPU state structure inemu/cpu.h adapts based on the ISH_GUEST_64BIT flag:
32-bit Register Macros
64-bit Register Macros
Extended Registers
In 64-bit mode, the CPU state includes r8-r15:Instruction Pointer
XMM Registers
64-bit mode expands XMM registers from 8 to 16:Instruction Decoding
decode64.c and decode64.h
The 64-bit port uses a completely separate instruction decoder powered by Zydis:decode64_init()- Initialize Zydis for 64-bit long modedecode64_inst()- Decode a single instructiondecode64_is_branch(),decode64_is_call(),decode64_is_ret()- Instruction classificationzydis_reg_to_arg64()- Convert Zydis registers to internal format
Operand Types
Code Generation
gen64.c vs gen.c
The build system selects the appropriate code generator:gen64.c is significantly larger (331,926 bytes vs 20,945 bytes for gen.c) due to the expanded instruction set and addressing modes of x86_64.
Gadget Directories
Directory Structure
Gadgets are organized by host and guest architecture:gadgets-aarch64- 32-bit guest on ARM64 hostgadgets-aarch64-64- 64-bit guest on ARM64 hostgadgets-x86_64- 32-bit guest on x86_64 host
Gadget Assembly Files
Each gadget directory contains:Current Status
The 64-bit port is experimental. Key considerations:- Decoder: Uses Zydis for robust instruction decoding
- Gadgets: 64-bit gadget implementations exist for AArch64 hosts
- Register State: Full 64-bit register support with backward compatibility for 32-bit sub-registers
- Addressing: Supports RIP-relative addressing and 64-bit memory operands
- TLS: Includes FS/GS base register support for thread-local storage
What Works
- Basic 64-bit instruction execution
- Extended register access (r8-r15)
- 64-bit addressing modes
- RIP-relative addressing
- Extended XMM register set (16 registers)
Build Testing
To test the 64-bit build:Implementation Notes
Portable Macros
Code uses portable macros to work with both architectures:Crash Handler
The crash handler inmain.c displays appropriate register state:
See Also
- Interpreter - Gadget system architecture
- Debugging - Tools for debugging the emulator