https://github.com/p-x9/swift-dwarf
🐞 A Swift library for parsing binary files to obtain DWARF information.
https://github.com/p-x9/swift-dwarf
dwarf mach-o reverse-engineering
Last synced: 2 months ago
JSON representation
🐞 A Swift library for parsing binary files to obtain DWARF information.
- Host: GitHub
- URL: https://github.com/p-x9/swift-dwarf
- Owner: p-x9
- License: mit
- Created: 2025-04-01T17:22:03.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-04-13T13:28:52.000Z (2 months ago)
- Last Synced: 2026-04-14T08:42:33.543Z (2 months ago)
- Topics: dwarf, mach-o, reverse-engineering
- Language: Swift
- Homepage:
- Size: 315 KB
- Stars: 21
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# swift-dwarf
A Swift library for parsing binary files to obtain DWARF information.
> [!NOTE]
> Currently, only mach-o binaries are supported.
> ([MachOKit](https://github.com/p-x9/MachOKit))
>
> Support for ELF binaries will also be added in the future.
> ([ELFKit](https://github.com/p-x9/ELFKit))
[](https://github.com/p-x9/swift/issues)
[](https://github.com/p-x9/swift-dwarf/network/members)
[](https://github.com/p-x9/swift-dwarf/stargazers)
[](https://github.com/p-x9/swift-dwarf/)
## Usage
### Basic
DWARF information from binary file (MachOFile) can be retrieved via the `dwarf` property.
```swift
import MachOKit
import DWARF
// 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
/* ... */
```
[DWARFMachOPrintTests.swift](/Tests/DWARFTests/DWARFMachOPrintTests.swift) provides test cases that generate output similar to dwarfdump.
Please use these as a reference.
## Status
### Supported Binary formats
- [x] mach-o
- [ ] ELF
### Supported DWARF sections
- [x] `.debug_abbrev`
- [x] `.debug_info`
- [x] `.debug_line`
- [x] `.debug_str`
- [x] `.debug_line_str`
- [x] `.debug_str_offs`
- [x] `.debug_addr`
- [x] `.debug_aranges`
- [x] `.debug_rnglists`
- [x] `.debug_loclists`
- [x] `.debug_names`
- [ ] `.debug-macro`
- [ ] `.debug-pubnames`
- [ ] `.debug-pubtypes`
- [ ] `.debug-ranges`
## License
swift-dwarf is released under the MIT License. See [LICENSE](./LICENSE)