elfkit 0.0.4

an elf parser and manipulation library in pure rust
Documentation

Build Status crates.io MIT licensed docs

Elfkit

an elf read and manipulation library in pure rust (written from scratch, no bfd, no gnu code, no license infections), intended to be used in binary manipulation utils such as strip, chrpath, objcopy and ld. The end goal is to build a well designed library that facilitates drop-in replacements for gnu ld.

currently elfkit's ld can only link asm and C code with clang and musl libc

cargo build --release --example ld
ln -s $PWD/target/release/examples/ld /usr/bin/ld.elfkit
musl-clang -fuse-ld=elfkit tests/samples/main_c.c

there's also a prettier version of readelf showing of parsing capabilities

cargo run --example readelf ./tests/samples/amd64_exe

screenshot

implementation status

section specific parsers

type read write
symbols ok ok
strtab ok ok
relocations ok ok
dynamic ok ok
note - -
gnu_hash - -
hash - faked
versym - -
verneed - -

architectures

abi headers relocations
x86_64 ok minimum viable
mips32r2 o32 ok
arm eabi ok

alternatives

  • goblin mach-o and archive support, no-std support, very low level
  • elf most popular, most generic use case, no writing, no section parsing
  • xmas-elf zero alloc (good for writing an OS), read only

references