GELF_UPDATE_PHDR(3)
π GELF_UPDATE_PHDR β okay bestie, let's talk β¨
So this page lives in the Libelf Programmer's Manual, section 3, and it's called GELF_UPDATE_PHDR(3). It's all about gelf_update_phdr β the little function that copies a class-independent program header table entry into an ELF descriptor. Yes, that's a mouthful. No, we're not skipping it. Let's go π«Ά
πΈ NAME πΈ
gelf_update_phdr β copy a class-independent program header table entry into an ELF descriptor. That's the whole vibe. That's the job. π
π SYNOPSIS π
#include <gelf.h>
int gelf_update_phdr (Elf *elf, int ndx, GElf_Phdr *src);
Look at her. Three args. No notes. π
π¦ DESCRIPTION π¦
okay so here's the tea β
gelf_update_phdr() copies the class-independent program header table entry from the structure pointed to by src into the program header table of elf at index ndx. Like, it takes your pretty portable struct and slots it right in there. π
And the program header table entry gets translated as necessary to match the class (ELFCLASS32 or ELFCLASS64) of the underlying object file. So you don't gotta worry about the class β she handles it. Iconic behaviour honestly. β¨
π¨ but like, real talk: ifelfhas classELFCLASS32thenp_offset,p_vaddr,p_paddr,p_filesz,p_memsz, andp_alignmust fit within unsigned 32-bit values. So don't be out here trying to cram your giant 64-bit numbers into a 32-bit situation. It will not slay. It will not fit. π
π PARAMETERS π
elfβ Pointer to an ELF descriptor of kindELF_K_ELF. Gotta be the right kind, bestie, we're not accepting substitutes. π§ndxβ Index of the program header table entry to be updated. Wanna know how many program header table entries are chilling withelf? Useelf_getphdrnum(). She'll tell you. πΈsrcβ Pointer to aGElf_Phdrstructure that holds the caller's desired program header table entry contents. Andsrcmust not beNULL. Like, please. Don't do that to her. π
β RETURN VALUE β
On success, this function returns a non-zero value and updates the program header table entry at index ndx. And the program header table gets flagged with ELF_F_DIRTY β because yes, she's changed, and she wants everybody to know. π
On failure, it returns 0 and sets elf_errno. π§οΈ
And here's the little plot twist: if elf is NULL then 0 is returned without setting elf_errno. No explanation, no error code, just a silent 0. it's giving mystery. it's giving chaos. π
π₯ SEE ALSO π₯
elf_flagphdr(3), elf_getphdrnum(3), gelf_getphdr(3), gelf_newphdr(3), libelf(3), elf(5)
(go read them, iykyk β the whole friend group is worth knowing π«Ά)
π ATTRIBUTES π
- Interface:
gelf_update_phdr() - Attribute: Thread safety
- Value:
MT-Safe
Which means she's MT-Safe, so multiple threads can hang out with her at once without drama. main character energy fr fr π
π REPORTING BUGS π
Found a bug? Don't suffer in silence, bestie. Report bugs to <elfutils-devel@sourceware.org> or hit up https://sourceware.org/bugzilla/. The maintainers wanna hear it. Tell them everything. π
and that's the page!! this whole thing came from Libelf, dated 2025-12-27, and it's filed under GELF_UPDATE_PHDR(3) β go forth and update those program headers, you absolute legend πβ¨
π¦ where this page comes from
- alpine 3.24: elfutils-doc 0.195-r0 Β· GPL-3.0-or-later AND ( GPL-2.0-or-later OR LGPL-3.0-or-later )
- arch rolling: libelf 0.196-1
- arch rolling: libelf 0.197-1 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- centos-stream 10: elfutils-libelf-devel 0.197-1.el10 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- centos-stream 9: elfutils-libelf-devel 0.197-1.el9 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- centos-stream 9: elfutils-libelf-devel 0.197-1.el9 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 43: elfutils-libelf-devel 0.196-1.fc43
- fedora 43: elfutils-libelf-devel 0.196-1.fc43
- fedora 43: elfutils-libelf-devel 0.197-1.fc43 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 43: elfutils-libelf-devel 0.197-1.fc43 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 44: elfutils-libelf-devel 0.196-1.fc44
- fedora 44: elfutils-libelf-devel 0.196-1.fc44
- fedora 44: elfutils-libelf-devel 0.197-1.fc44 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 44: elfutils-libelf-devel 0.197-1.fc44 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- nixpkgs unstable: elfutils 0.195
- ubuntu stonking: libelf-dev 0.196-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms