{"id":13648772,"url":"https://github.com/aep/elfkit","last_synced_at":"2025-12-30T05:12:38.677Z","repository":{"id":57624101,"uuid":"102656249","full_name":"aep/elfkit","owner":"aep","description":"rust elf parsing, manipulation and (re)linking toolkit","archived":true,"fork":false,"pushed_at":"2020-06-22T13:53:51.000Z","size":1530,"stargazers_count":205,"open_issues_count":3,"forks_count":24,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-19T08:21:35.862Z","etag":null,"topics":["binutils","elf","elf-parser","ld","linker","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-06T20:40:56.000Z","updated_at":"2025-02-28T15:24:11.000Z","dependencies_parsed_at":"2022-08-26T22:11:40.939Z","dependency_job_id":null,"html_url":"https://github.com/aep/elfkit","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aep%2Felfkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aep%2Felfkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aep%2Felfkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aep%2Felfkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aep","download_url":"https://codeload.github.com/aep/elfkit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250232549,"owners_count":21396661,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binutils","elf","elf-parser","ld","linker","rust"],"created_at":"2024-08-02T01:04:31.784Z","updated_at":"2025-12-12T15:03:35.890Z","avatar_url":"https://github.com/aep.png","language":"Rust","readme":"[![Build Status](https://travis-ci.org/aep/elfkit.svg?branch=master)](https://travis-ci.org/aep/elfkit)\n[![crates.io](http://meritbadge.herokuapp.com/elfkit)](https://crates.io/crates/elfkit)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE-MIT)\n[![docs](https://docs.rs/elfkit/badge.svg)](https://docs.rs/elfkit)\n\nDED\n=========\n\nplease note that i no longer work with rust and this is not maintained.\nIf anyone has interest in maintaining this crate, feel free to open a github issue.\n\n\n\nElfkit\n=========\n\nAn elf read and manipulation library in pure Rust (written from scratch, no bfd, no gnu code, no license infections),\nintended to be used in binary manipulation utils such as strip, chrpath, objcopy and ld.\nThe end goal is to build a well designed library that facilitates all sorts of binary manipulation magic.\n\nelfkit can now link elfkit, so it's reasonably complete for x86_64. But it's definitely not stable yet and might produce incorrect code.\n\n\nUsing the linker\n---------------------\n\nThe quickest way to use elfkit with Rust is with [korhal/stasis](https://github.com/korhalio/stasis).\n\nYou can also either build from source or download binaries.\nGCC does not have an option to use a foreign linker, so we need to pretend we're ld.gold, like so:\n\n```sh\ncurl -L https://github.com/aep/elfkit/releases/download/0.0.4/elfkit-0.0.4.tar.xz | tar xvjf -\nexport PATH=\"$PWD/elfkit-0.0.4/:$PATH\"\nmusl-gcc -fuse-ld=gold main.c\n```\n\nFor using elfkit for compiling Rust code, add the following to `~/.cargo/config`:\n\n```toml\n[target.x86_64-unknown-linux-musl]\nrustflags = [\n    \"-C\", \"link-arg=-fuse-ld=gold\",\n    \"-C\", \"link-arg=-Wl,-dynamic-linker,/usr/local/musl/lib/libc.so\",\n]\n```\n\nWhen compiling from source, create the ld.gold symlink manually:\n\n```sh\ncargo build --release --bin ld\nln -s \"$PWD/target/release/ld\" /usr/local/bin/ld.gold\n```\n\n\nOther binutils\n---------------------\n\nreadelf:\n![screenshot](/bin/readelf-screenshot.png?raw=true)\n\n\nimplementation status\n---------------------\n\nbinutils\n\n| type         | status    | gnu compatible |\n|--------------|-----------|----------------|\n| ldd          | done      | no             |\n| readelf      | done      | no             |\n| ld           | wip       | wip            |\n| objdump      | -         | -              |\n| ar           | -         | -              |\n| as           | -         | -              |\n| nm           | -         | -              |\n| strip        | -         | -              |\n\nsection parsers\n\n| type         | read    | write   |\n|--------------|---------|---------|\n| symbols      | done    | done    |\n| strtab       | done    | done    |\n| relocations  | done    | done    |\n| dynamic      | done    | done    |\n| note         | -       | -       |\n| gnu_hash     | -       | -       |\n| hash         | -       | mvp     |\n| versym       | -       | -       |\n| verneed      | -       | -       |\n\narchitectures\n\n| abi          | parser  | linker |\n|--------------|---------|--------|\n| x86_64       | done    | wip    |\n| mips32r2 o32 | done    |        |\n| arm eabi     | done    |        |\n\n\nmodular linker toolkit\n---------------------\n\n- Loader:       loads elf objects from disk\n- Linker:       produces a link graph of sections from a loader\n- Collector:    bakes multiple sections into a single object\n- Relocator:    applies relocations to a combined object\n\nalternatives\n----------------\n\n- [goblin](https://crates.io/crates/goblin) mach-o and archive support, no-std support, very low level\n- [elf](https://crates.io/crates/elf) most popular, most generic use case, no writing, no section parsing\n- [xmas-elf](https://github.com/nrc/xmas-elf) zero alloc (good for writing an OS), read only\n\n\nreferences\n---------------------\n- https://en.wikipedia.org/wiki/Executable_and_Linkable_Format\n- https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-r252.pdf\n- https://software.intel.com/sites/default/files/article/402129/mpx-linux64-abi.pdf\n- http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044f/IHI0044F_aaelf.pdf\n- https://dmz-portal.imgtec.com/wiki/MIPS_ABI_Project\n- https://dmz-portal.imgtec.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking\n- http://www.mindfruit.co.uk/2012/06/relocations-relocations.html#reloc_types_table\n- https://www.akkadia.org/drepper/tls.pdf\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faep%2Felfkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faep%2Felfkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faep%2Felfkit/lists"}