A Swift library for parsing binary files to obtain DWARF information.
Note
Mach-O and ELF binaries are supported. MachOKit is used for Mach-O binaries. ELFKit is used for ELF binaries.
DWARF information from binary files can be retrieved via the dwarf property.
Import the format-specific adapter that matches the binary type you want to inspect.
import MachOKit
import DWARF
import DWARFMachO
let machO: MachOFile = ...
// string table in `.debug_str` section
let strings = machO.dwarf.strings
// abbreviations tables in `.debug_abbrev` section
let abbreviationSets = machO.dwarf.abbreviationsSets
// compilation units in `.debug_info` section
let compilationUnits = machO.dwarf.compilationUnits
/* ... */import ELFKit
import DWARF
import DWARFELF
let elf: ELFFile = ...
let elfStrings = elf.dwarf.strings
let elfCompilationUnits = elf.dwarf.compilationUnitsDWARFMachOPrintTests.swift provides test cases that generate output similar to dwarfdump. DWARFELFPrintTests.swift provides the same for ELF binaries. Please use these as a reference.
- mach-o
- ELF
-
.debug_abbrev -
.debug_info -
.debug_line -
.debug_str -
.debug_line_str -
.debug_str_offs -
.debug_addr -
.debug_aranges -
.debug_rnglists -
.debug_loclists -
.debug_names -
.debug-macro -
.debug-pubnames -
.debug-pubtypes -
.debug-ranges
swift-dwarf is released under the MIT License. See LICENSE