elfkit

rust elf parsing, manipulation and (re)linking toolkit

Github星跟踪图

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 all sorts of binary manipulation magic.

elfkit can now link elfkit, so it's reasonably complete for x86_64. But it's definitely not stable yet and might produce incorrect code.

Using the linker

The quickest way to use elfkit with Rust is with korhal/stasis.

You can also either build from source or download binaries.
GCC does not have an option to use a foreign linker, so we need to pretend we're ld.gold, like so:

curl -L https://github.com/aep/elfkit/releases/download/0.0.4/elfkit-0.0.4.tar.xz, tar xvjf -
export PATH="$PWD/elfkit-0.0.4/:$PATH"
musl-gcc -fuse-ld=gold main.c

For using elfkit for compiling Rust code, add the following to ~/.cargo/config:

[target.x86_64-unknown-linux-musl]
rustflags = [
    "-C", "link-arg=-fuse-ld=gold",
    "-C", "link-arg=-Wl,-dynamic-linker,/usr/local/musl/lib/libc.so",
]

When compiling from source, create the ld.gold symlink manually:

cargo build --release --bin ld
ln -s "$PWD/target/release/ld" /usr/local/bin/ld.gold

Other binutils

readelf:
screenshot

implementation status

binutils, type, status, gnu compatible, --------------, -----------, ----------------, ldd, done, no, readelf, done, no, ld, wip, wip, objdump, -, -, ar, -, -, as, -, -, nm, -, -, strip, -, -, section parsers, type, read, write, --------------, ---------, ---------, symbols, done, done, strtab, done, done, relocations, done, done, dynamic, done, done, note, -, -, gnu_hash, -, -, hash, -, mvp, versym, -, -, verneed, -, -, architectures, abi, parser, linker, --------------, ---------, --------, x86_64, done, wip, mips32r2 o32, done, arm eabi, done, modular linker toolkit

  • Loader: loads elf objects from disk
  • Linker: produces a link graph of sections from a loader
  • Collector: bakes multiple sections into a single object
  • Relocator: applies relocations to a combined object

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

主要指标

概览
名称与所有者aep/elfkit
主编程语言Rust
编程语言Rust (语言数: 4)
平台
许可证MIT License
所有者活动
创建于2017-09-06 20:40:56
推送于2020-06-22 13:53:51
最后一次提交2020-06-22 15:53:50
发布数3
最新版本名称0.0.6 (发布于 2018-07-22 00:11:47)
第一版名称0.0.4 (发布于 2017-12-28 20:25:38)
用户参与
星数205
关注者数7
派生数24
提交数89
已启用问题?
问题数7
打开的问题数1
拉请求数8
打开的拉请求数2
关闭的拉请求数2
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?