fn load(
        &mut self,
        flags: elfloader::Flags,
        destination: u64,
        region: &[u8],
    ) -> Result<(), elfloader::ElfLoaderErr> {
        let destination = self.offset + destination;

        // Only write to the read-only sections, writable frames already have
        // the right content (see DataSecLoader in src/process.rs)
        if !flags.is_write() {
            self.read_only_offset = destination + region.len();
            info!(
                "ELF Load of read-only region at {:#x} -- {:#x}",
                destination,
                destination + region.len()
            );

            // Load the region at destination in the kernel space
            for (idx, val) in region.iter().enumerate() {
                let vaddr = VAddr::from(destination + idx);
                let (paddr, _rights) = self
                    .vspace
                    .resolve(vaddr)
                    .map_err(|_e| "Can't write to the resolved address in the kernel vspace.")?;

                // TODO(perf): Inefficient byte-wise copy also within a 4 KiB /
                // 2 MiB page we don't have to resolve_addr every time
                if idx == 0 {
                    trace!(
                        "write ptr = {:p} vaddr = {:#x} dest+idx={:#x}",
                        paddr,
                        vaddr,
                        destination + idx
                    );
                }

                let ptr: *mut u8 = paddr_to_kernel_vaddr(paddr).as_mut_ptr();
                unsafe {
                    *ptr = *val;
                }
            }
        } else {
            debug!(
                "Skip ELF Load of writeable region at {:#x} -- {:#x}",
                destination,
                destination + region.len()
            );
        }

        Ok(())
    }
/// Load a region of bytes into the virtual address space of the process.
Load a region of bytes into the virtual address space of the process.
Load a region of bytes into the virtual address space of the process .
fn load(
        &mut self,
        flags: elfloader::Flags,
        destination: u64,
        region: &[u8],
    ) -> Result<(), elfloader::ElfLoaderErr> {
        let destination = self.offset + destination;
        // Only write to the read-only sections, writable frames already have
        // the right content (see DataSecLoader in src/process.rs)
        if !flags.is_write() {
            self.read_only_offset = destination + region.len();
            info!(
                "ELF Load of read-only region at {:#x} -- {:#x}",
                destination,
                destination + region.len()
            );
            // Load the region at destination in the kernel space
            for (idx, val) in region.iter().enumerate() {
                let vaddr = VAddr::from(destination + idx);
                let (paddr, _rights) = self
                    .vspace
                    .resolve(vaddr)
                    .map_err(|_e| "Can't write to the resolved address in the kernel vspace.")?;
                // TODO(perf): Inefficient byte-wise copy also within a 4 KiB /
                // 2 MiB page we don't have to resolve_addr every time
                if idx == 0 {
                    trace!(
                        "write ptr = {:p} vaddr = {:#x} dest+idx={:#x}",
                        paddr,
                        vaddr,
                        destination + idx
                    );
                }
                let ptr: *mut u8 = paddr_to_kernel_vaddr(paddr).as_mut_ptr();
                unsafe {
                    *ptr = *val;
                }
            }
        } else {
            debug!(
                "Skip ELF Load of writeable region at {:#x} -- {:#x}",
                destination,
                destination + region.len()
            );
        }
        Ok(())
    }
fn load ( & mut self , flags : elfloader :: Flags , destination : u64 , region : & [ u8 ] , ) -> Result < ( ) , elfloader :: ElfLoaderErr > { let destination = self . offset + destination ; // Only write to the read-only sections, writable frames already have // the right content (see DataSecLoader in src/process.rs) if ! flags . is_write ( ) { self . read_only_offset = destination + region . len ( ) ; info ! ( " " destination destination region len ( ) ) ; // Load the region at destination in the kernel space for ( idx , val ) in region . iter ( ) . enumerate ( ) { let vaddr = VAddr :: from ( destination + idx ) ; let ( paddr , _rights ) = self . vspace . resolve ( vaddr ) . map_err ( | _e | " " ) ? ; // TODO(perf): Inefficient byte-wise copy also within a 4 KiB / // 2 MiB page we don't have to resolve_addr every time if idx == 0 { trace ! ( " " paddr vaddr destination idx ) ; } let ptr : * mut u8 = paddr_to_kernel_vaddr ( paddr ) . as_mut_ptr ( ) ; unsafe { * ptr = * val ; } } } else { debug ! ( " " destination destination region len ( ) ) ; } Ok ( ( ) ) }
Load a region of bytes into the virtual address space of the process.
Load a region of bytes into the virtual address space of the process .
&mut self
flags
elfloader::Flags
destination
u64
region
&[u8]
&mut self
flags
elfloader::Flags
destination
u64
region
&[u8]