#[non_exhaustive]pub enum ModelError {
Section {
section: SectionId,
problem: SectionProblem,
},
Symbol {
symbol: SymbolId,
problem: SymbolProblem,
},
Relocation {
section: SectionId,
index: usize,
problem: RelocationProblem,
},
SectionsOverlap {
first: SectionId,
second: SectionId,
},
EntryNotExecutable {
entry: u64,
},
UnknownSection {
section: SectionId,
},
InvalidAlignment {
align: u64,
},
AppendToBss,
SizeOverflow,
TooManyItems,
}Expand description
A rule of the object model that an Object breaks, from
Object::validate, from the builders on
Section, or from a reader whose input decodes to an invalid model.
The enum is #[non_exhaustive]: match it with a wildcard arm.
§Examples
use object_lang::{Architecture, ModelError, Object, Symbol, SymbolProblem, Binding};
let mut obj = Object::relocatable(Architecture::X86_64);
let sym = obj.add_symbol(Symbol::undefined("x").with_binding(Binding::Local));
assert_eq!(
obj.validate(),
Err(ModelError::Symbol { symbol: sym, problem: SymbolProblem::LocalUndefined }),
);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Section
A section breaks a rule.
Symbol
A symbol breaks a rule.
Relocation
A relocation breaks a rule.
Fields
index: usizeThe relocation’s position in that section’s
relocations.
problem: RelocationProblemThe rule it breaks.
SectionsOverlap
Two loadable sections of an executable overlap in memory.
Fields
EntryNotExecutable
An executable’s entry point is not inside an executable section.
UnknownSection
A section id that the object does not have, passed to
Object::add_relocation.
InvalidAlignment
An alignment that is zero or not a power of two, passed to
Section::append or
Section::reserve.
AppendToBss
Section::append on a
Bss section, which holds no bytes; use
reserve.
SizeOverflow
A section would grow past the 64-bit size range or past available memory.
TooManyItems
The object holds more sections or symbols than ids can number (2³¹ − 1).
Trait Implementations§
Source§impl Clone for ModelError
impl Clone for ModelError
impl Copy for ModelError
Source§impl Debug for ModelError
impl Debug for ModelError
Source§impl Display for ModelError
impl Display for ModelError
impl Eq for ModelError
Source§impl Error for ModelError
impl Error for ModelError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()