0429ed2fa2
``` error: manual implementation of `ok` --> aya/src/util.rs:261:28 | 261 | let addr = match u64::from_str_radix(addr, 16) { | ____________________________^ 262 | | Ok(addr) => Some(addr), 263 | | Err(ParseIntError { .. }) => None, 264 | | }?; | |_________________^ help: replace with: `u64::from_str_radix(addr, 16).ok()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_err error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:1705:44 | 1705 | section: ProgramSection::KProbe { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern note: the lint level is defined here --> aya-obj/src/lib.rs:68:9 | 68 | #![deny(clippy::all, missing_docs)] | ^^^^^^^^^^^ = note: `#[deny(clippy::unneeded_struct_pattern)]` implied by `#[deny(clippy::all)]` error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:1769:44 | 1769 | section: ProgramSection::KProbe { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:1787:44 | 1787 | section: ProgramSection::KProbe { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:1919:48 | 1919 | section: ProgramSection::KProbe { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:2041:52 | 2041 | section: ProgramSection::TracePoint { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:2058:52 | 2058 | section: ProgramSection::TracePoint { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:2081:54 | 2081 | section: ProgramSection::SocketFilter { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:2151:55 | 2151 | section: ProgramSection::RawTracePoint { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:2168:55 | 2168 | section: ProgramSection::RawTracePoint { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:2243:55 | 2243 | section: ProgramSection::BtfTracePoint { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:2266:59 | 2266 | section: ProgramSection::SkSkbStreamParser { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:2289:59 | 2289 | section: ProgramSection::SkSkbStreamParser { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:2410:58 | 2410 | section: ProgramSection::CgroupSkbIngress { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:2433:58 | 2433 | section: ProgramSection::CgroupSkbIngress { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:2456:51 | 2456 | section: ProgramSection::CgroupSkb { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: struct pattern is not needed for a unit variant --> aya-obj/src/obj.rs:2479:51 | 2479 | section: ProgramSection::CgroupSkb { .. }, | ^^^^^^^ help: remove the struct pattern | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern error: manual implementation of `ok` --> aya-log-common/src/lib.rs:168:36 | 168 | let wire_len: LogValueLength = match value.len().try_into() { | ____________________________________^ 169 | | Ok(wire_len) => Some(wire_len), 170 | | Err(TryFromIntError { .. }) => None, 171 | | }?; | |_____^ help: replace with: `value.len().try_into().ok()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_err error: manual implementation of `err` --> init/src/main.rs:141:30 | 141 | .filter_map(|result| match result { | ______________________________^ 142 | | Ok(()) => None, 143 | | Err(err) => Some(err), 144 | | }) | |_________^ help: replace with: `result.err()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_err error: manual implementation of `err` --> xtask/src/public_api.rs:80:30 | 80 | .filter_map(|result| match result { | ______________________________^ 81 | | Ok(()) => None, 82 | | Err(err) => Some(err), 83 | | }) | |_________^ help: replace with: `result.err()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_err ``` |
1 day ago | |
---|---|---|
.. | ||
include | 4 months ago | |
src | 1 day ago | |
CHANGELOG.md | 3 months ago | |
Cargo.toml | 3 months ago | |
README.md | 2 years ago |
README.md
aya-obj
Status
This crate includes code that started as internal API used by the aya crate. It has been split out so that it can be used by other projects that deal with eBPF object files. Unless you're writing low level eBPF plumbing tools, you should not need to use this crate but see the aya crate instead.
The API as it is today has a few rough edges and is generally not as polished nor stable as the main aya crate API. As always, improvements welcome!
Overview
eBPF programs written with libbpf or aya-bpf are usually compiled into an ELF object file, using various sections to store information about the eBPF programs.
aya-obj
is a library for parsing such eBPF object files, with BTF and
relocation support.
Example
This example loads a simple eBPF program and runs it with rbpf.
use aya_obj::{generated::bpf_insn, Object};
// Parse the object file
let bytes = std::fs::read("program.o").unwrap();
let mut object = Object::parse(&bytes).unwrap();
// Relocate the programs
object.relocate_calls().unwrap();
object.relocate_maps(std::iter::empty()).unwrap();
// Run with rbpf
let instructions = &object.programs["prog_name"].function.instructions;
let data = unsafe {
core::slice::from_raw_parts(
instructions.as_ptr() as *const u8,
instructions.len() * core::mem::size_of::<bpf_insn>(),
)
};
let vm = rbpf::EbpfVmNoData::new(Some(data)).unwrap();
let _return = vm.execute_program().unwrap();