mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
Merge pull request #343 from eupn/patch-1
elf.rs: fix alignment edge case (take 2)
This commit is contained in:
commit
f2e1a89f13
1 changed files with 5 additions and 4 deletions
|
|
@ -372,11 +372,12 @@ pub fn process_minielf(b: &[u8]) -> Result<MiniElf, ElfReadError> {
|
||||||
if s.get_type() != Ok(ShType::NoBits) {
|
if s.get_type() != Ok(ShType::NoBits) {
|
||||||
let section_data = s.raw_data(&elf);
|
let section_data = s.raw_data(&elf);
|
||||||
let pad_amount = if let Some(next_section) = section_iter.peek() {
|
let pad_amount = if let Some(next_section) = section_iter.peek() {
|
||||||
if next_section.get_type() != Ok(ShType::NoBits) {
|
|
||||||
if section_data.len() % next_section.align() as usize != 0 {
|
if section_data.len() % next_section.align() as usize != 0 {
|
||||||
next_section.align() as usize - (section_data.len() % next_section.align() as usize)
|
let pad_amount = next_section.align() as usize - (section_data.len() % next_section.align() as usize);
|
||||||
|
if s.address() + size + pad_amount as u64 > next_section.address() {
|
||||||
|
(next_section.address() - (s.address() + size)) as usize
|
||||||
} else {
|
} else {
|
||||||
0
|
pad_amount
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue