Skip to content

Commit

Permalink
fix(firmware): support special ELF program header with p_filesz=0
Browse files Browse the repository at this point in the history
Fix #77
  • Loading branch information
andelf committed Nov 15, 2024
1 parent a2d0386 commit 2b749e7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/firmware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ pub fn read_elf(elf_data: &[u8]) -> Result<Firmware> {

let flags = segment.p_flags(endian);

// The number of bytes in the file image of the segment, which can be zero.
if segment.p_filesz(endian) == 0 {
// skip empty segment
continue;
}
let segment_data = segment
.data(endian, elf_data)
.map_err(|_| anyhow::format_err!("Failed to access data for an ELF segment."))?;
Expand Down

0 comments on commit 2b749e7

Please sign in to comment.