Skip to content

Commit

Permalink
chore(sections): return Error as Err
Browse files Browse the repository at this point in the history
  • Loading branch information
toku-sa-n committed Aug 2, 2021
1 parent 121da95 commit 18d0c74
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ pub enum Error {
ValueNotContained,
/// The dynamic link information does not contain a pointer, but a value.
PointerNotContained,
/// 32-bit binaries are not supported.
Binary32BitNotSupported,
}

impl fmt::Display for Error {
Expand Down Expand Up @@ -91,6 +93,7 @@ impl fmt::Display for Error {
Self::DecompressionError => "Failed to decompress the section.",
Self::ValueNotContained => "The dynamic link information does not contain a value, but a pointer.",
Self::PointerNotContained => "The dynamic link information does not contain a pointer, but a value.",
Self::Binary32BitNotSupported => "The 32-bit binaries are not supported.",
}
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ impl<'a> SectionHeader<'a> {
ShType::Note => {
let data = self.raw_data(elf_file);
match elf_file.header.pt1.class() {
Class::ThirtyTwo => return Err("32-bit binaries not implemented"),
Class::ThirtyTwo => return Err(Error::Binary32BitNotSupported),
Class::SixtyFour => {
let header: &'a NoteHeader = read(&data[0..12]);
let index = &data[12..];
SectionData::Note64(header, index)
}
Class::None | Class::Other(_) => return Err("Unknown ELF class"),
Class::None | Class::Other(_) => return Err(Error::InvalidClass),
}
}
ShType::Hash => {
Expand Down

0 comments on commit 18d0c74

Please sign in to comment.