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:
2024-09-05 00:26:14 -06:00
parent c403931f0f
commit 9dfdbb9301
3 changed files with 8 additions and 6 deletions

View File

@@ -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(&section_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])?;
}