Skip to content

Commit

Permalink
Skip zero size sections (observed on a LOAD segment from LLD link)
Browse files Browse the repository at this point in the history
  • Loading branch information
gamozolabs committed Mar 14, 2022
1 parent b0a5943 commit 4e8118e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ pub fn write_file(path: impl AsRef<Path>, base: Option<u64>,
let _align = consume_native!(reader, bt, en, "PH align")?;

if typ == PT_LOAD {
// If the section is zero size, skip it entirely
if memsz == 0 {
continue;
}

// Read initialized bytes from file if needed
let mut bytes = Vec::new();
if filesz > 0 {
Expand Down

0 comments on commit 4e8118e

Please sign in to comment.