Skip to content

Scharxi/elf-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ELF Loader

A simple ELF file loader and parser written in Rust. This library allows you to parse and examine ELF (Executable and Linkable Format) files.

Features

  • Parse 32-bit and 64-bit ELF files
  • Support for big and little endian
  • Extract and examine ELF headers
  • Parse program headers (segments)
  • Parse section headers
  • Resolve section names
  • Extract section data
  • Basic interpreter path identification

Installation

Add this to your Cargo.toml:

[dependencies]
elf-loader = { git = "https://github.com/yourusername/elf-loader.git" }

Usage

Basic Usage

use elf_loader::ElfFile;

fn main() {
    // Load an ELF file
    let elf_file = ElfFile::open("path/to/your/executable").unwrap();
    
    // Print basic information
    println!("Architecture: {:?}", elf_file.header.e_machine);
    println!("Type: {:?}", elf_file.header.e_type);
    println!("Entry point: 0x{:x}", elf_file.header.e_entry);
    
    // Iterate through program headers
    for (i, ph) in elf_file.program_headers.iter().enumerate() {
        println!("Program Header {}: Type: {:?}, Flags: {}", i, ph.p_type, ph.p_flags);
    }
    
    // Iterate through section headers
    for (i, sh) in elf_file.section_headers.iter().enumerate() {
        println!("Section {}: Name: {:?}, Type: {:?}", 
                i, sh.name, sh.sh_type);
    }
    
    // Get data from a specific section
    if let Some((index, _)) = elf_file.find_section_by_name(".text") {
        let section_data = elf_file.get_section_data(index).unwrap();
        println!("Size of .text section: {} bytes", section_data.len());
    }
}

Command-line Tool

The package also includes a command-line tool for examining ELF files:

cargo run -- path/to/your/executable

This will display detailed information about the ELF file.

Development

Building

cargo build

Testing

cargo test

Running

cargo run -- path/to/your/executable

License

This project is licensed under the MIT License - see the LICENSE file for details.

Roadmap

  • Support for dynamic loading
  • Symbol table parsing
  • Relocation handling
  • Memory mapping and execution
  • Debugging support

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages