tools: pad inie and xkrn tags to 4-bytes

This fixes an issue where images were not word-aligned.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-03-10 13:12:27 +08:00
parent 279e0131c8
commit 36dbc97a61
3 changed files with 10 additions and 14 deletions

View file

@ -15,18 +15,6 @@ use tools::xous_arguments::XousArguments;
use clap::{App, Arg};
// fn pad_file_to_4_bytes(f: &mut File) {
// while f
// .seek(SeekFrom::Current(0))
// .expect("couldn't check file position")
// & 3
// != 0
// {
// println!("padding...");
// f.seek(SeekFrom::Current(1)).expect("couldn't pad file");
// }
// }
fn main() {
env_logger::init();
let matches = App::new("Xous Image Creator")

View file

@ -35,7 +35,11 @@ impl fmt::Display for IniE {
}
impl IniE {
pub fn new(entrypoint: u32, sections: Vec<MiniElfSection>, data: Vec<u8>) -> IniE {
pub fn new(entrypoint: u32, sections: Vec<MiniElfSection>, mut data: Vec<u8>) -> IniE {
// pad the data to 4 bytes
while data.len() & 3 != 0 {
data.push(0);
}
IniE {
load_offset: 0,
entrypoint,

View file

@ -45,8 +45,12 @@ impl XousKernel {
data_size: u32,
bss_size: u32,
entrypoint: u32,
program: Vec<u8>,
mut program: Vec<u8>,
) -> XousKernel {
// pad the program to 4 bytes
while program.len() & 3 != 0 {
program.push(0);
}
XousKernel {
load_offset: 0,
text_offset,