mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Generate correct 0 bytes
This commit is contained in:
parent
a111a41deb
commit
07318256e0
|
@ -19,7 +19,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
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<dyn std::error::Error>> {
|
|||
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<dyn std::error::Error>> {
|
|||
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()?;
|
||||
|
|
Loading…
Reference in a new issue