WIPIVERSE All articles

.debug_info

Overview

.debug_info is a standard section in Executable and Linkable Format (ELF) files that contains debugging information encoded in the DWARF (Debugging With Attributed Record Formats) standard. This section stores a hierarchical representation of the program’s source-level constructs—including types, variables, functions, and line numbers—to enable source-level debugging by tools such as GDB, LLDB, and commercial debuggers.

Technical Characteristics

Aspect Detail
File Format ELF (used on Unix‑like operating systems)
Section Name .debug_info (sometimes .debug_info.dwo for split DWARF)
Content Encoding DWARF “info” records, organized as a series of compilation units (CUs)
Compression May be compressed using the GNU zlib or zstd compression conventions (e.g., .debug_info may be stored in a .zdebug_info variant)
Related Sections .debug_abbrev, .debug_str, .debug_line, .debug_loc, .debug_aranges, .debug_pubnames, .debug_pubtypes

DWARF Structure within .debug_info

  1. Compilation Unit Header – Begins each CU and includes:

    • Length of the CU (4 or 12 bytes depending on DWARF version)
    • DWARF version number (e.g., 4, 5)
    • Offset to the abbreviation table (.debug_abbrev)
    • Address size (1, 2, 4, or 8 bytes)
  2. Debugging Information Entries (DIEs) – Hierarchical nodes describing program entities:

    • Each DIE references an abbreviation that defines the set and format of its attributes.
    • Common DIE tags: DW_TAG_subprogram, DW_TAG_variable, DW_TAG_structure_type, DW_TAG_namespace, etc.
    • Attributes reference other sections for strings (.debug_str), line tables (.debug_line), and location expressions (.debug_loc).
  3. End of CU – Marked implicitly by reaching the length specified in the CU header.

Purpose and Usage

  • Source-Level Debugging: Enables debuggers to map machine addresses back to source lines, variable names, and type information.
  • Static Analysis: Tools that perform binary analysis (e.g., objdump --dwarf=info, readelf --debug-dump=info) parse .debug_info to reconstruct program structure.
  • Performance Profiling: Some profilers use DWARF info to attribute sampled instruction pointers to source locations.

Generation and Stripping

  • Compilers such as GCC, Clang, and ICC generate .debug_info when invoked with debugging flags (e.g., -g).
  • The section can be removed from the final binary using strip --strip-debug or by specifying -s/-Wl,--strip-all to the linker, reducing file size but eliminating source-level debugging capability.

Versioning

  • DWARF has multiple revisions (2 through 5 as of 2026). Newer versions add features such as:
    • Ranges and address families for improved representation of non‑contiguous code.
    • Split DWARF (.debug_info.dwo) to separate debug info from the main binary.
  • Compatibility is maintained: most debuggers understand older DWARF versions, but newer features may be ignored if unsupported.

References

  • DWARF Debugging Information Format, Version 5, 2022 (the official specification).
  • System V Application Binary Interface, ELF Specification, Fourth Edition.
  • GCC and Clang documentation on debugging options (-g, -gstrip).

See Also

  • .debug_abbrev – Abbreviation table referenced by .debug_info.
  • .debug_line – Line number mapping for source files.
  • GNU objdump and readelf – Utilities for inspecting .debug_info.
  • Split DWARF – Technique for distributing debugging information across separate files.
Browse

More topics to explore

    Browse all articles