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:DWARF

From ReverseEngineering.wiki
Format
Platforms Linux, Android, macOS/iOS, WebAssembly, MinGW
Extensions .debug files, .dwo, .dwp, .dSYM
Endianness target byte order
On this wiki Facts · Code · Notes · Topics

The standard debug-information format of ELF, Mach-O (in .o and dSYM files), WebAssembly and COFF/MinGW toolchains: .debug_* sections holding a tree of tagged entries (DIEs) per compilation unit, line-number programs and call-frame information, versions 2 to 5.

Sections

.debug_info (the DIE tree, split into units), .debug_abbrev (abbreviation tables: tag, children flag, attribute/form pairs), .debug_str and .debug_line_str (strings), .debug_line (line-number programs), .debug_aranges, .debug_ranges / .debug_rnglists, .debug_loc / .debug_loclists, .debug_addr, .debug_str_offsets (DWARF 5), .debug_frame and, for unwinding at run time, .eh_frame. Sections can be zlib/zstd compressed (SHF_COMPRESSED in Format:ELF (Executable and Linkable Format); old .zdebug_* names start with "ZLIB"). Split DWARF keeps the DIEs in .dwo files (skeleton units point at them by name and dwo id).

Unit header

Every unit starts with unit_length (4 bytes; the value 0xFFFFFFFF introduces the 64-bit format with an 8-byte length and 8-byte section offsets), then uint16 version (2-5). Versions 2-4: debug_abbrev_offset, address_size. Version 5: unit_type (1 byte), address_size, debug_abbrev_offset, then skeleton/split units add an 8-byte dwo id and type units a type signature and type offset. Unit types: 1 compile, 2 type, 3 partial, 4 skeleton, 5 split_compile, 6 split_type; 0x80-0xFF user. Fact:DWARF/enum/Unit types

DIEs

Each DIE is a ULEB128 abbreviation code (0 ends a sibling list) followed by the attribute values in the form the abbreviation prescribes. Common tags: 0x11 compile_unit, 0x2e subprogram, 0x34 variable. Forms new in version 5 include strx (0x1a), line_strp (0x1f) and strx1-4 (0x25-0x28); GNU extensions use 0x1f01 GNU_addr_index, 0x1f02 GNU_str_index, 0x1f20 GNU_ref_alt and 0x1f21 GNU_strp_alt (dwz). DW_AT_producer names the compiler and its flags, useful for identifying the toolchain of a binary.

The abbreviation table format is in Fact:DWARF/behavior/Abbreviation declaration encoding; the form, tag, attribute, language and base-type value tables are Fact:DWARF/enum/Attribute forms, Fact:DWARF/enum/Common tags, Fact:DWARF/enum/Common attributes, Fact:DWARF/enum/Languages and Fact:DWARF/enum/Base type encodings. DW_FORM_implicit_const (0x21, version 5) keeps its value inside the abbreviation, so DIEs carry no bytes for it.

Reversing notes

  • .debug_line is a byte-code state machine: standard opcodes 1-12 (copy, advance_pc, advance_line, set_file, set_column, negate_stmt, ...), extended opcodes introduced by a 0 byte (end_sequence 1, set_address 2, set_discriminator 4) and special opcodes from the header's opcode_base on; DWARF 5 headers describe directory and file tables with content-type/form pairs (path 1, directory_index 2, timestamp 3, size 4, MD5 5). Fact:DWARF/enum/Line number opcodes
  • Call-frame instructions are listed in Fact:DWARF/enum/Call frame instructions.
  • A stripped binary usually still has .eh_frame, which gives function start addresses and sizes even without symbols.
  • Separate debug files are found through the GNU build-id note or .gnu_debuglink; on Mach-O through the UUID and dSYM bundle; Windows toolchains use Format:PDB (Program Database) instead.
  • Offsets in DWARF 5 .debug_str_offsets / .debug_addr are relative to the unit's base attributes, not to the section start.
  • DWARF is the one symbol carrier that IDA, Ghidra, Binary Ninja and Rizin all read, so it is a good way to hand names and types between tools: see Technique:Moving analysis between tools.
  • The .debug_line header differs by version: version 5 adds address_size and segment_selector_size after the version, version 4 and later has maximum_operations_per_instruction, version 2-3 do not; see Fact:DWARF/struct/Line program header.
  • Split DWARF packages (.dwp) index their units by section id; ids 5, 7 and 8 differ between the old GNU proposal and DWARF 5: Fact:DWARF/enum/Package file section ids. The skeleton unit in the main binary has unit_type 4 and the dwo id that matches the .dwo or .dwp unit.
  • Compressed .debug_* sections in ELF (SHF_COMPRESSED) start with an Elf_Chdr giving compression type (1 zlib, 2 zstd), uncompressed size and alignment: Fact:ELF (Executable and Linkable Format)/struct/Elf Chdr. Unverified: old .zdebug_* sections start with the 4 bytes "ZLIB" followed by an 8-byte big-endian uncompressed size, then a zlib stream.
  • Unverified: debuggers look for separate debug files at /usr/lib/debug/.build-id/<first byte of the build-id in hex>/<remaining bytes>.debug, or by the .gnu_debuglink name next to the binary, in a .debug subdirectory and under /usr/lib/debug; the build-id is the note type NT_GNU_BUILD_ID (3) in .note.gnu.build-id.
  • The related compact type format CTF is on Format:CTF (Compact C Type Format).

Topics

  • .eh frame — The call-frame information section .eh_frame (PT_GNU_EH_FRAME, .eh_frame_hdr) that the Itanium-ABI unwinder reads to unwind stacks: a sequence of…

Code & repositories

  • https://github.com/llvm/llvm-project @ 7bebaeed869a17710fb90ba1398aee0f20cc8cf2 · license: Apache-2.0 WITH LLVM-exception (declared by the contributor; GitHub's detector did not recognize LICENSE.TXT)
    LLVM: BinaryFormat/Minidump.h and MinidumpConstants.def, BinaryFormat/Dwarf.h and Dwarf.def, DebugInfo/DWARF/DWARFDebugFrame.cpp
    Tested on: source read, not run: source reading · checked 2026-10-18; last activity 2026-10-18; Note: the latest release ships binaries; the wiki links only the source, never the binaries