load_elf_phdrs(9)
π load_elf_phdrs(9) β like, the Kernel API Manual entry bestie π
okay so gather round, we're doing kernel internals today and honestly? it's giving main character energy β¨ this one lives in the Kernel API Manual and it's all about getting those ELF program headers loaded. no cap, it's a short one but she's iconic.
πΈ NAME πΈ
load_elf_phdrs β literally loads ELF program headers. that's the whole vibe. π
β¨ SYNOPSIS β¨
struct elf_phdr * load_elf_phdrs (const struct elfhdr *elf_ex , struct
file *elf_file );
look at her go π returns a struct elf_phdr *, takes two args, slays.
π¦ ARGUMENTS π¦
elf_exβ the ELF header of the binary whose program headers should be loaded. like, the source of truth header, you feel me? πelf_fileβ the opened ELF binary file. the actual file file. the one you already opened, bestie π«Ά
π DESCRIPTION π
okay so here's what she does: she loads the ELF program headers out of the binary file elf_file β the one whose ELF header is pointed to by elf_ex β and drops them into a newly allocated array. brand new array, freshly allocated, no reuse, we love to see it π
π¨ bestie listen: the caller is responsible for freeing the allocated data. that's you. you allocated it (well, she did, on your behalf) and you're gonna free it. no leaking in this house, fr fr π
and if things go sideways? returns NULL upon failure. that's it, that's the failure mode. simple, clean, lowkey terrifying π
π₯ SEE ALSO π₯
- Kernel file
./fs/binfmt_elf.c struct arch_elf_state(9)arch_elf_pt_proc(9)arch_check_elf(9)
like, go read those next, iykyk π
okay that's the page!! sourced from ./fs, dated October 2026, and that's the cute little sign-off from your resident kernel girlie π go free that memory, bestie, and remember β NULL means no π periodt π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms