-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. cleaning fuzz test crashes by removing some unwrap(), add slice boundary checks and using saturating_* functions. 2. reorganize some structs. elf_header, program_header and section_header mods are now standalone raw data structure, while the counterparts in elf mod contains reference for the whole ELF file for section content retrieval. 3. bump version to 0.3.0 as API changes.
- Loading branch information
1 parent
e7aaaaf
commit 3ec9935
Showing
15 changed files
with
312 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use super::ElfFile; | ||
use crate::elf_header::ElfHeaderRaw; | ||
use core::fmt; | ||
use core::ops; | ||
|
||
pub struct ElfHeader<'a> { | ||
_elf_file: &'a dyn ElfFile, | ||
inner: &'a dyn ElfHeaderRaw, | ||
} | ||
|
||
impl<'a> ElfHeader<'a> { | ||
pub fn new(elf_file: &'a dyn ElfFile, inner: &'a dyn ElfHeaderRaw) -> Self { | ||
Self { | ||
_elf_file: elf_file, | ||
inner, | ||
} | ||
} | ||
} | ||
|
||
impl<'a> ops::Deref for ElfHeader<'a> { | ||
type Target = dyn ElfHeaderRaw + 'a; | ||
fn deref(&self) -> &Self::Target { | ||
self.inner | ||
} | ||
} | ||
|
||
impl<'a> fmt::Debug for ElfHeader<'a> { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
f.debug_struct("ELF Header") | ||
.field("Class", &self.class()) | ||
.field("Endianness", &self.endianness()) | ||
.field("ELF Header Version", &self.header_version()) | ||
.field("ABI", &self.abi()) | ||
.field("ABI Version", &self.abi_version()) | ||
.field("File Type", &self.elftype()) | ||
.field("Target Machine", &self.machine()) | ||
.field("ELF Version", &self.elf_version()) | ||
.field("Entry Point", &self.entry_point()) | ||
.field("Program Header Offset", &self.program_header_offset()) | ||
.field("Section Header Offset", &self.section_header_offset()) | ||
.field("Flags", &self.flags()) | ||
.field("ELF Header Size", &self.elf_header_size()) | ||
.field("Program Header Size", &self.program_header_entry_size()) | ||
.field("Program Header Number", &self.program_header_entry_num()) | ||
.field("Section Header Size", &self.section_header_entry_size()) | ||
.field("Section Header Number", &self.section_header_entry_num()) | ||
.field(".shstr Section Index", &self.shstr_index()) | ||
.finish() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.