[−][src]Struct libelf::Elf
A handle to an ELF file.
Methods
impl<'elf> Elf<'elf>
[src]
pub 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();
pub 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();
pub 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();
pub 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.
pub 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);
Trait Implementations
Auto Trait Implementations
impl<'elf> !Send for Elf<'elf>
impl<'elf> Unpin for Elf<'elf>
impl<'elf> !Sync for Elf<'elf>
impl<'elf> !UnwindSafe for Elf<'elf>
impl<'elf> !RefUnwindSafe for Elf<'elf>
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,