Skip to content

Commit

Permalink
Documents E_FLAGS_OFFSET.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Nov 14, 2024
1 parent 364c6ec commit 821c03b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,12 @@ impl<C: ContextObject> Executable<C> {

/// Fully loads an ELF
pub fn load(bytes: &[u8], loader: Arc<BuiltinProgram<C>>) -> Result<Self, ElfError> {
let e_flags = LittleEndian::read_u32(bytes.get(48..52).ok_or(ElfParserError::OutOfBounds)?);
const E_FLAGS_OFFSET: usize = 48;
let e_flags = LittleEndian::read_u32(
bytes
.get(E_FLAGS_OFFSET..E_FLAGS_OFFSET.saturating_add(std::mem::size_of::<u32>()))
.ok_or(ElfParserError::OutOfBounds)?,
);
let config = loader.get_config();
let sbpf_version = if config.enabled_sbpf_versions.end() == &SBPFVersion::V1 {
if e_flags == EF_SBPF_V2 {
Expand Down

0 comments on commit 821c03b

Please sign in to comment.