Giter VIP home page Giter VIP logo

elfkit's Introduction

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

elfkit's People

Contributors

aep avatar bkchr avatar glandium avatar josephlr avatar konstin avatar nabijaczleweli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elfkit's Issues

Bloom filter crate is buggy and not maintained

The bloom crate has a bug which was reported in 2017. There were no actions in the repo for three years.

Briefly, the bug is as follows: one needs to compute k hash values for an element added to the filter. In order to cut down the number of hash function calls, the crate computes two independent hashes and uses them as a seed for a RNG and then samples k values from it. I think that the basic idea is sound, but they botched the implementation of the RNG. See the next method for HashIter in src/hashing.rs. All RNG outputs after the first are a multiple of h2 modulo 2^64.

I'm sorry to say that I don't know a good alternative for the crate. I've been looking at several other bloom filter implementations in Rust for work and none of them inspired much confidence, so we ultimately decided to roll our own.

refactor ld

bolter and example/ld share most of the code.
We'll need to refactor that code to be usable as library code in elfkit for others.

section alignment

sections are currently not aligned (alignment needs to be the maximum of all input alignments i think)
also the objects inside each section need to be aligned.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.