Skip to content

Commit

Permalink
Merge pull request #1 from bincsh/increase-pad-size
Browse files Browse the repository at this point in the history
Increase pad size
  • Loading branch information
bincsh authored Sep 29, 2022
2 parents e740ffa + a0d3050 commit 60895c0
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,19 +436,27 @@ pub fn elf_to_tbf<W: Write>(
// a new address segment. We need the start of the next section
// to be after the previous one, and the gap to not be _too_
// large.
if start > end && (start - end) < 100 {
if start > end {
// If this is the next section in the same segment, then
// check if there is any padding required.
let padding = start - end;
if padding > 0 {
if verbose {
println!(" Adding {} bytes of padding between sections", padding,);
}

// Increment our index pointer and add the padding bytes.
binary_index += padding;
let zero_buf = [0_u8; 512];
binary.extend(&zero_buf[..padding]);
if padding < 1024 {
if padding > 0 {
if verbose {
println!(" Adding {} bytes of padding between sections", padding,);
}

// Increment our index pointer and add the padding bytes.
binary_index += padding;
let zero_buf = [0_u8; 1024];
binary.extend(&zero_buf[..padding]);
}
} else {
println!(
"Warning! Padding to section {} is too large ({} bytes).",
section.shdr.name, padding
);
}
}
}
Expand Down

0 comments on commit 60895c0

Please sign in to comment.