diff --git a/src/errors.rs b/src/errors.rs index fe2d9ce..ed9b569 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -27,6 +27,8 @@ pub enum Error { UnknownMagic(u32), #[error("unknown symbol type, {0}.")] UnknownSymType(u8), + #[error("unknown export symbol kind, {0}.")] + UnknownExportSymKind(u8), #[error("offset {0} out of range: {1:?}.")] OutOfRange(usize, Range), #[error("number overflowing.")] diff --git a/src/export.rs b/src/export.rs index 64271bc..f65e5de 100644 --- a/src/export.rs +++ b/src/export.rs @@ -3,8 +3,8 @@ use std::io::Cursor; use byteorder::ReadBytesExt; use crate::commands::CursorExt; -use crate::consts::*; use crate::errors::{Error::*, Result}; +use crate::{consts::*, MachError}; #[derive(Clone, Copy, Debug, PartialEq)] pub enum ExportKind { @@ -41,7 +41,7 @@ impl Exported { EXPORT_SYMBOL_FLAGS_KIND_REGULAR => ExportKind::Regular, EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL => ExportKind::ThreadLocal, EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE => ExportKind::Absolute, - _ => unreachable!(), + invalid => return Err(MachError::UnknownExportSymKind(invalid)), }; let flags = ExportSymbolFlags::from_bits_truncate(flags as u32);