Introduction
A .beam file holds one compiled module for BEAM, the virtual machine of
Erlang/OTP. The Erlang compiler writes one file
per module, and so do the compilers of other languages that run on the same virtual
machine, such as Elixir and Gleam. The runtime loads modules from these files as the
program calls them, and can load a new version of a module while the system is
running.
Structure
A BEAM file uses the chunk layout of the IFF format. It starts with
FOR1, a 32-bit big-endian size for the rest of the file, and the form
type BEAM. Then come chunks, each a four-character ID, a 32-bit big-endian
length and that many bytes, padded to a multiple of four.
Common chunks are AtU8 (the atoms the module uses, in UTF-8;
Atom in older files), Code (the bytecode), StrT
(strings), ImpT, ExpT and LocT (imported,
exported and local functions), LitT (literals), FunT
(anonymous functions), Attr and CInf (module attributes and
compiler information), Line (line numbers) and Dbgi or
Docs for debug information and documentation.
0FOR1, size, form typeBEAM12 bytes12AtU8 atom tablevaries…Code bytecodevaries…StrT, ImpT, ExpT, LocT, LitT and other chunksvaries
Links
Software
- Erlang/OTP, which compiles and runs them (Windows, macOS, Linux)
- Elixir (Windows, macOS, Linux)
- Gleam (Windows, macOS, Linux)
Developers
- beam_lib, the Erlang/OTP standard library module that reads chunks from BEAM files