• This repository has been archived on 04/Mar/2021
  • Stars
    star
    202
  • Rank 193,691 (Top 4 %)
  • Language
    Rust
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

rust elf parsing, manipulation and (re)linking toolkit

Build Status crates.io MIT licensed docs

DED

please note that i no longer work with rust and this is not maintained. If anyone has interest in maintaining this crate, feel free to open a github issue.

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

More Repositories

1

osaka

async for rust without the noise
Rust
141
star
2

pug-rs

pug.js reimplemented in rust for speed
Rust
27
star
3

vag_reverse_engineering

volkswagen vw audi group reverse engineering
C
19
star
4

aws-terraform-vault-consul-nomad-wireguard

zero to nomad cluster on aws
HCL
11
star
5

zztop

for science
10
star
6

ugo

go without GOPATH
Go
7
star
7

archon

content addressable image store
Rust
6
star
8

usb-mining-watchdog-china

reverse engineering of the crappy chinese usb mining watchdog thing
Rust
5
star
9

Kite

Modern event driven C++ toolkit for embedded linux
C++
5
star
10

MONORAKE

static website builder that just works
Go
4
star
11

kicad

kicad stuff
3
star
12

stonecast

dlna services done my way. i.e. not crappy.
C++
3
star
13

ppsbench

sigrok gui for running current sink test
C++
3
star
14

xdo-go

golang wrapper for libxdo
Go
2
star
15

pn532

Rust
2
star
16

bolter-research

content addressable storage for ELF binaries
Rust
2
star
17

artanis-light

2
star
18

madpack

stupid small json binary encoding
Go
2
star
19

libvirt-hub-agent

C
2
star
20

ceramic-rust

channels over proccess for rust
Rust
2
star
21

bolter

content addressed elf linker
Rust
2
star
22

qtftp

C++
1
star
23

EagleLibraries

1
star
24

coinz

Rust
1
star
25

gcmap

Rust
1
star
26

vault-init

bootstrap a a vault-consul-nomad cluster from a single command
Go
1
star
27

screeps

screeps ai in typescript
TypeScript
1
star
28

codeclimate-rustfmt

this enables rustfmt as codeclimate engine
Shell
1
star
29

btrfs-workspace-plugin

Jenkins plugin to make workspaces btrfs snapshots
Java
1
star
30

kite-mqtt

mqtt client in kite/c++
C++
1
star
31

zzsinglemoduletest

1
star
32

carrier-custom-service-example

Rust
1
star
33

valetudo-dreameadapter

1
star
34

LazerSharks

Embedded Linux C++ HttpServer framework, similator to rack/plug/etc
C++
1
star
35

clay.io.events

Asynch i/o for clay.
1
star
36

witch

A permission elevation mechanism protecting the user from the machine, instead of the other way round.
C++
1
star
37

msul

musl libc, actually.
C
1
star
38

tinylogger

env_logger semi-compatible logger but much much smaller
Rust
1
star
39

feistel

collision-free pseudorandom sequence using a feistel cipher in cycle walking mode
Go
1
star
40

tplink-bootloader

C
1
star
41

rblue

a reimplementation of the bluez userspace in pure ruby
Ruby
1
star