Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Ruby YARB binary instruction sequence

From ReverseEngineering.wiki
Format
Magic 59 41 52 42 (YARB)
Extensions .yarb, .bin
Endianness native (header byte 'l' or 'b')
License Ruby / BSD-2-Clause (ruby/ruby)
On this wiki Facts · Code · Notes · Topics

Binary iseq dump of CRuby (RubyVM::InstructionSequence#to_binary, also bootsnap-style caches): a file starting with the magic YARB and a fixed header holding the Ruby API major and minor version, sizes, offsets, an endian marker and the word size.

Overview

CRuby writes a compiled top-level instruction sequence with ibf_dump (compile.c, functions iseq_ibf_dump_0 and rb_iseq_ibf_dump). The file starts with a fixed struct ibf_header and ends with the optional extra data given to the dump call. The loader (ibf_load_setup_bytes) refuses a file that does not match the running interpreter exactly, so a YARB file is tied to one Ruby API version, one endianness and one word size. Source: ruby/ruby commit dfe721da1e00 (see Fact:Ruby YARB binary instruction sequence/struct/ibf_header).

Header

Fields in order: magic[4] YARB, u32 major_version, u32 minor_version, u32 size (length of the dump without the extra data), u32 extra_size, u32 iseq_list_size, u32 global_object_list_size, u32 iseq_list_offset, u32 global_object_list_offset, u8 endian, u8 wordsize. The endian byte is the ASCII letter 'l' (little) or 'b' (big); wordsize is sizeof(VALUE), i.e. 8 on 64-bit. By the C layout rules the struct is 38 bytes of fields padded to 40 (computed, not measured). The header is written first as zeros, filled after the iseqs and the object list are dumped, and overwritten at offset 0.

Version check

IBF_MAJOR_VERSION is ISEQ_MAJOR_VERSION and IBF_MINOR_VERSION is ISEQ_MINOR_VERSION, which come from ruby_api_version[0] and [1] (iseq.h); in a development build (RUBY_DEVEL) the minor is minor*10000 + 9. At the cited commit RUBY_API_VERSION_MAJOR is 4 and MINOR is 1 (include/ruby/version.h), so a dump from that tree has major 4 and minor 1 (or 10009 in a devel build; Unverified which applies). The loader raises: "broken binary format" (file shorter than header size), "unknown binary format" (magic), "unmatched version file (%u.%u for %u.%u)", "unmatched endian: %c", "unmatched word size: %d", and ArgumentError for unaligned list offsets.

There is no platform string and no checksum in this header at this commit. Unverified: the iseq body encoding (the iseq list entries, the object list, small-value encoding) changes between Ruby versions; read ibf_dump_iseq_each / ibf_load_iseq_each in compile.c for the version you target.

Code & repositories

  • https://github.com/ruby/ruby @ dfe721da1e00b6eb34f7368796f815acedd5255e · license: Ruby OR BSD-2-Clause (declared by the contributor; GitHub's detector did not recognize COPYING)
    CRuby: compile.c ibf_* functions (binary iseq dump/load).
    Tested on: source read, not run: read source only · checked 2026-10-19; last activity 2026-10-19

Evidence & references

  • ruby/ruby at dfe721da1e00: compile.c (struct ibf_header, iseq_ibf_dump_0, ibf_load_setup_bytes), iseq.h, include/ruby/version.h.