Struct libelf::Elf
[−]
[src]
pub struct Elf<'elf> { /* fields omitted */ }
A handle to an ELF file.
Methods
impl<'elf> Elf<'elf>
[src]
fn open<P: AsRef<Path>>(path: P) -> Result<Elf<'static>>
[src]
Open an Elf
from a path.
Examples
let exe = std::env::current_exe().unwrap(); let elf = libelf::Elf::open(exe).unwrap();
fn from_fd<FD: AsRawFd>(fd: &'elf FD) -> Result<Elf<'elf>>
[src]
Create an Elf
from an open file.
Examples
let exe = std::env::current_exe().unwrap(); let f = std::fs::File::open(exe).unwrap(); let elf = libelf::Elf::from_fd(&f).unwrap();
fn from_bytes(bytes: &'elf [u8]) -> Result<Elf<'elf>>
[src]
Create an Elf
from a byte slice.
Examples
use std::io::Read; let exe = std::env::current_exe().unwrap(); let mut buf = vec![]; std::fs::File::open(exe).unwrap() .read_to_end(&mut buf).unwrap(); let elf = libelf::Elf::from_bytes(&buf).unwrap();
// elfutils doesn't mind an empty ELF! let empty = libelf::Elf::from_bytes(&[]).unwrap();
unsafe fn from_raw(elf: *mut Elf) -> Elf<'elf>
[src]
Create an Elf
from a raw FFI pointer.
Safety
This function is unsafe because there is no guarantee that the given
pointer is a valid libelf
handle, nor whether the lifetime inferred
is appropriate. This does not take ownership of the underlying object,
so the caller must ensure it outlives the returned Elf
wrapper.
fn as_ptr(&self) -> *mut Elf
[src]
Get a raw FFI pointer
Examples
let ptr = elf.as_ptr(); assert!(!ptr.is_null()); let base = unsafe { libelf::raw::elf_getbase(ptr) }; assert!(base >= 0);