diff --git a/Cargo.lock b/Cargo.lock index 850ccfe..8cb957e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -739,8 +739,7 @@ checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] name = "neotron-loader" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b8634a088b9d5b338a96b3f6ef45a3bc0b9c0f0d562c7d00e498265fd96e8f" +source = "git+https://github.com/Neotron-Compute/neotron-loader?rev=ab92cecd8a458044aef30b39c87112244deb69c6#ab92cecd8a458044aef30b39c87112244deb69c6" [[package]] name = "no_std_io2" @@ -774,7 +773,7 @@ dependencies = [ [[package]] name = "nvme-mi-dev" version = "0.1.0" -source = "git+https://github.com/CodeConstruct/nvme-mi-dev#6dc246aae5fdc46d655b6e0b8126ec34546152d9" +source = "git+https://github.com/CodeConstruct/nvme-mi-dev#b6614f2651dc46df5e7798c133a43669cebfee70" dependencies = [ "crc", "deku 0.19.1 (git+https://github.com/sharksforarms/deku.git?rev=e5363bc11e123bfcfd3467a2a90aeef8b588f432)", diff --git a/xspiloader/Cargo.toml b/xspiloader/Cargo.toml index 2f4bb50..3d1bc9e 100644 --- a/xspiloader/Cargo.toml +++ b/xspiloader/Cargo.toml @@ -17,4 +17,6 @@ cortex-m = { workspace = true } cortex-m-rt = { workspace = true } panic-probe = { workspace = true } -neotron-loader = "0.1.0" +# Required for ELF payloads build with Rust 1.89 +# https://github.com/Neotron-Compute/neotron-loader/pull/2 +neotron-loader = { git = "https://github.com/Neotron-Compute/neotron-loader", rev = "ab92cecd8a458044aef30b39c87112244deb69c6" } diff --git a/xspiloader/src/main.rs b/xspiloader/src/main.rs index ffd629b..03c176f 100644 --- a/xspiloader/src/main.rs +++ b/xspiloader/src/main.rs @@ -247,27 +247,25 @@ async fn load_elf( }; // Attempt to load PT_LOAD segments - if ph.p_type() == neotron_loader::ProgramHeader::PT_LOAD { + if ph.p_type() == neotron_loader::ProgramHeader::PT_LOAD + && ph.p_filesz() > 0 + { info!( "loading 0x{:x} len 0x{:x} from 0x{:x}", ph.p_paddr(), - ph.p_memsz(), + ph.p_filesz(), ph.p_offset() ); // Flush in case it faults log::logger().flush(); - if !valid_dest(ph.p_paddr(), ph.p_memsz()) { + if !valid_dest(ph.p_paddr(), ph.p_filesz()) { error!("Invalid dest"); return Err(()); } - if ph.p_memsz() == 0 { - continue; - } - let (foff, addr, sz) = if ph.p_paddr() != 0 { - (ph.p_offset(), ph.p_paddr(), ph.p_memsz()) + (ph.p_offset(), ph.p_paddr(), ph.p_filesz()) } else { // Rust disallows NULL pointers, which is unfortunate given // 0x0 is the start of ITCM where reset vectors can go. @@ -288,7 +286,7 @@ async fn load_elf( ); } - (ph.p_offset() + 1, ph.p_paddr() + 1, ph.p_memsz() - 1) + (ph.p_offset() + 1, ph.p_paddr() + 1, ph.p_filesz() - 1) }; let dest = (addr as usize) as *mut u8;