wpahole is a forked and extended version of the original pahole tool from the dwarves project. Pahole is a utility for analyzing and pretty-printing DWARF debug information in ELF files, commonly used for tasks like BTF (BPF Type Format) encoding and struct layout inspection.
This fork adds support for JSON-formatted output, making it compatible with the Witchcraft Shell (WSH) from the Witchcraft Compiler Collection (WCC). The JSON output allows seamless integration with WSH for scripting and automation in binary analysis workflows.
Key features:
- All original pahole functionalities.
- New
--jsonoption (or equivalent) for outputting results in JSON format. - Builds an additional binary
wpaholealongsidepaholefor easy distinction.
This project is based on the upstream dwarves/pahole repository from git://git.kernel.org/pub/scm/devel/pahole/pahole.git.
The primary extension is to enable JSON output, which is particularly useful for:
- Integrating with tools like WSH in WCC for programmatic binary introspection.
- Parsing structured data in scripts or pipelines.
- Enhancing compatibility with modern tooling that expects machine-readable formats.
For more on WCC and WSH, see the WCC README.
wpahole requires the following dependencies (similar to upstream dwarves):
- CMake (version 3.5 or higher)
- libdw (from elfutils)
- zlib
- libbpf (embedded by default, or via pkg-config)
- argp and obstack (often in libc)
- Git (for submodule management)
On Ubuntu/Debian, install with:
sudo apt-get install -y cmake libdw-dev zlib1g-dev libelf-dev pkg-config gitIf using the embedded libbpf, no additional packages are needed beyond the basics.
Clone the repository:
git clone https://github.com/endrazine/wpahole.git
cd wpaholeInitialize and update submodules (for libbpf):
git submodule init
git submodule updateCreate a build directory and run CMake:
mkdir build
cd build
cmake ..
makeThis will build all tools, including pahole and the new wpahole (a copy of pahole for branding).
Install system-wide (may require sudo):
sudo make installBy default, binaries are installed to /usr/local/bin, libraries to /usr/local/lib, etc. Customize with -DCMAKE_INSTALL_PREFIX=/path during CMake.
wpahole retains all upstream pahole options. Run wpahole --help or man pahole for full details.
Pretty-print struct layouts from an ELF file:
wpahole -C struct_name /path/to/elf/fileUse the extended JSON feature (assuming implementation via a new flag; adjust based on your modifications):
wpahole -W /path/to/elf/file > output.jsonThis outputs DWARF information in JSON format, suitable for parsing in WSH scripts or other tools.
Refer to the WCC documentation for WSH scripting examples.
- Added CMake rules to build and install
wpaholeas a copy ofpahole. - Implemented JSON output support (details in source diffs; see commits).
- Maintained compatibility with upstream; pull updates via
git fetch upstream.
To contribute back or sync with upstream, fork from the original kernel.org repo and submit patches.
wpahole is licensed under the GNU General Public License v2 (GPL-2.0). See COPYING for details.
This fork respects the upstream license. For the original dwarves project license, refer to the kernel.org repository.
- Upstream: git://git.kernel.org/pub/scm/devel/pahole/pahole.git
- Related Project: Witchcraft Compiler Collection (WCC)
- Issues: Report bugs or feature requests here
Extended pahole with JSON output for WCC/WSH compatibility.
© 2025 Jonathan Brossard