padlock-dwarf
DWARF and PDB binary analysis backend for padlock — a struct memory layout analyzer for C, C++, Rust, Go, and Zig.
This crate reads compiled binaries and extracts exact struct layouts as produced by the compiler:
- DWARF (ELF on Linux, Mach-O on macOS) — reads
DW_TAG_structure_typeandDW_TAG_memberentries viagimli+object - PDB (Windows) — reads type records via the
pdbcrate detect_arch_from_host()— returns theArchConfigfor the current build target
Unlike source analysis, DWARF-based layouts are compiler-verified: offsets, sizes, and padding are exactly what the compiler produced. This is useful for structs with alignas, __attribute__((packed)), conditional compilation, or complex type aliases that source analysis cannot fully resolve.
Usage
padlock-dwarf is an internal library crate. To analyze a binary, use the CLI:
Part of padlock
padlock-cli— CLI (padlock+cargo-padlockbinaries)padlock-core— IR, analysis passes, findingspadlock-source— Source analysis (C/C++/Rust/Go)padlock-dwarf— Binary analysis (DWARF/PDB) (this crate)padlock-output— Output formatters (terminal/JSON/SARIF/diff)padlock-macros— Compile-time layout assertions