Code Monkey home page Code Monkey logo

object's Introduction

object

The object crate provides a unified interface to working with object files across platforms. It supports reading relocatable object files and executable files, and writing COFF/ELF/Mach-O/XCOFF relocatable object files and ELF/PE executable files.

For reading files, it provides multiple levels of support:

  • raw struct definitions suitable for zero copy access
  • low level APIs for accessing the raw structs (example)
  • a higher level unified API for accessing common features of object files, such as sections and symbols (example)

Supported file formats for reading: ELF, Mach-O, Windows PE/COFF, Wasm, XCOFF, and Unix archive.

For writing files, it provides:

  • low level writers for ELF, PE, and COFF
  • higher level builder for ELF (example)
  • a unified API for writing relocatable object files (ELF, Mach-O, COFF, XCOFF) (example)

Example for unified read API

use object::{Object, ObjectSection};
use std::error::Error;
use std::fs;

/// Reads a file and displays the name of each section.
fn main() -> Result<(), Box<dyn Error>> {
    let binary_data = fs::read("path/to/binary")?;
    let file = object::File::parse(&*binary_data)?;
    for section in file.sections() {
        println!("{}", section.name()?);
    }
    Ok(())
}

See crates/examples for more examples.

Minimum Supported Rust Version (MSRV)

Changes to MSRV are considered breaking changes. We are conservative about changing the MSRV, but sometimes are required to due to dependencies. The MSRV is 1.65.0.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

object's People

Contributors

philipc avatar fitzgen avatar tesuji avatar daladim avatar bjorn3 avatar xry111 avatar dependabot-support avatar mstange avatar alexcrichton avatar esmeyi avatar amanieu avatar ignatenkobrain avatar luser avatar rreverser avatar striezel avatar amshafer avatar jrmuizel avatar jsgf avatar rocallahan avatar nagisa avatar tamird avatar vthib avatar sunfishcode avatar roblabla avatar m4b avatar ecnelises avatar osiewicz avatar mkroening avatar jonas-schievink avatar davidlattimore avatar

Watchers

 avatar

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.