File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -224,15 +224,21 @@ impl TransientProgramArea {
224224
225225 let mut iter = loader. iter_program_headers ( ) ;
226226 while let Some ( Ok ( ph) ) = iter. next ( ) {
227- if ph. p_vaddr ( ) >= 0x2000_1000 {
227+ if ph. p_vaddr ( ) as * mut u32 >= self . memory_bottom
228+ && ph. p_type ( ) == neotron_loader:: ProgramHeader :: PT_LOAD
229+ {
228230 println ! ( "Loading {} bytes to 0x{:08x}" , ph. p_memsz( ) , ph. p_vaddr( ) ) ;
229231 let ram = unsafe {
230232 core:: slice:: from_raw_parts_mut ( ph. p_vaddr ( ) as * mut u8 , ph. p_memsz ( ) as usize )
231233 } ;
234+ // Zero all of it.
232235 for b in ram. iter_mut ( ) {
233236 * b = 0 ;
234237 }
235- source. uncached_read ( ph. p_offset ( ) , & mut ram[ 0 ..ph. p_filesz ( ) as usize ] ) ?;
238+ // Replace some of those zeros with bytes from disk.
239+ if ph. p_filesz ( ) != 0 {
240+ source. uncached_read ( ph. p_offset ( ) , & mut ram[ 0 ..ph. p_filesz ( ) as usize ] ) ?;
241+ }
236242 }
237243 }
238244
You can’t perform that action at this time.
0 commit comments