tools: generate byte addresses for mini elf files

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-03-12 15:29:26 +08:00
parent 1b83177b8a
commit 5aa3358bc0
2 changed files with 3 additions and 6 deletions

View file

@ -308,7 +308,6 @@ pub fn read_minielf<P: AsRef<Path>>(filename: P) -> Result<MiniElf, ElfReadError
debug!(" size: {:?}", s.size());
debug!(" link: {:?}", s.link());
let size = s.size();
let padding = (4 - (size & 3)) & 3;
if s.flags() & SHF_ALLOC == 0 {
debug!("section has no allocations -- skipping");
@ -326,12 +325,11 @@ pub fn read_minielf<P: AsRef<Path>>(filename: P) -> Result<MiniElf, ElfReadError
debug!("Adding {} to the file", name);
debug!(
"{} offset: {:08x} program_offset: {:08x} bytes: {} padding: {} seek: {}",
"{} offset: {:08x} program_offset: {:08x} bytes: {} seek: {}",
name,
s.offset(),
program_offset,
s.raw_data(&elf).len(),
padding,
program_offset
);
let section_data = s.raw_data(&elf);
@ -349,11 +347,10 @@ pub fn read_minielf<P: AsRef<Path>>(filename: P) -> Result<MiniElf, ElfReadError
.write(section_data)
.or_else(|x| Err(ElfReadError::WriteSectionError(x)))?;
program_offset += section_data.len() as u64;
program_offset += padding as u64;
}
sections.push(MiniElfSection {
virt: s.address() as u32,
size: (size + padding) as u32,
size: size as u32,
flags: flags,
name: name.to_string(),
});

View file

@ -73,7 +73,7 @@ impl XousArgument for IniE {
written += output.write(&self.entrypoint.to_le_bytes())?;
for section in &self.sections {
written += output.write(&section.virt.to_le_bytes())?;
let mut word2 = (section.size >> 2).to_le_bytes();
let mut word2 = section.size.to_le_bytes();
word2[3] = section.flags.bits();
written += output.write(&word2)?;
}