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:Emacs Lisp byte-code (.elc)

From ReverseEngineering.wiki
Format
Magic 3B 45 4C 43 (;ELC) then version byte
Extensions .elc
License GPL-3.0-or-later (emacs-mirror/emacs)
On this wiki Facts · Code · Notes · Topics

Compiled Emacs Lisp file written by the byte compiler: a text-like file whose first four bytes are ';ELC', followed by a byte holding the Emacs major version (minus one for x.0 development builds), three NUL bytes and a newline, then comment lines and Lisp forms containing byte-code function objects.

Overview

Recognition level. byte-compile-insert-header in lisp/emacs-lisp/bytecomp.el (emacs-mirror/emacs commit 2b0acc90e165) writes ;ELC, one version byte, \000\000\000\n, then the comment lines ;;; Compiled, ;;; in Emacs version <emacs-version> and ;;; with <optimization level> and two blank lines. The rest of the file is ordinary Lisp reader syntax: top-level forms where compiled functions are byte-code objects printed as #[...] vectors (Unverified: exact printed form of a compiled function in the cited Emacs version; open a .elc to see it). See Fact:Emacs Lisp byte-code (.elc)/magic/ELC header.

Version byte

The source comment says the byte is the file-format version number (18, 19, 20 or 23 in older releases). The current code sets it to emacs-major-version, except when emacs-minor-version is 0 where it uses emacs-major-version minus 1, so that files compiled with a freshly cut x.0 development build still load in the previous release. It must be above 13 and below 128, so it is a plain byte that does not end the comment line. The header comment suggests a magic(5) rule: string ;ELC at 0, byte at 4 printed as the version. The Emacs version string in the second comment line gives the exact version.

The bytecode inside is a stack machine whose opcodes are defined in the same file family (byte-opt.el / bytecomp.el opcode table); Unverified: details, and the format of natively compiled .eln files, which are shared objects loaded by native-compilation and are not covered here.

Code & repositories

  • https://github.com/emacs-mirror/emacs @ 2b0acc90e165f668cbfb0fddb17f4149b1d7901b · license: GPL-3.0
    Emacs: lisp/emacs-lisp/bytecomp.el (byte compiler and .elc header).
    Tested on: source read, not run: read source only · checked 2026-10-19; last activity 2026-10-18

Evidence & references

  • emacs-mirror/emacs at 2b0acc90e165: lisp/emacs-lisp/bytecomp.el lines 2504-2541.