Object

Struct Object 

Source
pub struct Object {
    pub endianness: Endianness,
    pub license: CString,
    pub kernel_version: Option<u32>,
    pub btf: Option<Btf>,
    pub btf_ext: Option<BtfExt>,
    pub maps: HashMap<String, Map>,
    pub programs: HashMap<String, Program>,
    pub functions: BTreeMap<(usize, u64), Function>,
    /* private fields */
}
Expand description

The loaded object file representation

Fields§

§endianness: Endianness

The endianness

§license: CString

Program license

§kernel_version: Option<u32>

Kernel version

§btf: Option<Btf>

Program BTF

§btf_ext: Option<BtfExt>

Program BTF.ext

§maps: HashMap<String, Map>

Referenced maps

§programs: HashMap<String, Program>

A hash map of programs, using the program names parsed in ProgramSections as keys.

§functions: BTreeMap<(usize, u64), Function>

Functions

Implementations§

Source§

impl Object

Source

pub fn fixup_and_sanitize_btf( &mut self, features: &BtfFeatures, ) -> Result<Option<&Btf>, BtfError>

Fixes up and sanitizes BTF data.

Mostly, it removes unsupported types and works around LLVM behaviours.

Source§

impl Object

Source

pub fn relocate_btf( &mut self, target_btf: &Btf, ) -> Result<(), BtfRelocationError>

Relocates programs inside this object file with loaded BTF info.

Source§

impl Object

Source

pub fn parse(data: &[u8]) -> Result<Object, ParseError>

Parses the binary data as an object file into an Object

Source

pub fn patch_map_data( &mut self, globals: HashMap<&str, (&[u8], bool)>, ) -> Result<(), ParseError>

Patches map data

Source

pub fn sanitize_functions(&mut self, features: &Features)

Sanitize BPF functions.

Source§

impl Object

Source

pub fn relocate_maps<'a, I: Iterator<Item = (&'a str, c_int, &'a Map)>>( &mut self, maps: I, text_sections: &HashSet<usize>, ) -> Result<(), EbpfRelocationError>

Relocates the map references

Source

pub fn relocate_calls( &mut self, text_sections: &HashSet<usize>, ) -> Result<(), EbpfRelocationError>

Relocates function calls

Trait Implementations§

Source§

impl Clone for Object

Source§

fn clone(&self) -> Object

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Object

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Object

§

impl RefUnwindSafe for Object

§

impl Send for Object

§

impl Sync for Object

§

impl Unpin for Object

§

impl UnwindSafe for Object

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.