Detect memory layout inefficiencies in C/C++/Rust/Go binaries.
layout-audit reads DWARF debug info to visualize struct layouts, find padding, and flag cache-inefficient layouts. Great for catching regressions in CI.
cargo install layout-audit- Or download a prebuilt binary from GitHub Releases.
# Inspect all structs
layout-audit inspect ./target/debug/myapp
# JSON output
layout-audit inspect ./target/debug/myapp -o json
# SARIF output (for GitHub code scanning)
layout-audit inspect ./target/debug/myapp -o sarif > layout-audit.sarifinspect— analyze struct layoutsdiff— compare two binaries (use--fail-on-regressionin CI)check— enforce budgets from a config filesuggest— propose field reordering (review for ABI/serialization impact)
budgets:
Order:
max_size: 64
max_padding: 8
max_padding_percent: 15.0
"hot_path::*":
max_padding_percent: 5.0
"*":
max_size: 256Basic usage:
- uses: avifenesh/layout-audit@v0.5.0
with:
binary: ./target/debug/myapp
command: inspectSARIF (GitHub code scanning). The action uploads SARIF automatically when output: sarif is set. Your workflow must grant security-events: write.
permissions:
security-events: write
- uses: avifenesh/layout-audit@v0.5.0
with:
command: diff
binary: ./target/debug/myapp
baseline: ./target/debug/myapp-baseline
output: sarif| Input | Description | Default |
|---|---|---|
binary |
Path to binary file (required) | - |
command |
inspect, diff, check, or suggest |
inspect |
baseline |
Baseline binary for diff |
- |
config |
Config file for check |
.layout-audit.yaml |
filter |
Filter structs by name | - |
output |
Output format: table, json, or sarif |
table |
sort-by |
Sort by: name, size, padding, padding-pct |
padding |
top |
Show only top N structs | - |
min-padding |
Minimum padding bytes to show | - |
min-savings |
Minimum savings bytes to show (suggest) | - |
sort-by-savings |
Sort suggestions by savings (suggest) | false |
fail-on-regression |
Fail if layout regressed (diff) | false |
version |
layout-audit version to use | latest |
| Output | Description |
|---|---|
report |
The layout-audit output |
sarif-path |
Path to SARIF file (when output: sarif) |
- Rust 1.85+
- Binaries must include DWARF debug info (
-g) - Formats: ELF (Linux), Mach-O (macOS), PE (Windows with MinGW)
- On macOS, pass the dSYM path:
./binary.dSYM/Contents/Resources/DWARF/binary
Go is supported on Linux/macOS (Windows uses PDB). Use full debug info:
go build -gcflags=all="-N -l" -o myappRuntime types are filtered by default; use --include-go-runtime to show them.
MIT OR Apache-2.0