mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
tools: generate byte addresses for mini elf files
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
1b83177b8a
commit
5aa3358bc0
2 changed files with 3 additions and 6 deletions
|
|
@ -308,7 +308,6 @@ pub fn read_minielf<P: AsRef<Path>>(filename: P) -> Result<MiniElf, ElfReadError
|
||||||
debug!(" size: {:?}", s.size());
|
debug!(" size: {:?}", s.size());
|
||||||
debug!(" link: {:?}", s.link());
|
debug!(" link: {:?}", s.link());
|
||||||
let size = s.size();
|
let size = s.size();
|
||||||
let padding = (4 - (size & 3)) & 3;
|
|
||||||
|
|
||||||
if s.flags() & SHF_ALLOC == 0 {
|
if s.flags() & SHF_ALLOC == 0 {
|
||||||
debug!("section has no allocations -- skipping");
|
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!("Adding {} to the file", name);
|
||||||
debug!(
|
debug!(
|
||||||
"{} offset: {:08x} program_offset: {:08x} bytes: {} padding: {} seek: {}",
|
"{} offset: {:08x} program_offset: {:08x} bytes: {} seek: {}",
|
||||||
name,
|
name,
|
||||||
s.offset(),
|
s.offset(),
|
||||||
program_offset,
|
program_offset,
|
||||||
s.raw_data(&elf).len(),
|
s.raw_data(&elf).len(),
|
||||||
padding,
|
|
||||||
program_offset
|
program_offset
|
||||||
);
|
);
|
||||||
let section_data = s.raw_data(&elf);
|
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)
|
.write(section_data)
|
||||||
.or_else(|x| Err(ElfReadError::WriteSectionError(x)))?;
|
.or_else(|x| Err(ElfReadError::WriteSectionError(x)))?;
|
||||||
program_offset += section_data.len() as u64;
|
program_offset += section_data.len() as u64;
|
||||||
program_offset += padding as u64;
|
|
||||||
}
|
}
|
||||||
sections.push(MiniElfSection {
|
sections.push(MiniElfSection {
|
||||||
virt: s.address() as u32,
|
virt: s.address() as u32,
|
||||||
size: (size + padding) as u32,
|
size: size as u32,
|
||||||
flags: flags,
|
flags: flags,
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ impl XousArgument for IniE {
|
||||||
written += output.write(&self.entrypoint.to_le_bytes())?;
|
written += output.write(&self.entrypoint.to_le_bytes())?;
|
||||||
for section in &self.sections {
|
for section in &self.sections {
|
||||||
written += output.write(§ion.virt.to_le_bytes())?;
|
written += output.write(§ion.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();
|
word2[3] = section.flags.bits();
|
||||||
written += output.write(&word2)?;
|
written += output.write(&word2)?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue