Module elf_loader

Source
Expand description

ELF Loading Module

This module provides functionality for loading ELF (Executable and Linkable Format) executables into a task’s memory space. It supports 64-bit ELF files and handles the parsing of ELF headers and program headers, as well as the mapping of loadable segments into memory.

§Components

  • ElfHeader: Represents the ELF file header which contains metadata about the file
  • ProgramHeader: Represents a program header which describes a segment in the ELF file
  • LoadedSegment: Represents a segment after it has been loaded into memory
  • Error types for handling various failure scenarios during ELF parsing and loading

§Main Functions

  • load_elf_into_task: Loads an ELF file from a file handle into a task’s memory space
  • map_elf_segment: Maps an ELF segment into a task’s virtual memory

§Constants

The module defines various constants for ELF parsing, including:

  • Magic numbers for identifying ELF files
  • ELF class identifiers (64-bit)
  • Data encoding formats (little/big endian)
  • Program header types and segment flags (Read/Write/Execute)

§Endian Support

The module provides endian-aware data reading functions to correctly parse ELF files regardless of the endianness used in the file.

Structs§

ElfHeader
ElfHeaderParseError
ElfLoaderError
LoadedSegment
ProgramHeader
ProgramHeaderParseError

Enums§

ElfHeaderParseErrorKind
ProgramHeaderParseErrorKind

Constants§

EI_CLASS 🔒
EI_DATA 🔒
EI_MAG0 🔒
EI_MAG1 🔒
EI_MAG2 🔒
EI_MAG3 🔒
ELFCLASS64 🔒
ELFDATA2LSB 🔒
ELFMAG 🔒
PF_R
PF_W
PF_X
PT_LOAD 🔒

Functions§

load_elf_into_task
Load an ELF file into a task’s memory space
map_elf_segment 🔒
read_u16 🔒
read_u32 🔒
read_u64 🔒