elf: fix a section alignment edge case

This commit is contained in:
eupn 2023-03-27 16:29:07 +04:00
parent ceeb2d94cd
commit 199ab0a73c
No known key found for this signature in database
GPG key ID: 6A550BE33BE768A9

View file

@ -372,8 +372,12 @@ pub fn process_minielf(b: &[u8]) -> Result<MiniElf, ElfReadError> {
if s.get_type() != Ok(ShType::NoBits) {
let section_data = s.raw_data(&elf);
let pad_amount = if let Some(next_section) = section_iter.peek() {
if section_data.len() % next_section.align() as usize != 0 {
next_section.align() as usize - (section_data.len() % next_section.align() as usize)
if next_section.get_type() != Ok(ShType::NoBits) {
if section_data.len() % next_section.align() as usize != 0 {
next_section.align() as usize - (section_data.len() % next_section.align() as usize)
} else {
0
}
} else {
0
}