const ELF_MAGIC
pub const ELF_MAGIC = 0x464C457FPurpose
Constant ELF_MAGIC, defining protocol or algorithm parameters.
#core/elfPure zero-allocation ELF64 parser & validator for freestanding kernels.
const ELF_MAGICpub const ELF_MAGIC = 0x464C457FConstant ELF_MAGIC, defining protocol or algorithm parameters.
const ELFCLASS64pub const ELFCLASS64 = 2Constant ELFCLASS64, defining protocol or algorithm parameters.
const ELFDATA2LSBpub const ELFDATA2LSB = 1Constant ELFDATA2LSB, defining protocol or algorithm parameters.
const ET_EXECpub const ET_EXEC = 2Constant ET_EXEC, defining protocol or algorithm parameters.
const ET_DYNpub const ET_DYN = 3Constant ET_DYN, defining protocol or algorithm parameters.
const EM_X86_64pub const EM_X86_64 = 62Constant EM_X86_64, defining protocol or algorithm parameters.
const EM_AARCH64pub const EM_AARCH64 = 183Constant EM_AARCH64, defining protocol or algorithm parameters.
const EM_RISCVpub const EM_RISCV = 243Constant EM_RISCV, defining protocol or algorithm parameters.
const PT_NULLpub const PT_NULL = 0Constant PT_NULL, defining protocol or algorithm parameters.
const PT_LOADpub const PT_LOAD = 1Constant PT_LOAD, defining protocol or algorithm parameters.
const PT_DYNAMICpub const PT_DYNAMIC = 2Constant PT_DYNAMIC, defining protocol or algorithm parameters.
const PT_INTERPpub const PT_INTERP = 3Constant PT_INTERP, defining protocol or algorithm parameters.
const PT_NOTEpub const PT_NOTE = 4Constant PT_NOTE, defining protocol or algorithm parameters.
const PT_PHDRpub const PT_PHDR = 6Constant PT_PHDR, defining protocol or algorithm parameters.
const PT_TLSpub const PT_TLS = 7Constant PT_TLS, defining protocol or algorithm parameters.
const PT_GNU_STACKpub const PT_GNU_STACK = 0x6474E551Constant PT_GNU_STACK, defining protocol or algorithm parameters.
const PT_GNU_RELROpub const PT_GNU_RELRO = 0x6474E552Constant PT_GNU_RELRO, defining protocol or algorithm parameters.
const PF_Xpub const PF_X = 1Constant PF_X, defining protocol or algorithm parameters.
const PF_Wpub const PF_W = 2Constant PF_W, defining protocol or algorithm parameters.
const PF_Rpub const PF_R = 4Constant PF_R, defining protocol or algorithm parameters.
const DT_NULLpub const DT_NULL = 0Constant DT_NULL, defining protocol or algorithm parameters.
const DT_RELApub const DT_RELA = 7Constant DT_RELA, defining protocol or algorithm parameters.
const DT_RELASZpub const DT_RELASZ = 8Constant DT_RELASZ, defining protocol or algorithm parameters.
const DT_RELAENTpub const DT_RELAENT = 9Constant DT_RELAENT, defining protocol or algorithm parameters.
const DT_FLAGSpub const DT_FLAGS = 30Constant DT_FLAGS, defining protocol or algorithm parameters.
const DT_FLAGS_1pub const DT_FLAGS_1 = 0x6FFFFFFBConstant DT_FLAGS_1, defining protocol or algorithm parameters.
const R_X86_64_RELATIVEpub const R_X86_64_RELATIVE = 8Constant R_X86_64_RELATIVE, defining protocol or algorithm parameters.
const R_AARCH64_RELATIVEpub const R_AARCH64_RELATIVE = 1027Constant R_AARCH64_RELATIVE, defining protocol or algorithm parameters.
const R_RISCV_RELATIVEpub const R_RISCV_RELATIVE = 3Constant R_RISCV_RELATIVE, defining protocol or algorithm parameters.
const SHT_NULLpub const SHT_NULL = 0Constant SHT_NULL, defining protocol or algorithm parameters.
const SHT_PROGBITSpub const SHT_PROGBITS = 1Constant SHT_PROGBITS, defining protocol or algorithm parameters.
const SHT_SYMTABpub const SHT_SYMTAB = 2Constant SHT_SYMTAB, defining protocol or algorithm parameters.
const SHT_STRTABpub const SHT_STRTAB = 3Constant SHT_STRTAB, defining protocol or algorithm parameters.
const SHT_NOBITSpub const SHT_NOBITS = 8Constant SHT_NOBITS, defining protocol or algorithm parameters.
const STT_FUNCpub const STT_FUNC = 2Constant STT_FUNC, defining protocol or algorithm parameters.
struct Elf64Ehdrpub struct Elf64Ehdr {
pub magic u32
pub elf_class u8
pub elf_data u8
pub elf_version u8
pub osabi u8
pub pad0 u64
pub e_type u16
pub e_machine u16
pub e_version u32
pub e_entry u64
pub e_phoff u64
pub e_shoff u64
pub e_flags u32
pub e_ehsize u16
pub e_phentsize u16
pub e_phnum u16
pub e_shentsize u16
pub e_shnum u16
pub e_shstrndx u16
}Structure encapsulating magic, elf_class, elf_data, elf_version, osabi.
magic u32elf_class u8elf_data u8elf_version u8osabi u8pad0 u64e_type u16e_machine u16e_version u32e_entry u64e_phoff u64e_shoff u64e_flags u32e_ehsize u16e_phentsize u16e_phnum u16e_shentsize u16e_shnum u16e_shstrndx u16struct Elf64Phdrpub struct Elf64Phdr {
pub p_type u32
pub p_flags u32
pub p_offset u64
pub p_vaddr u64
pub p_paddr u64
pub p_filesz u64
pub p_memsz u64
pub p_align u64
}Structure encapsulating p_type, p_flags, p_offset, p_vaddr, p_paddr.
p_type u32p_flags u32p_offset u64p_vaddr u64p_paddr u64p_filesz u64p_memsz u64p_align u64struct Elf64Dynpub struct Elf64Dyn {
pub d_tag i64
pub d_val u64
}Structure encapsulating d_tag, d_val.
d_tag i64d_val u64struct Elf64Relapub struct Elf64Rela {
pub r_offset u64
pub r_info u64
pub r_addend i64
}Structure encapsulating r_offset, r_info, r_addend.
r_offset u64r_info u64r_addend i64struct Elf64Shdrpub struct Elf64Shdr {
pub sh_name u32
pub sh_type u32
pub sh_flags u64
pub sh_addr u64
pub sh_offset u64
pub sh_size u64
pub sh_link u32
pub sh_info u32
pub sh_addralign u64
pub sh_entsize u64
}Structure encapsulating sh_name, sh_type, sh_flags, sh_addr, sh_offset.
sh_name u32sh_type u32sh_flags u64sh_addr u64sh_offset u64sh_size u64sh_link u32sh_info u32sh_addralign u64sh_entsize u64struct Elf64Sympub struct Elf64Sym {
pub st_name u32
pub st_info u8
pub st_other u8
pub st_shndx u16
pub st_value u64
pub st_size u64
}Structure encapsulating st_name, st_info, st_other, st_shndx, st_value.
st_name u32st_info u8st_other u8st_shndx u16st_value u64st_size u64struct Elf64Imagepub struct Elf64Image {
pub data *raw u8
pub len usize
}Structure encapsulating data, len.
data *raw u8len usizestruct Elf64TlsInfopub struct Elf64TlsInfo {
pub file_off u64
pub file_sz u64
pub mem_sz u64
pub align u64
pub vaddr u64
}Structure encapsulating file_off, file_sz, mem_sz, align, vaddr.
file_off u64file_sz u64mem_sz u64align u64vaddr u64elf64_parsepub fn elf64_parse(data *raw u8, len usize) Elf64ImageElf64 parse.
data *raw u8len usizeElf64Image — a value of this type
(&Elf64Image) ehdrpub fn (img &Elf64Image) ehdr() *raw Elf64EhdrExecute ehdr on &Elf64Image.
img &Elf64ImageElf64Image instance used by this call (borrow).*raw Elf64Ehdr — a value of this type
(&Elf64Image) validate_exec_or_piepub fn (img &Elf64Image) validate_exec_or_pie(expected_machine u16) boolOperation on &Elf64Image: validate exec or pie.
img &Elf64ImageElf64Image instance used by this call (borrow).expected_machine u16bool — true or false
(&Elf64Image) is_piepub fn (img &Elf64Image) is_pie() boolOperation on &Elf64Image: whether it is pie.
img &Elf64ImageElf64Image instance used by this call (borrow).bool — true or false
(&Elf64Image) find_phdrpub fn (img &Elf64Image) find_phdr(p_type u32) *raw Elf64PhdrOperation on &Elf64Image: find phdr.
img &Elf64ImageElf64Image instance used by this call (borrow).p_type u32*raw Elf64Phdr — a value of this type
(&Elf64Image) has_wx_violationpub fn (img &Elf64Image) has_wx_violation() boolOperation on &Elf64Image: whether it has wx violation.
img &Elf64ImageElf64Image instance used by this call (borrow).bool — true or false
(&Elf64Image) validate_execpub fn (img &Elf64Image) validate_exec(expected_machine u16) boolOperation on &Elf64Image: validate exec.
img &Elf64ImageElf64Image instance used by this call (borrow).expected_machine u16bool — true or false
(&Elf64Image) entrypub fn (img &Elf64Image) entry() u64Execute entry on &Elf64Image.
img &Elf64ImageElf64Image instance used by this call (borrow).u64 — a value of this type
(&Elf64Image) phdr_countpub fn (img &Elf64Image) phdr_count() intOperation on &Elf64Image: phdr count.
img &Elf64ImageElf64Image instance used by this call (borrow).int — a value of this type
(&Elf64Image) phdr_atpub fn (img &Elf64Image) phdr_at(idx int) *raw Elf64PhdrOperation on &Elf64Image: phdr at.
img &Elf64ImageElf64Image instance used by this call (borrow).idx int*raw Elf64Phdr — a value of this type
(&Elf64Image) segment_validpub fn (img &Elf64Image) segment_valid(ph *raw Elf64Phdr) boolOperation on &Elf64Image: segment valid.
img &Elf64ImageElf64Image instance used by this call (borrow).ph *raw Elf64Phdrbool — true or false
(&Elf64Image) segment_datapub fn (img &Elf64Image) segment_data(ph *raw Elf64Phdr) *raw u8Operation on &Elf64Image: segment data.
img &Elf64ImageElf64Image instance used by this call (borrow).ph *raw Elf64Phdr*raw u8 — a value of this type
(&Elf64Image) shdr_countpub fn (img &Elf64Image) shdr_count() intOperation on &Elf64Image: shdr count.
img &Elf64ImageElf64Image instance used by this call (borrow).int — a value of this type
(&Elf64Image) shdr_atpub fn (img &Elf64Image) shdr_at(idx int) *raw Elf64ShdrOperation on &Elf64Image: shdr at.
img &Elf64ImageElf64Image instance used by this call (borrow).idx int*raw Elf64Shdr — a value of this type
(&Elf64Image) find_section_by_typepub fn (img &Elf64Image) find_section_by_type(sh_type u32) *raw Elf64ShdrOperation on &Elf64Image: find section by type.
img &Elf64ImageElf64Image instance used by this call (borrow).sh_type u32*raw Elf64Shdr — a value of this type
(&Elf64Image) resolve_symbolpub fn (img &Elf64Image) resolve_symbol(addr u64, out_sym_addr *raw u64) *raw u8Operation on &Elf64Image: resolve symbol.
img &Elf64ImageElf64Image instance used by this call (borrow).addr u64out_sym_addr *raw u64*raw u8 — a value of this type
(&Elf64Image) tls_infopub fn (img &Elf64Image) tls_info(out *raw Elf64TlsInfo) boolOperation on &Elf64Image: tls info.
img &Elf64ImageElf64Image instance used by this call (borrow).out *raw Elf64TlsInfobool — true or false