Skip to content

Commit

Permalink
Merge pull request #81 from tock/riscv-align-4
Browse files Browse the repository at this point in the history
riscv: ensure total length is multiple of 4
  • Loading branch information
bradjc committed Sep 9, 2023
2 parents fc14c93 + 4dc3417 commit 1972a93
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,12 @@ pub fn elf_to_tbf(
//
// - ARM: make sure the entire TBF is a power of 2 to make configuring the
// MPU easy.
// - RISC_V: make sure the entire TBF is a multiple of 4 to meet TBF
// alignment requirements.
// - x86: use 4k padding to match page size.
//
// RISC-V apps do not need any additional padding.
let trailing_padding = match elf_file.ehdr.e_machine {
elf::abi::EM_ARM => Some(TrailingPadding::TotalSizePowerOfTwo),
elf::abi::EM_RISCV => Some(TrailingPadding::TotalSizeMultiple(4)),
elf::abi::EM_386 => Some(TrailingPadding::TotalSizeMultiple(4096)),
_ => None,
};
Expand Down

0 comments on commit 1972a93

Please sign in to comment.