GELF_UPDATE_PHDR(3)

πŸ“¦
version 0.197 Β· 2 versions
, in alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, fedora 43, fedora 44, nixpkgs unstable, ubuntu stonking

πŸ’– 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: if elf has class ELFCLASS32 then p_offset, p_vaddr, p_paddr, p_filesz, p_memsz, and p_align must 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 kind ELF_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 with elf? Use elf_getphdrnum(). She'll tell you. 🌸
  • src β€” Pointer to a GElf_Phdr structure that holds the caller's desired program header table entry contents. And src must not be NULL. 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