7 releases

0.3.1 Oct 13, 2023
0.3.0 Jan 16, 2023
0.2.0 Dec 8, 2021
0.1.3 May 30, 2020
0.1.0 Apr 3, 2019

#271 in Parser implementations

Download history 1305/week @ 2023-12-12 529/week @ 2023-12-19 225/week @ 2023-12-26 574/week @ 2024-01-02 668/week @ 2024-01-09 736/week @ 2024-01-16 726/week @ 2024-01-23 751/week @ 2024-01-30 556/week @ 2024-02-06 617/week @ 2024-02-13 505/week @ 2024-02-20 520/week @ 2024-02-27 657/week @ 2024-03-05 651/week @ 2024-03-12 1144/week @ 2024-03-19 906/week @ 2024-03-26

3,442 downloads per month
Used in 3 crates

Custom license

72KB
940 lines

Contains (ELF exe/lib, 135KB) tests/data/ls

elf_rs

Build Status Crates.io

This is a no_std library for ELF file handling. It supports ELF32 and ELF64 format.

Usage

To read an elf file, supply elf_rs::Elf with a &[u8] memory:

extern crate elf_rs;

use std::io::Read;
use std::fs::File;
use std::env;

use elf_rs::*;

fn read_elf(filename: &String) {
    let mut elf_file = File::open(filename).expect("open file failed");
    let mut elf_buf = Vec::<u8>::new();
    elf_file.read_to_end(&mut elf_buf).expect("read file failed");

    let elf = Elf::from_bytes(&elf_buf).expect("load elf file failed");

    println!("{:?} header: {:?}", elf, elf.elf_header());

    for p in elf.program_header_iter() {
        println!("{:x?}", p);
    }

    for s in elf.section_header_iter() {
        println!("{:x?}", s);
    }

    let s = elf.lookup_section(b".text");
    println!("s {:?}", s);
}

Under example directory there is a demo readelf to read an ELF file.

$ cargo run --example readelf <path_to_elf_file>

License

it is distributed under the terms of the MIT license.

Please see LICENSE file for details.

Dependencies

~195–270KB