Skip to content

GitHub Action & CLI to analyze binary memory layouts: detect padding, compare diffs, enforce budgets. Parses DWARF debug info for C/C++/Rust/Go.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

avifenesh/layout-audit

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

layout-audit

Crates.io Downloads CI Coverage License GitHub Marketplace

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.

Install

  • cargo install layout-audit
  • Or download a prebuilt binary from GitHub Releases.

Quick start

# 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.sarif

Commands

  • inspect — analyze struct layouts
  • diff — compare two binaries (use --fail-on-regression in CI)
  • check — enforce budgets from a config file
  • suggest — propose field reordering (review for ABI/serialization impact)

Budget config (.layout-audit.yaml)

budgets:
  Order:
    max_size: 64
    max_padding: 8
    max_padding_percent: 15.0

  "hot_path::*":
    max_padding_percent: 5.0

  "*":
    max_size: 256

GitHub Action

Basic usage:

- uses: avifenesh/layout-audit@v0.5.0
  with:
    binary: ./target/debug/myapp
    command: inspect

SARIF (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

Action inputs

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

Action outputs

Output Description
report The layout-audit output
sarif-path Path to SARIF file (when output: sarif)

Requirements

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

Go is supported on Linux/macOS (Windows uses PDB). Use full debug info:

go build -gcflags=all="-N -l" -o myapp

Runtime types are filtered by default; use --include-go-runtime to show them.

License

MIT OR Apache-2.0

About

GitHub Action & CLI to analyze binary memory layouts: detect padding, compare diffs, enforce budgets. Parses DWARF debug info for C/C++/Rust/Go.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published