Fix v1-2 REL alignment regression

Alignment after section data and
before relocations / import table
is exclusive to REL v3.
This commit is contained in:
Luke Street 2024-09-05 00:26:14 -06:00
parent c403931f0f
commit 9dfdbb9301
3 changed files with 8 additions and 6 deletions

2
Cargo.lock generated
View File

@ -367,7 +367,7 @@ checksum = "c2e06f9bce634a3c898eb1e5cb949ff63133cbb218af93cc9b38b31d6f3ea285"
[[package]] [[package]]
name = "decomp-toolkit" name = "decomp-toolkit"
version = "0.9.5" version = "0.9.6"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"ar", "ar",

View File

@ -3,7 +3,7 @@ name = "decomp-toolkit"
description = "Yet another GameCube/Wii decompilation toolkit." description = "Yet another GameCube/Wii decompilation toolkit."
authors = ["Luke Street <luke@street.dev>"] authors = ["Luke Street <luke@street.dev>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
version = "0.9.5" version = "0.9.6"
edition = "2021" edition = "2021"
publish = false publish = false
repository = "https://github.com/encounter/decomp-toolkit" repository = "https://github.com/encounter/decomp-toolkit"

View File

@ -853,8 +853,10 @@ where
offset = (offset + align) & !align; offset = (offset + align) & !align;
offset += section.size() as u32; offset += section.size() as u32;
} }
// Align to 4 after section data if info.version >= 3 {
offset = (offset + 3) & !3; // Align to 4 after section data
offset = (offset + 3) & !3;
}
fn do_relocation_layout( fn do_relocation_layout(
relocations: &[RelReloc], relocations: &[RelReloc],
@ -1047,8 +1049,8 @@ where
} }
w.write_all(&section_data)?; w.write_all(&section_data)?;
} }
// Align to 4 after section data if info.version >= 3 {
{ // Align to 4 after section data
let position = w.stream_position()?; let position = w.stream_position()?;
w.write_all(&vec![0u8; calculate_padding(position, 4) as usize])?; w.write_all(&vec![0u8; calculate_padding(position, 4) as usize])?;
} }