Read a 16-bit little-endian value from bytes at the given offset
(bytes: &[u8], offset: usize)
| 97 | .checked_add(2) |
| 98 | .ok_or_else(|| VmError::Other("ELF read overflow".to_owned()))?; |
| 99 | let slice = bytes |
| 100 | .get(offset..end) |
| 101 | .ok_or_else(|| VmError::Other("ELF read out of bounds".to_owned()))?; |
| 102 | Ok(u16::from_le_bytes([slice[0], slice[1]])) |
| 103 | } |
| 104 | |
| 105 | fn read_u32(bytes: &[u8], offset: usize) -> Result<u32, VmError> { |
| 106 | let end = offset |
| 107 | .checked_add(4) |
| 108 | .ok_or_else(|| VmError::Other("ELF read overflow".to_owned()))?; |
| 109 | let slice = bytes |
| 110 | .get(offset..end) |