From 9dfdbb93019022d57206f456be1648f2884004cb Mon Sep 17 00:00:00 2001 From: Luke Street Date: Thu, 5 Sep 2024 00:26:14 -0600 Subject: [PATCH] Fix v1-2 REL alignment regression Alignment after section data and before relocations / import table is exclusive to REL v3. --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/util/rel.rs | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2e80c8..bbb0b8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -367,7 +367,7 @@ checksum = "c2e06f9bce634a3c898eb1e5cb949ff63133cbb218af93cc9b38b31d6f3ea285" [[package]] name = "decomp-toolkit" -version = "0.9.5" +version = "0.9.6" dependencies = [ "anyhow", "ar", diff --git a/Cargo.toml b/Cargo.toml index ac02225..f9ae0de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "decomp-toolkit" description = "Yet another GameCube/Wii decompilation toolkit." authors = ["Luke Street "] license = "MIT OR Apache-2.0" -version = "0.9.5" +version = "0.9.6" edition = "2021" publish = false repository = "https://github.com/encounter/decomp-toolkit" diff --git a/src/util/rel.rs b/src/util/rel.rs index 229ba7c..dc4864f 100644 --- a/src/util/rel.rs +++ b/src/util/rel.rs @@ -853,8 +853,10 @@ where offset = (offset + align) & !align; offset += section.size() as u32; } - // Align to 4 after section data - offset = (offset + 3) & !3; + if info.version >= 3 { + // Align to 4 after section data + offset = (offset + 3) & !3; + } fn do_relocation_layout( relocations: &[RelReloc], @@ -1047,8 +1049,8 @@ where } w.write_all(§ion_data)?; } - // Align to 4 after section data - { + if info.version >= 3 { + // Align to 4 after section data let position = w.stream_position()?; w.write_all(&vec![0u8; calculate_padding(position, 4) as usize])?; }