pub struct ElfParser<'a> { /* private fields */ }Implementations§
Source§impl<'a> ElfParser<'a>
impl<'a> ElfParser<'a>
Sourcepub fn new(data: &'a [u8]) -> Result<Self>
pub fn new(data: &'a [u8]) -> Result<Self>
Examples found in repository?
examples/basic.rs (line 9)
3fn main() -> elflib::Result<()> {
4 // let mut content = std::fs::read("/lib/modules/6.2.0-34-generic/kernel/net/nfc/nfc.ko").unwrap();
5 // let mut content = std::fs::read("/usr/bin/ls").unwrap();
6 let mut content =
7 std::fs::read("./test_binaries/build/mips64-linux-gnuabi64-gcc-main").unwrap();
8
9 let parser = ElfParser::new(&mut content)?;
10 let sections = parser.section_headers()?;
11 for section_res in sections {
12 let section = section_res?;
13 match section.data()? {
14 elflib::SectionData::RelocationSection(rel_section) => {
15 for rel_entry_res in rel_section.entries {
16 let rel_entry = rel_entry_res?;
17 println!("{:?}", rel_entry);
18 }
19 }
20 elflib::SectionData::SymbolTable(symbol_entries) => {
21 for symbol_res in symbol_entries {
22 let symbol = symbol_res?;
23 println!("{:?}", symbol.name());
24 }
25 }
26 _ => {}
27 }
28 }
29 Ok(())
30}pub fn data(&self) -> &'a [u8]
pub fn file_info(&self) -> ElfFileInfo
pub fn header(&self) -> Result<ElfHeader>
pub fn program_headers(&self) -> Result<ProgramHeaders<'a>>
Sourcepub fn section_headers(&self) -> Result<SectionHeaders<'a>>
pub fn section_headers(&self) -> Result<SectionHeaders<'a>>
Examples found in repository?
examples/basic.rs (line 10)
3fn main() -> elflib::Result<()> {
4 // let mut content = std::fs::read("/lib/modules/6.2.0-34-generic/kernel/net/nfc/nfc.ko").unwrap();
5 // let mut content = std::fs::read("/usr/bin/ls").unwrap();
6 let mut content =
7 std::fs::read("./test_binaries/build/mips64-linux-gnuabi64-gcc-main").unwrap();
8
9 let parser = ElfParser::new(&mut content)?;
10 let sections = parser.section_headers()?;
11 for section_res in sections {
12 let section = section_res?;
13 match section.data()? {
14 elflib::SectionData::RelocationSection(rel_section) => {
15 for rel_entry_res in rel_section.entries {
16 let rel_entry = rel_entry_res?;
17 println!("{:?}", rel_entry);
18 }
19 }
20 elflib::SectionData::SymbolTable(symbol_entries) => {
21 for symbol_res in symbol_entries {
22 let symbol = symbol_res?;
23 println!("{:?}", symbol.name());
24 }
25 }
26 _ => {}
27 }
28 }
29 Ok(())
30}pub fn section_names_string_table(&self) -> Result<StringTable<'a>>
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for ElfParser<'a>
impl<'a> RefUnwindSafe for ElfParser<'a>
impl<'a> Send for ElfParser<'a>
impl<'a> Sync for ElfParser<'a>
impl<'a> Unpin for ElfParser<'a>
impl<'a> UnwindSafe for ElfParser<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more