Merge branch 'main' of github.com:betrusted-io/xous-core into main

This commit is contained in:
bunnie 2022-06-10 18:06:03 +08:00
commit f059f4c85f

View file

@ -315,11 +315,13 @@ pub fn read_minielf<P: AsRef<Path>>(filename: P) -> Result<MiniElf, ElfReadError
debug!(" link: {:?}", s.link()); debug!(" link: {:?}", s.link());
let size = s.size(); let size = s.size();
let no_copy = s.get_type() == Ok(ShType::NoBits);
if s.flags() & SHF_ALLOC == 0 { if s.flags() & SHF_ALLOC == 0 {
debug!("section has no allocations -- skipping"); debug!("section has no allocations -- skipping");
continue; continue;
} }
if s.get_type() == Ok(ShType::NoBits) { if no_copy {
flags |= MiniElfFlags::NOCOPY; flags |= MiniElfFlags::NOCOPY;
} }
if s.flags() & SHF_EXECINSTR != 0 { if s.flags() & SHF_EXECINSTR != 0 {
@ -335,17 +337,17 @@ pub fn read_minielf<P: AsRef<Path>>(filename: P) -> Result<MiniElf, ElfReadError
name, name,
s.offset(), s.offset(),
program_offset, program_offset,
s.raw_data(&elf).len(), if no_copy { 0 } else { s.raw_data(&elf).len() },
program_offset program_offset
); );
// If this section gets copied, add it to the program stream.
if s.get_type() != Ok(ShType::NoBits) {
let section_data = s.raw_data(&elf); let section_data = s.raw_data(&elf);
debug!( debug!(
"Section start: {:02x} {:02x} {:02x} {:02x} going into offset 0x{:08x}", "Section start: {:02x} {:02x} {:02x} {:02x} going into offset 0x{:08x}",
section_data[0], section_data[1], section_data[2], section_data[3], program_offset section_data[0], section_data[1], section_data[2], section_data[3], program_offset
); );
// If this section gets copied, add it to the program stream.
if s.get_type() != Ok(ShType::NoBits) {
program_data program_data
.seek(SeekFrom::Start(program_offset)) .seek(SeekFrom::Start(program_offset))
.map_err(ElfReadError::FileSeekError)?; .map_err(ElfReadError::FileSeekError)?;