mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
Pad the result
This commit is contained in:
parent
b76781799a
commit
44e0d24f1b
|
@ -42,10 +42,14 @@ fn write_gba_file<W: Write>(input: &[u8], output: &mut W) -> Result<()> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if address < section_header.sh_addr {
|
||||||
for _ in address..section_header.sh_addr {
|
for _ in address..section_header.sh_addr {
|
||||||
output.write_all(&[0])?;
|
output.write_all(&[0])?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
address = section_header.sh_addr;
|
||||||
|
}
|
||||||
|
|
||||||
let (mut data, compression) = elf_file.section_data(§ion_header)?;
|
let (mut data, compression) = elf_file.section_data(§ion_header)?;
|
||||||
if let Some(compression) = compression {
|
if let Some(compression) = compression {
|
||||||
bail!("Cannot decompress elf content, but got compression header {compression:?}");
|
bail!("Cannot decompress elf content, but got compression header {compression:?}");
|
||||||
|
@ -73,5 +77,15 @@ fn write_gba_file<W: Write>(input: &[u8], output: &mut W) -> Result<()> {
|
||||||
address += data.len() as u64;
|
address += data.len() as u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let length = address - GBA_START_ADDRESS;
|
||||||
|
|
||||||
|
if !length.is_power_of_two() {
|
||||||
|
let required_padding = length.next_power_of_two() - length;
|
||||||
|
|
||||||
|
for _ in 0..required_padding {
|
||||||
|
output.write_all(&[0])?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue