From 07318256e0883901e2a0d5bc37b247a2ffab03d5 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Thu, 6 Apr 2023 23:09:19 +0100 Subject: [PATCH] Generate correct 0 bytes --- agb-gbafix/src/main.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/agb-gbafix/src/main.rs b/agb-gbafix/src/main.rs index 88747d80..de7e9fb1 100644 --- a/agb-gbafix/src/main.rs +++ b/agb-gbafix/src/main.rs @@ -19,7 +19,9 @@ fn main() -> Result<(), Box> { let mut header = gbafix::GBAHeader::default(); - let mut written_header = false; + const GBA_START_ADDRESS: u64 = 0x8000000; + let mut address = GBA_START_ADDRESS; + for section_header in section_headers.iter() { const SHT_NOBITS: u32 = 8; const SHT_NULL: u32 = 0; @@ -31,12 +33,16 @@ fn main() -> Result<(), Box> { continue; } + for _ in address..section_header.sh_addr { + output.write_all(&[0])?; + } + let (mut data, compression) = elf_file.section_data(§ion_header)?; if let Some(compression) = compression { panic!("Cannot decompress elf content, but got compression header {compression:?}"); } - if !written_header { + if address == GBA_START_ADDRESS { const GBA_HEADER_SIZE: usize = 192; assert!( @@ -51,10 +57,11 @@ fn main() -> Result<(), Box> { output.write_all(header_bytes)?; data = &data[GBA_HEADER_SIZE..]; - written_header = true; + address += GBA_HEADER_SIZE as u64; } output.write_all(data)?; + address += data.len() as u64; } output.flush()?;