Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

ELF Symbol Analyzer

A command-line tool for inspecting ELF binaries — symbol tables, section sizes, undefined/weak symbols, and shared library dependencies. Supports both ELF32 and ELF64, little- and big-endian, across x86, x86-64, ARM, AArch64, and RISC-V.

Zero external dependencies. Pure C++17 with hand-rolled ELF parsing.

Features

  • Symbol table extraction (.symtab and .dynsym)
  • Section inventory sorted by size
  • Undefined symbol detection (unresolved external references)
  • Weak symbol listing
  • Shared library dependency chains (DT_NEEDED entries)
  • JSON output mode for pipeline integration
  • Handles stripped binaries gracefully

Build

mkdir build && cd build
cmake ..
make -j$(nproc)

Usage

elf-analyzer [options] <elf-binary>

Options:
  -s, --symbols       Show full symbol table (default)
  -S, --sections      Show section sizes
  -u, --undefined     Show undefined symbols only
  -w, --weak          Show weak symbols only
  -d, --deps          Show shared library dependencies
  -a, --all           Show everything
  -j, --json          Output as JSON
  -h, --help          Show this help

Examples

# Quick overview — undefined symbols and deps
./elf-analyzer -u -d /usr/bin/ls

# Full section breakdown
./elf-analyzer -S /usr/bin/python3

# JSON output for scripting
./elf-analyzer -a -j ./my_program | jq '.undefined_symbols'

# Inspect a shared library
./elf-analyzer -a /usr/lib/x86_64-linux-gnu/libc.so.6

Sample Output

File: /usr/bin/ls
Type: DYN (shared object)  Arch: x86-64  Class: ELF64  Endian: LE
Entry: 0x67d0

── Shared Library Dependencies (4) ──
  libselinux.so.1
  libc.so.6
  libpcre2-8.so.0

── Undefined Symbols (12) ──
  [FUNC] opendir
  [FUNC] __printf_chk
  [FUNC] getxattr
  ...

Performance

Analyzes a 50 MB binary in under 200 ms on commodity hardware. Memory usage is O(file size) — the file is loaded once into a single buffer.

Internals

  • No libelf or libbfd — ELF structs are defined inline from the spec
  • Endian-aware read helpers handle both LE and BE without UB
  • Separate 32-bit and 64-bit parse paths share the same reporter layer
  • JSON output is hand-serialized (no external JSON library needed)

About

A command-line tool for inspecting ELF binaries — symbol tables, section sizes, undefined/weak symbols, and shared library dependencies. Supports both ELF32 and ELF64, little- and big-endian, across x86, x86-64, ARM, AArch64, and RISC-V. Zero external dependencies. Pure C++17 with hand-rolled ELF parsing.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages