Skip to content

Latest commit

 

History

History
84 lines (61 loc) · 2.26 KB

File metadata and controls

84 lines (61 loc) · 2.26 KB

swift-dwarf

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.

Github issues Github forks Github stars Github top language

Usage

Basic

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.compilationUnits

DWARFMachOPrintTests.swift provides test cases that generate output similar to dwarfdump. DWARFELFPrintTests.swift provides the same for ELF binaries. Please use these as a reference.

Status

Supported Binary formats

  • mach-o
  • ELF

Supported DWARF sections

  • .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

License

swift-dwarf is released under the MIT License. See LICENSE